@funnelfox/billing 0.5.0-beta.2 → 0.5.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-index.cjs.js +30 -22
- package/dist/chunk-index.cjs2.js +27 -10
- package/dist/chunk-index.es.js +24 -16
- package/dist/chunk-index.es2.js +27 -10
- package/dist/funnelfox-billing.cjs.js +121 -33
- package/dist/funnelfox-billing.esm.js +121 -33
- package/dist/funnelfox-billing.js +173 -60
- package/dist/funnelfox-billing.min.js +1 -1
- package/package.json +2 -2
- package/src/types.d.ts +32 -10
package/dist/chunk-index.es2.js
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* @author Funnelfox
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
|
-
var template = "<div>\n <label class=\"ff-card-form-label\" for=\"cardNumberInput\">Card number</label>\n <div id=\"cardNumberInput\"></div>\n <div class=\"errorContainer\"></div>\n</div>\n<div class=\"card-form-row\">\n <div>\n <label class=\"ff-card-form-label\" for=\"expiryInput\">Expiration date</label>\n <div id=\"expiryInput\"></div>\n <div class=\"errorContainer\"></div>\n </div>\n <div>\n <label class=\"ff-card-form-label\" for=\"cvvInput\">Security code</label>\n <div id=\"cvvInput\">\n <svg width=\"200\" height=\"200\" viewBox=\"0 0 200 200\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect width=\"200\" height=\"200\" fill=\"transparent\"/>\n <g clip-path=\"url(#clip0_0_1)\">\n <path d=\"M157.555 23C168.279 23.0002 177 31.7394 177 42.4854V80.5889C171.946 72.0151 164.749 64.8558 156.146 59.8457H166.394V42.4854C166.393 37.6004 162.43 33.6291 157.555 33.6289H27.4453C22.5704 33.6291 18.6066 37.6004 18.6064 42.4854V59.8457H97.8535C88.9153 65.0512 81.4954 72.5771 76.4189 81.5986H18.6064V127.515C18.6066 132.4 22.5704 136.371 27.4453 136.371H75.3281C77.2742 140.177 79.6285 143.739 82.333 147H27.4453C16.7215 147 8.00019 138.261 8 127.515V42.4854C8.0002 31.7394 16.7215 23.0002 27.4453 23H157.555Z\" fill=\"#93939A\"/>\n <mask id=\"path-2-outside-1_0_1\" maskUnits=\"userSpaceOnUse\" x=\"68.5012\" y=\"52.0311\" width=\"135\" height=\"135\" fill=\"black\">\n <rect fill=\"white\" x=\"68.5012\" y=\"52.0311\" width=\"135\" height=\"135\"/>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\"/>\n </mask>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\" fill=\"#93939A\"/>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\" stroke=\"transparent\" stroke-width=\"20\" mask=\"url(#path-2-outside-1_0_1)\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_0_1\">\n <rect width=\"200\" height=\"200\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n </div>\n <div class=\"errorContainer\"></div>\n </div>\n</div>\n";
|
|
8
|
+
var template = "<div>\n <label class=\"ff-card-form-label\" for=\"cardNumberInput\">Card number</label>\n <div id=\"cardNumberInput\"></div>\n <div class=\"errorContainer\"></div>\n</div>\n<div class=\"card-form-row\">\n <div>\n <label class=\"ff-card-form-label\" for=\"expiryInput\">Expiration date</label>\n <div id=\"expiryInput\"></div>\n <div class=\"errorContainer\"></div>\n </div>\n <div>\n <label class=\"ff-card-form-label\" for=\"cvvInput\">Security code</label>\n <div id=\"cvvInput\">\n <svg width=\"200\" height=\"200\" viewBox=\"0 0 200 200\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect width=\"200\" height=\"200\" fill=\"transparent\"/>\n <g clip-path=\"url(#clip0_0_1)\">\n <path d=\"M157.555 23C168.279 23.0002 177 31.7394 177 42.4854V80.5889C171.946 72.0151 164.749 64.8558 156.146 59.8457H166.394V42.4854C166.393 37.6004 162.43 33.6291 157.555 33.6289H27.4453C22.5704 33.6291 18.6066 37.6004 18.6064 42.4854V59.8457H97.8535C88.9153 65.0512 81.4954 72.5771 76.4189 81.5986H18.6064V127.515C18.6066 132.4 22.5704 136.371 27.4453 136.371H75.3281C77.2742 140.177 79.6285 143.739 82.333 147H27.4453C16.7215 147 8.00019 138.261 8 127.515V42.4854C8.0002 31.7394 16.7215 23.0002 27.4453 23H157.555Z\" fill=\"#93939A\"/>\n <mask id=\"path-2-outside-1_0_1\" maskUnits=\"userSpaceOnUse\" x=\"68.5012\" y=\"52.0311\" width=\"135\" height=\"135\" fill=\"black\">\n <rect fill=\"white\" x=\"68.5012\" y=\"52.0311\" width=\"135\" height=\"135\"/>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\"/>\n </mask>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\" fill=\"#93939A\"/>\n <path d=\"M190.242 160.457L170.136 140.351C166.533 145.552 162.023 150.063 156.821 153.666L176.927 173.772C178.693 175.538 181.088 176.53 183.585 176.53C186.082 176.53 188.477 175.538 190.242 173.772C192.008 172.007 193 169.612 193 167.115C193 164.618 192.008 162.223 190.242 160.457ZM126.436 157.901C116.955 157.901 107.688 155.089 99.8048 149.822C91.922 144.555 85.7781 137.069 82.15 128.31C78.5219 119.551 77.5727 109.913 79.4222 100.614C81.2718 91.3158 85.8371 82.7746 92.5409 76.0708C99.2447 69.367 107.786 64.8017 117.084 62.9521C126.383 61.1026 136.021 62.0518 144.78 65.6799C153.539 69.308 161.025 75.4519 166.292 83.3347C171.559 91.2175 174.371 100.485 174.371 109.966C174.371 122.679 169.32 134.871 160.331 143.861C151.341 152.85 139.149 157.901 126.436 157.901ZM163.719 109.966C163.719 102.592 161.532 95.3838 157.435 89.2527C153.339 83.1216 147.516 78.343 140.703 75.5212C133.891 72.6994 126.395 71.9611 119.162 73.3996C111.93 74.8382 105.287 78.389 100.073 83.6031C94.8591 88.8171 91.3083 95.4602 89.8697 102.692C88.4312 109.924 89.1695 117.421 91.9913 124.233C94.8131 131.046 99.5918 136.869 105.723 140.965C111.854 145.062 119.062 147.248 126.436 147.248C136.324 147.248 145.807 143.32 152.799 136.329C159.791 129.337 163.719 119.854 163.719 109.966ZM133.645 102.757C133.398 102.51 133.104 102.313 132.781 102.179C132.458 102.046 132.112 101.977 131.762 101.977C131.412 101.977 131.066 102.046 130.743 102.179C130.42 102.313 130.126 102.51 129.879 102.757L126.436 106.2L122.993 102.757C122.49 102.272 121.818 102.003 121.119 102.01C120.421 102.016 119.753 102.296 119.26 102.789C118.766 103.283 118.486 103.951 118.48 104.649C118.474 105.348 118.742 106.02 119.227 106.523L122.67 109.966L119.227 113.409C118.973 113.655 118.77 113.949 118.63 114.274C118.491 114.598 118.417 114.948 118.414 115.301C118.411 115.655 118.479 116.006 118.612 116.333C118.746 116.66 118.944 116.958 119.194 117.208C119.444 117.458 119.741 117.655 120.069 117.789C120.396 117.923 120.747 117.991 121.1 117.988C121.454 117.985 121.803 117.911 122.128 117.771C122.453 117.632 122.747 117.429 122.993 117.175L126.436 113.732L129.879 117.175C130.382 117.66 131.054 117.928 131.752 117.922C132.451 117.916 133.119 117.636 133.612 117.142C134.106 116.648 134.386 115.981 134.392 115.282C134.398 114.584 134.13 113.911 133.645 113.409L130.202 109.966L133.645 106.523C133.892 106.275 134.088 105.982 134.222 105.659C134.356 105.336 134.425 104.989 134.425 104.64C134.425 104.29 134.356 103.944 134.222 103.621C134.088 103.298 133.892 103.004 133.645 102.757ZM112.34 102.757C112.093 102.51 111.8 102.313 111.477 102.179C111.154 102.046 110.807 101.977 110.458 101.977C110.108 101.977 109.762 102.046 109.439 102.179C109.116 102.313 108.822 102.51 108.575 102.757L105.132 106.2L101.688 102.757C101.186 102.272 100.513 102.003 99.8151 102.01C99.1169 102.016 98.4489 102.296 97.9552 102.789C97.4614 103.283 97.1814 103.951 97.1753 104.649C97.1692 105.348 97.4377 106.02 97.9227 106.523L101.366 109.966L97.9227 113.409C97.6684 113.655 97.4655 113.949 97.326 114.274C97.1864 114.598 97.1129 114.948 97.1098 115.301C97.1068 115.655 97.1742 116.006 97.3081 116.333C97.442 116.66 97.6397 116.958 97.8897 117.208C98.1398 117.458 98.4371 117.655 98.7644 117.789C99.0917 117.923 99.4423 117.991 99.7959 117.988C100.15 117.985 100.499 117.911 100.824 117.771C101.149 117.632 101.443 117.429 101.688 117.175L105.132 113.732L108.575 117.175C109.077 117.66 109.75 117.928 110.448 117.922C111.146 117.916 111.814 117.636 112.308 117.142C112.802 116.648 113.082 115.981 113.088 115.282C113.094 114.584 112.826 113.911 112.34 113.409L108.897 109.966L112.34 106.523C112.588 106.275 112.784 105.982 112.918 105.659C113.052 105.336 113.121 104.989 113.121 104.64C113.121 104.29 113.052 103.944 112.918 103.621C112.784 103.298 112.588 103.004 112.34 102.757ZM151.506 109.966L154.949 106.523C155.434 106.02 155.703 105.348 155.697 104.649C155.691 103.951 155.41 103.283 154.917 102.789C154.423 102.296 153.755 102.016 153.057 102.01C152.359 102.003 151.686 102.272 151.184 102.757L147.74 106.2L144.297 102.757C143.795 102.272 143.122 102.003 142.424 102.01C141.726 102.016 141.058 102.296 140.564 102.789C140.07 103.283 139.79 103.951 139.784 104.649C139.778 105.348 140.046 106.02 140.531 106.523L143.974 109.966L140.531 113.409C140.277 113.655 140.074 113.949 139.935 114.274C139.795 114.598 139.722 114.948 139.719 115.301C139.715 115.655 139.783 116.006 139.917 116.333C140.051 116.66 140.248 116.958 140.498 117.208C140.748 117.458 141.046 117.655 141.373 117.789C141.7 117.923 142.051 117.991 142.405 117.988C142.758 117.985 143.108 117.911 143.433 117.771C143.757 117.632 144.051 117.429 144.297 117.175L147.74 113.732L151.184 117.175C151.686 117.66 152.359 117.928 153.057 117.922C153.755 117.916 154.423 117.636 154.917 117.142C155.41 116.648 155.691 115.981 155.697 115.282C155.703 114.584 155.434 113.911 154.949 113.409L151.506 109.966Z\" stroke=\"transparent\" stroke-width=\"20\" mask=\"url(#path-2-outside-1_0_1)\"/>\n </g>\n <defs>\n <clipPath id=\"clip0_0_1\">\n <rect width=\"200\" height=\"200\" fill=\"white\"/>\n </clipPath>\n </defs>\n </svg>\n </div>\n <div class=\"errorContainer\"></div>\n </div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"cardHolderInput\">Card holder</label>\n <input class=\"ff-card-form-cardholder-input\" id=\"cardHolderInput\" placeholder=\"Card holder\">\n <div class=\"errorContainer\"></div>\n</div>\n";
|
|
9
9
|
|
|
10
|
-
if(typeof document!=="undefined")document.head.appendChild(document.createElement("style")).textContent="\n\n.ff-card-form-label {\n display: block;\n font-size: 16px;\n margin-bottom: 5px;\n }\n \n .card-form-row {\n display: flex;\n flex-direction: row;\n gap: 10px;\n }\n \n .ff-card-form-cardholder-input {\n padding-left: 10px;\n padding-right: 10px;\n box-sizing: border-box;\n height: 36px;\n width: 100%;\n font-size: 1rem;\n background-color: transparent;\n border: 1px solid rgb(0 0 0 / 10%);\n border-radius: 6px;\n transition: all 0.3s ease;\n box-shadow: none;\n }\n .ff-card-form-cardholder-input.error {\n border-color: #e32f41;\n }\n \n .errorContainer {\n color: #d10000;\n font-size: 16px;\n }\n\n #cvvInput {\n position: relative;\n }\n \n #cvvInput > svg {\n z-index: 1;\n position: absolute;\n top: 5px;\n right: 5px;\n width: 26px;\n height: 26px;\n }";
|
|
10
|
+
if(typeof document!=="undefined")document.head.appendChild(document.createElement("style")).textContent="\n\n.ff-card-form-label {\n display: block;\n font-size: 16px;\n margin-bottom: 5px;\n }\n \n .card-form-row {\n display: flex;\n flex-direction: row;\n gap: 10px;\n }\n \n .ff-card-form-cardholder-input {\n margin: 0 0 3px;\n padding-left: 10px;\n padding-right: 10px;\n box-sizing: border-box;\n height: 36px;\n width: 100%;\n font-size: 1rem;\n background-color: transparent;\n border: 1px solid rgb(0 0 0 / 10%);\n border-radius: 6px;\n transition: all 0.3s ease;\n box-shadow: none;\n outline: none;\n }\n .ff-card-form-cardholder-input.error {\n border-color: #e32f41;\n }\n \n .errorContainer:not(:empty) {\n color: #d10000;\n font-size: 16px;\n line-height: 1;\n margin: 0 0 10px;\n }\n\n #cvvInput {\n position: relative;\n }\n \n #cvvInput > svg {\n z-index: 1;\n position: absolute;\n top: 5px;\n right: 5px;\n width: 26px;\n height: 26px;\n }";
|
|
11
11
|
|
|
12
12
|
class CardSkin {
|
|
13
|
-
constructor(containerEl) {
|
|
13
|
+
constructor(containerEl, checkoutConfig) {
|
|
14
14
|
this.onInputError = (event) => {
|
|
15
15
|
const { name, error } = event;
|
|
16
16
|
const cardInputElements = this.getCardInputElements();
|
|
@@ -18,27 +18,43 @@ class CardSkin {
|
|
|
18
18
|
cardNumber: cardInputElements.cardNumber.parentElement,
|
|
19
19
|
expiryDate: cardInputElements.expiryDate.parentElement,
|
|
20
20
|
cvv: cardInputElements.cvv.parentElement,
|
|
21
|
+
cardholderName: cardInputElements.cardholderName?.parentElement,
|
|
21
22
|
};
|
|
22
23
|
const errorContainer = elementsMap[name]?.querySelector('.errorContainer');
|
|
23
24
|
if (errorContainer) {
|
|
24
25
|
errorContainer.textContent = error || '';
|
|
25
26
|
}
|
|
27
|
+
if (name === 'cardholderName') {
|
|
28
|
+
if (error) {
|
|
29
|
+
cardInputElements.cardholderName?.classList?.add('error');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
cardInputElements.cardholderName?.classList?.remove('error');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
this.onMethodRender = () => {
|
|
37
|
+
this.containerEl.style.display = 'block';
|
|
26
38
|
};
|
|
27
39
|
if (!containerEl) {
|
|
28
40
|
throw new Error('Container element not found');
|
|
29
41
|
}
|
|
30
42
|
this.containerEl = containerEl;
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
cardNumber: document.createElement('div'),
|
|
34
|
-
expiryDate: document.createElement('div'),
|
|
35
|
-
cvv: document.createElement('div'),
|
|
36
|
-
};
|
|
43
|
+
this.checkoutConfig = checkoutConfig;
|
|
44
|
+
this.containerEl.style.display = 'none';
|
|
37
45
|
}
|
|
38
46
|
wireCardInputs() {
|
|
39
47
|
const cardNumber = this.containerEl.querySelector('#cardNumberInput');
|
|
40
48
|
const expiryDate = this.containerEl.querySelector('#expiryInput');
|
|
41
49
|
const cvv = this.containerEl.querySelector('#cvvInput');
|
|
50
|
+
let cardholderName = null;
|
|
51
|
+
if (this.checkoutConfig?.card?.cardholderName) {
|
|
52
|
+
cardholderName =
|
|
53
|
+
this.containerEl.querySelector('#cardHolderInput');
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.containerEl.querySelector('#cardHolderInput').parentElement.style.display = 'none';
|
|
57
|
+
}
|
|
42
58
|
if (!cardNumber || !expiryDate || !cvv) {
|
|
43
59
|
throw new Error('One or more card input elements are missing in the default skin');
|
|
44
60
|
}
|
|
@@ -46,6 +62,7 @@ class CardSkin {
|
|
|
46
62
|
cardNumber,
|
|
47
63
|
expiryDate,
|
|
48
64
|
cvv,
|
|
65
|
+
cardholderName,
|
|
49
66
|
};
|
|
50
67
|
}
|
|
51
68
|
async init() {
|
|
@@ -72,7 +89,7 @@ class CardSkin {
|
|
|
72
89
|
cardElements: this.getCardInputElements(),
|
|
73
90
|
card: {
|
|
74
91
|
cardholderName: {
|
|
75
|
-
required:
|
|
92
|
+
required: !!this.checkoutConfig?.card?.cardholderName,
|
|
76
93
|
},
|
|
77
94
|
},
|
|
78
95
|
};
|
|
@@ -217,7 +217,7 @@ exports.PaymentMethod = void 0;
|
|
|
217
217
|
/**
|
|
218
218
|
* @fileoverview Constants for Funnefox SDK
|
|
219
219
|
*/
|
|
220
|
-
const SDK_VERSION = '0.5.0-beta.
|
|
220
|
+
const SDK_VERSION = '0.5.0-beta.3';
|
|
221
221
|
const DEFAULTS = {
|
|
222
222
|
BASE_URL: 'https://billing.funnelfox.com',
|
|
223
223
|
REGION: 'default',
|
|
@@ -249,6 +249,7 @@ const EVENTS = {
|
|
|
249
249
|
PURCHASE_FAILURE: 'purchase-failure',
|
|
250
250
|
PURCHASE_COMPLETED: 'purchase-completed',
|
|
251
251
|
PURCHASE_CANCELLED: 'purchase-cancelled',
|
|
252
|
+
METHODS_AVAILABLE: 'methods-available',
|
|
252
253
|
};
|
|
253
254
|
const API_ENDPOINTS = {
|
|
254
255
|
CREATE_CLIENT_SESSION: '/v1/checkout/create_client_session',
|
|
@@ -295,6 +296,12 @@ const inputStyle = {
|
|
|
295
296
|
({
|
|
296
297
|
paddingLeft: inputStyle.input.base.paddingHorizontal + 'px',
|
|
297
298
|
paddingRight: inputStyle.input.base.paddingHorizontal + 'px'});
|
|
299
|
+
const DEFAULT_PAYMENT_METHOD_ORDER = [
|
|
300
|
+
exports.PaymentMethod.APPLE_PAY,
|
|
301
|
+
exports.PaymentMethod.GOOGLE_PAY,
|
|
302
|
+
exports.PaymentMethod.PAYPAL,
|
|
303
|
+
exports.PaymentMethod.PAYMENT_CARD,
|
|
304
|
+
];
|
|
298
305
|
|
|
299
306
|
/**
|
|
300
307
|
* @fileoverview Primer SDK integration wrapper
|
|
@@ -337,10 +344,40 @@ class PrimerWrapper {
|
|
|
337
344
|
disableButtons(disabled) {
|
|
338
345
|
if (!this.paymentMethodsInterfaces)
|
|
339
346
|
return;
|
|
340
|
-
for (const
|
|
341
|
-
|
|
347
|
+
for (const paymentMethodInterface of this.paymentMethodsInterfaces) {
|
|
348
|
+
paymentMethodInterface.setDisabled(disabled);
|
|
342
349
|
}
|
|
343
350
|
}
|
|
351
|
+
waitForPayPalReady() {
|
|
352
|
+
return new Promise((resolve, reject) => {
|
|
353
|
+
let counter = 0;
|
|
354
|
+
const checkPayPalEnabler = async () => {
|
|
355
|
+
/**
|
|
356
|
+
* Wait 1000 seconds for PayPal SDK to initialize
|
|
357
|
+
*/
|
|
358
|
+
await new Promise(resolve => {
|
|
359
|
+
setTimeout(() => {
|
|
360
|
+
resolve();
|
|
361
|
+
}, 1000);
|
|
362
|
+
});
|
|
363
|
+
/**
|
|
364
|
+
* @link https://github.com/krakenjs/zoid/issues/334
|
|
365
|
+
*/
|
|
366
|
+
// @ts-expect-error paymentMethod is private property
|
|
367
|
+
const isPayPalReady = !!window?.paypalPrimer?.Buttons?.instances?.[0];
|
|
368
|
+
if (++counter < 20 && !isPayPalReady) {
|
|
369
|
+
setTimeout(checkPayPalEnabler, 0);
|
|
370
|
+
}
|
|
371
|
+
else if (!isPayPalReady) {
|
|
372
|
+
reject(new PrimerError('PayPal paypal_js_sdk_v5_unhandled_exception was detected', exports.PaymentMethod.PAYPAL));
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
resolve();
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
checkPayPalEnabler();
|
|
379
|
+
});
|
|
380
|
+
}
|
|
344
381
|
async renderButton(allowedPaymentMethod, { htmlNode, onMethodRenderError, onMethodRender, }) {
|
|
345
382
|
let button;
|
|
346
383
|
this.ensurePrimerAvailable();
|
|
@@ -354,6 +391,9 @@ class PrimerWrapper {
|
|
|
354
391
|
}
|
|
355
392
|
button = pmManager.createButton();
|
|
356
393
|
await button.render(htmlNode, {});
|
|
394
|
+
if (allowedPaymentMethod === exports.PaymentMethod.PAYPAL) {
|
|
395
|
+
await this.waitForPayPalReady();
|
|
396
|
+
}
|
|
357
397
|
this.destroyCallbacks.push(() => button.clean());
|
|
358
398
|
onMethodRender(allowedPaymentMethod);
|
|
359
399
|
return {
|
|
@@ -375,7 +415,7 @@ class PrimerWrapper {
|
|
|
375
415
|
!options.onInputChange) {
|
|
376
416
|
throw new PrimerError('Card elements, onSubmit, and onInputChange are required for PAYMENT_CARD method');
|
|
377
417
|
}
|
|
378
|
-
return this.renderCardCheckoutWithElements(options.cardElements, {
|
|
418
|
+
return await this.renderCardCheckoutWithElements(options.cardElements, {
|
|
379
419
|
onSubmit: options.onSubmit,
|
|
380
420
|
onInputChange: options.onInputChange,
|
|
381
421
|
onMethodRenderError: options.onMethodRenderError,
|
|
@@ -463,8 +503,8 @@ class PrimerWrapper {
|
|
|
463
503
|
]);
|
|
464
504
|
const onDestroy = () => {
|
|
465
505
|
pmManager.removeHostedInputs();
|
|
466
|
-
elements.cardholderName
|
|
467
|
-
elements.button
|
|
506
|
+
elements.cardholderName?.removeEventListener('change', cardHolderOnChange);
|
|
507
|
+
elements.button?.removeEventListener('click', onSubmitHandler);
|
|
468
508
|
};
|
|
469
509
|
this.destroyCallbacks.push(onDestroy);
|
|
470
510
|
onMethodRender(exports.PaymentMethod.PAYMENT_CARD);
|
|
@@ -512,12 +552,13 @@ class PrimerWrapper {
|
|
|
512
552
|
});
|
|
513
553
|
}
|
|
514
554
|
async renderCheckout(clientToken, checkoutOptions, checkoutRenderOptions) {
|
|
515
|
-
const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, } = checkoutRenderOptions;
|
|
555
|
+
const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, } = checkoutRenderOptions;
|
|
516
556
|
await this.initializeHeadlessCheckout(clientToken, checkoutOptions);
|
|
517
|
-
|
|
557
|
+
onMethodsAvailable?.(this.availableMethods);
|
|
558
|
+
return Promise.all(this.availableMethods.map(method => {
|
|
518
559
|
if (method === exports.PaymentMethod.PAYMENT_CARD) {
|
|
519
560
|
// For card, use the main container
|
|
520
|
-
|
|
561
|
+
return this.initMethod(method, container, {
|
|
521
562
|
cardElements,
|
|
522
563
|
onSubmit,
|
|
523
564
|
onInputChange,
|
|
@@ -533,13 +574,15 @@ class PrimerWrapper {
|
|
|
533
574
|
};
|
|
534
575
|
// For buttons, use the specific button container element
|
|
535
576
|
const buttonElement = buttonElementsMap[method];
|
|
536
|
-
|
|
577
|
+
return this.initMethod(method, buttonElement, {
|
|
537
578
|
onMethodRender,
|
|
538
579
|
onMethodRenderError,
|
|
539
580
|
});
|
|
540
581
|
}
|
|
541
|
-
}
|
|
542
|
-
|
|
582
|
+
})).then((interfaces) => {
|
|
583
|
+
this.paymentMethodsInterfaces = interfaces;
|
|
584
|
+
this.isInitialized = true;
|
|
585
|
+
});
|
|
543
586
|
}
|
|
544
587
|
wrapTokenizeHandler(handler) {
|
|
545
588
|
return async (paymentMethodTokenData, primerHandler) => {
|
|
@@ -834,12 +877,6 @@ class CheckoutInstance extends EventEmitter {
|
|
|
834
877
|
constructor(config) {
|
|
835
878
|
super();
|
|
836
879
|
this.counter = 0;
|
|
837
|
-
this.paymentMethodOrder = [
|
|
838
|
-
exports.PaymentMethod.APPLE_PAY,
|
|
839
|
-
exports.PaymentMethod.GOOGLE_PAY,
|
|
840
|
-
exports.PaymentMethod.PAYPAL,
|
|
841
|
-
exports.PaymentMethod.PAYMENT_CARD,
|
|
842
|
-
];
|
|
843
880
|
this.handleInputChange = (inputName, error) => {
|
|
844
881
|
this.emit(EVENTS.INPUT_ERROR, { name: inputName, error });
|
|
845
882
|
};
|
|
@@ -896,6 +933,9 @@ class CheckoutInstance extends EventEmitter {
|
|
|
896
933
|
this._setState('ready');
|
|
897
934
|
}
|
|
898
935
|
};
|
|
936
|
+
this.handleMethodsAvailable = (methods) => {
|
|
937
|
+
this.emit(EVENTS.METHODS_AVAILABLE, methods);
|
|
938
|
+
};
|
|
899
939
|
this.onLoaderChangeWithRace = (state) => {
|
|
900
940
|
const isLoading = !!(state ? ++this.counter : --this.counter);
|
|
901
941
|
this.emit(EVENTS.LOADER_CHANGE, isLoading);
|
|
@@ -965,14 +1005,31 @@ class CheckoutInstance extends EventEmitter {
|
|
|
965
1005
|
timeout: DEFAULTS.REQUEST_TIMEOUT,
|
|
966
1006
|
retryAttempts: DEFAULTS.RETRY_ATTEMPTS,
|
|
967
1007
|
});
|
|
968
|
-
const
|
|
1008
|
+
const sessionParams = {
|
|
969
1009
|
priceId: this.checkoutConfig.priceId,
|
|
970
1010
|
externalId: this.checkoutConfig.customer.externalId,
|
|
971
1011
|
email: this.checkoutConfig.customer.email,
|
|
972
1012
|
region: this.region || DEFAULTS.REGION,
|
|
973
1013
|
clientMetadata: this.checkoutConfig.clientMetadata,
|
|
974
1014
|
countryCode: this.checkoutConfig.customer.countryCode,
|
|
975
|
-
}
|
|
1015
|
+
};
|
|
1016
|
+
const cacheKey = [
|
|
1017
|
+
this.orgId,
|
|
1018
|
+
this.checkoutConfig.priceId,
|
|
1019
|
+
this.checkoutConfig.customer.externalId,
|
|
1020
|
+
this.checkoutConfig.customer.email,
|
|
1021
|
+
].join('-');
|
|
1022
|
+
let sessionResponse;
|
|
1023
|
+
// Return cached response if payload hasn't changed
|
|
1024
|
+
const cachedResponse = CheckoutInstance.sessionCache.get(cacheKey);
|
|
1025
|
+
if (cachedResponse) {
|
|
1026
|
+
sessionResponse = cachedResponse;
|
|
1027
|
+
}
|
|
1028
|
+
else {
|
|
1029
|
+
sessionResponse = await this.apiClient.createClientSession(sessionParams);
|
|
1030
|
+
// Cache the successful response
|
|
1031
|
+
CheckoutInstance.sessionCache.set(cacheKey, sessionResponse);
|
|
1032
|
+
}
|
|
976
1033
|
const sessionData = this.apiClient.processSessionResponse(sessionResponse);
|
|
977
1034
|
this.orderId = sessionData.orderId;
|
|
978
1035
|
this.clientToken = sessionData.clientToken;
|
|
@@ -1019,9 +1076,8 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1019
1076
|
let checkoutOptions;
|
|
1020
1077
|
if (!this.checkoutConfig.cardSelectors ||
|
|
1021
1078
|
!this.checkoutConfig.paymentButtonSelectors) {
|
|
1022
|
-
|
|
1023
|
-
this.paymentMethodOrder
|
|
1024
|
-
}
|
|
1079
|
+
this.checkoutConfig.paymentMethodOrder =
|
|
1080
|
+
this.checkoutConfig.paymentMethodOrder || DEFAULT_PAYMENT_METHOD_ORDER;
|
|
1025
1081
|
const defaultSkinCheckoutOptions = await this.getDefaultSkinCheckoutOptions();
|
|
1026
1082
|
if (!defaultSkinCheckoutOptions.cardElements ||
|
|
1027
1083
|
!defaultSkinCheckoutOptions.paymentButtonElements) {
|
|
@@ -1033,14 +1089,14 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1033
1089
|
checkoutOptions = this.getCheckoutOptions(defaultSkinCheckoutOptions);
|
|
1034
1090
|
}
|
|
1035
1091
|
else {
|
|
1092
|
+
if (this.checkoutConfig.paymentMethodOrder) {
|
|
1093
|
+
// eslint-disable-next-line no-console
|
|
1094
|
+
console.warn('paymentMethodOrder is using only for default skin and will be ignored if you are using custom checkout');
|
|
1095
|
+
}
|
|
1036
1096
|
cardElements = this.convertCardSelectorsToElements(this.checkoutConfig.cardSelectors, containerElement);
|
|
1037
1097
|
paymentButtonElements = this.convertPaymentButtonSelectorsToElements(this.checkoutConfig.paymentButtonSelectors);
|
|
1038
1098
|
checkoutOptions = this.getCheckoutOptions({});
|
|
1039
1099
|
}
|
|
1040
|
-
if (this.checkoutConfig.paymentMethodOrder) {
|
|
1041
|
-
// eslint-disable-next-line no-console
|
|
1042
|
-
console.warn('paymentMethodOrder is using only for default skin and will be ignored if you are using custom checkout');
|
|
1043
|
-
}
|
|
1044
1100
|
await this.primerWrapper.renderCheckout(this.clientToken, checkoutOptions, {
|
|
1045
1101
|
container: containerElement,
|
|
1046
1102
|
cardElements,
|
|
@@ -1048,6 +1104,8 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1048
1104
|
onSubmit: this.handleSubmit,
|
|
1049
1105
|
onInputChange: this.handleInputChange,
|
|
1050
1106
|
onMethodRender: this.handleMethodRender,
|
|
1107
|
+
onMethodsAvailable: this.handleMethodsAvailable,
|
|
1108
|
+
onMethodRenderError: this.handleMethodRenderError,
|
|
1051
1109
|
});
|
|
1052
1110
|
}
|
|
1053
1111
|
async _processPaymentResult(result, primerHandler) {
|
|
@@ -1128,6 +1186,8 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1128
1186
|
}
|
|
1129
1187
|
try {
|
|
1130
1188
|
this._setState('updating');
|
|
1189
|
+
// Invalidate session cache
|
|
1190
|
+
CheckoutInstance.sessionCache.clear();
|
|
1131
1191
|
await this.apiClient.updateClientSession({
|
|
1132
1192
|
orderId: this.orderId,
|
|
1133
1193
|
clientToken: this.clientToken,
|
|
@@ -1197,7 +1257,7 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1197
1257
|
async getDefaultSkinCheckoutOptions() {
|
|
1198
1258
|
const skinFactory = (await Promise.resolve().then(function () { return require('./chunk-index.cjs.js'); }))
|
|
1199
1259
|
.default;
|
|
1200
|
-
const skin = await skinFactory(this.primerWrapper, this.checkoutConfig
|
|
1260
|
+
const skin = await skinFactory(this.primerWrapper, this.checkoutConfig);
|
|
1201
1261
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
1202
1262
|
this.on(EVENTS.STATUS_CHANGE, skin.onStatusChange);
|
|
1203
1263
|
this.on(EVENTS.ERROR, (error) => skin.onError(error));
|
|
@@ -1208,13 +1268,15 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1208
1268
|
this.on(EVENTS.START_PURCHASE, skin.onStartPurchase);
|
|
1209
1269
|
this.on(EVENTS.PURCHASE_FAILURE, skin.onPurchaseFailure);
|
|
1210
1270
|
this.on(EVENTS.PURCHASE_COMPLETED, skin.onPurchaseCompleted);
|
|
1271
|
+
this.on(EVENTS.METHODS_AVAILABLE, skin.onMethodsAvailable);
|
|
1211
1272
|
return skin.getCheckoutOptions();
|
|
1212
1273
|
}
|
|
1213
1274
|
async getCardDefaultSkinCheckoutOptions(node) {
|
|
1214
1275
|
const CardSkin = (await Promise.resolve().then(function () { return require('./chunk-index.cjs2.js'); })).default;
|
|
1215
|
-
const skin = new CardSkin(node);
|
|
1276
|
+
const skin = new CardSkin(node, this.checkoutConfig);
|
|
1216
1277
|
skin.init();
|
|
1217
1278
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
1279
|
+
this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
|
|
1218
1280
|
return skin.getCheckoutOptions();
|
|
1219
1281
|
}
|
|
1220
1282
|
showInitializingLoader() {
|
|
@@ -1224,6 +1286,7 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1224
1286
|
hideLoader();
|
|
1225
1287
|
}
|
|
1226
1288
|
}
|
|
1289
|
+
CheckoutInstance.sessionCache = new Map();
|
|
1227
1290
|
|
|
1228
1291
|
/**
|
|
1229
1292
|
* @fileoverview Public API with configuration and orchestration logic
|
|
@@ -1279,6 +1342,28 @@ async function createClientSession(params) {
|
|
|
1279
1342
|
});
|
|
1280
1343
|
return apiClient.processSessionResponse(sessionResponse);
|
|
1281
1344
|
}
|
|
1345
|
+
async function silentPurchase(options) {
|
|
1346
|
+
const { priceId, externalId, clientMetadata, orgId, baseUrl } = options;
|
|
1347
|
+
const apiClient = new APIClient({
|
|
1348
|
+
baseUrl: baseUrl,
|
|
1349
|
+
orgId: orgId,
|
|
1350
|
+
timeout: DEFAULTS.REQUEST_TIMEOUT,
|
|
1351
|
+
retryAttempts: DEFAULTS.RETRY_ATTEMPTS,
|
|
1352
|
+
});
|
|
1353
|
+
const response = await apiClient.oneClick({
|
|
1354
|
+
pp_ident: priceId,
|
|
1355
|
+
external_id: externalId,
|
|
1356
|
+
client_metadata: clientMetadata,
|
|
1357
|
+
});
|
|
1358
|
+
if (response.status !== 'success' &&
|
|
1359
|
+
response.error.some(({ code }) => code === 'double_purchase')) {
|
|
1360
|
+
throw new APIError('This product was already purchased');
|
|
1361
|
+
}
|
|
1362
|
+
else if (response.status !== 'success') {
|
|
1363
|
+
return false;
|
|
1364
|
+
}
|
|
1365
|
+
return true;
|
|
1366
|
+
}
|
|
1282
1367
|
async function initMethod(method, element, options) {
|
|
1283
1368
|
const checkoutInstance = new CheckoutInstance({
|
|
1284
1369
|
orgId: options.orgId,
|
|
@@ -1291,6 +1376,11 @@ async function initMethod(method, element, options) {
|
|
|
1291
1376
|
},
|
|
1292
1377
|
container: '',
|
|
1293
1378
|
clientMetadata: options.meta,
|
|
1379
|
+
card: options.card,
|
|
1380
|
+
style: options.style,
|
|
1381
|
+
applePay: options.applePay,
|
|
1382
|
+
paypal: options.paypal,
|
|
1383
|
+
googlePay: options.googlePay,
|
|
1294
1384
|
},
|
|
1295
1385
|
});
|
|
1296
1386
|
checkoutInstance._ensureNotDestroyed();
|
|
@@ -1307,7 +1397,6 @@ async function initMethod(method, element, options) {
|
|
|
1307
1397
|
if (method === exports.PaymentMethod.PAYMENT_CARD) {
|
|
1308
1398
|
const cardDefaultOptions = await checkoutInstance['getCardDefaultSkinCheckoutOptions'](element);
|
|
1309
1399
|
const checkoutOptions = checkoutInstance['getCheckoutOptions']({
|
|
1310
|
-
style: options.styles,
|
|
1311
1400
|
...cardDefaultOptions,
|
|
1312
1401
|
});
|
|
1313
1402
|
await checkoutInstance.primerWrapper.initializeHeadlessCheckout(checkoutInstance.clientToken, checkoutOptions);
|
|
@@ -1319,9 +1408,7 @@ async function initMethod(method, element, options) {
|
|
|
1319
1408
|
onMethodRenderError: checkoutInstance['handleMethodRenderError'],
|
|
1320
1409
|
});
|
|
1321
1410
|
}
|
|
1322
|
-
await checkoutInstance.primerWrapper.initializeHeadlessCheckout(checkoutInstance.clientToken, checkoutInstance['getCheckoutOptions']({
|
|
1323
|
-
style: options.styles,
|
|
1324
|
-
}));
|
|
1411
|
+
await checkoutInstance.primerWrapper.initializeHeadlessCheckout(checkoutInstance.clientToken, checkoutInstance['getCheckoutOptions']({}));
|
|
1325
1412
|
return checkoutInstance.primerWrapper.initMethod(method, element, {
|
|
1326
1413
|
onMethodRender: checkoutInstance['handleMethodRender'],
|
|
1327
1414
|
onMethodRenderError: checkoutInstance['handleMethodRenderError'],
|
|
@@ -1336,6 +1423,7 @@ const Billing = {
|
|
|
1336
1423
|
createCheckout: createCheckout,
|
|
1337
1424
|
createClientSession: createClientSession,
|
|
1338
1425
|
initMethod: initMethod,
|
|
1426
|
+
silentPurchase: silentPurchase,
|
|
1339
1427
|
};
|
|
1340
1428
|
if (typeof window !== 'undefined') {
|
|
1341
1429
|
window.Billing = Billing;
|