@funnelfox/billing 0.5.0-beta.2 → 0.5.0-beta.4

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.
@@ -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,34 +18,58 @@ 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';
38
+ };
39
+ this.onDestroy = () => {
40
+ this.containerEl.remove();
26
41
  };
27
42
  if (!containerEl) {
28
43
  throw new Error('Container element not found');
29
44
  }
30
45
  this.containerEl = containerEl;
31
- // Initialize with placeholders; real nodes will be wired in `init`.
32
- this.cardInputElements = {
33
- cardNumber: document.createElement('div'),
34
- expiryDate: document.createElement('div'),
35
- cvv: document.createElement('div'),
36
- };
46
+ this.checkoutConfig = checkoutConfig;
47
+ this.containerEl.style.display = 'none';
37
48
  }
38
49
  wireCardInputs() {
39
50
  const cardNumber = this.containerEl.querySelector('#cardNumberInput');
40
51
  const expiryDate = this.containerEl.querySelector('#expiryInput');
41
52
  const cvv = this.containerEl.querySelector('#cvvInput');
42
- if (!cardNumber || !expiryDate || !cvv) {
53
+ const hasCardholderInput = !!this.checkoutConfig?.card?.cardholderName;
54
+ let cardholderName = undefined;
55
+ if (hasCardholderInput) {
56
+ cardholderName =
57
+ this.containerEl.querySelector('#cardHolderInput');
58
+ }
59
+ else {
60
+ this.containerEl.querySelector('#cardHolderInput').parentElement.style.display = 'none';
61
+ }
62
+ if (!cardNumber ||
63
+ !expiryDate ||
64
+ !cvv ||
65
+ (hasCardholderInput && !cardholderName)) {
43
66
  throw new Error('One or more card input elements are missing in the default skin');
44
67
  }
45
68
  this.cardInputElements = {
46
69
  cardNumber,
47
70
  expiryDate,
48
71
  cvv,
72
+ cardholderName,
49
73
  };
50
74
  }
51
75
  async init() {
@@ -72,7 +96,7 @@ class CardSkin {
72
96
  cardElements: this.getCardInputElements(),
73
97
  card: {
74
98
  cardholderName: {
75
- required: false,
99
+ required: !!this.checkoutConfig?.card?.cardholderName,
76
100
  },
77
101
  },
78
102
  };
@@ -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.2';
220
+ const SDK_VERSION = '0.5.0-beta.4';
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
@@ -305,6 +312,7 @@ class PrimerWrapper {
305
312
  this.destroyCallbacks = [];
306
313
  this.headless = null;
307
314
  this.availableMethods = [];
315
+ this.paymentMethodsInterfaces = [];
308
316
  }
309
317
  isPrimerAvailable() {
310
318
  return (typeof window !== 'undefined' &&
@@ -337,10 +345,40 @@ class PrimerWrapper {
337
345
  disableButtons(disabled) {
338
346
  if (!this.paymentMethodsInterfaces)
339
347
  return;
340
- for (const method in this.paymentMethodsInterfaces) {
341
- this.paymentMethodsInterfaces[method].setDisabled(disabled);
348
+ for (const paymentMethodInterface of this.paymentMethodsInterfaces) {
349
+ paymentMethodInterface.setDisabled(disabled);
342
350
  }
343
351
  }
352
+ waitForPayPalReady() {
353
+ return new Promise((resolve, reject) => {
354
+ let counter = 0;
355
+ const checkPayPalEnabler = async () => {
356
+ /**
357
+ * Wait 1000 seconds for PayPal SDK to initialize
358
+ */
359
+ await new Promise(resolve => {
360
+ setTimeout(() => {
361
+ resolve();
362
+ }, 1000);
363
+ });
364
+ /**
365
+ * @link https://github.com/krakenjs/zoid/issues/334
366
+ */
367
+ // @ts-expect-error paymentMethod is private property
368
+ const isPayPalReady = !!window?.paypalPrimer?.Buttons?.instances?.[0];
369
+ if (++counter < 20 && !isPayPalReady) {
370
+ setTimeout(checkPayPalEnabler, 0);
371
+ }
372
+ else if (!isPayPalReady) {
373
+ reject(new PrimerError('PayPal paypal_js_sdk_v5_unhandled_exception was detected', exports.PaymentMethod.PAYPAL));
374
+ }
375
+ else {
376
+ resolve();
377
+ }
378
+ };
379
+ checkPayPalEnabler();
380
+ });
381
+ }
344
382
  async renderButton(allowedPaymentMethod, { htmlNode, onMethodRenderError, onMethodRender, }) {
345
383
  let button;
346
384
  this.ensurePrimerAvailable();
@@ -354,6 +392,9 @@ class PrimerWrapper {
354
392
  }
355
393
  button = pmManager.createButton();
356
394
  await button.render(htmlNode, {});
395
+ if (allowedPaymentMethod === exports.PaymentMethod.PAYPAL) {
396
+ await this.waitForPayPalReady();
397
+ }
357
398
  this.destroyCallbacks.push(() => button.clean());
358
399
  onMethodRender(allowedPaymentMethod);
359
400
  return {
@@ -375,20 +416,24 @@ class PrimerWrapper {
375
416
  !options.onInputChange) {
376
417
  throw new PrimerError('Card elements, onSubmit, and onInputChange are required for PAYMENT_CARD method');
377
418
  }
378
- return this.renderCardCheckoutWithElements(options.cardElements, {
419
+ const cardInterface = await this.renderCardCheckoutWithElements(options.cardElements, {
379
420
  onSubmit: options.onSubmit,
380
421
  onInputChange: options.onInputChange,
381
422
  onMethodRenderError: options.onMethodRenderError,
382
423
  onMethodRender: options.onMethodRender,
383
424
  });
425
+ this.paymentMethodsInterfaces.push(cardInterface);
426
+ return cardInterface;
384
427
  }
385
428
  else {
386
429
  try {
387
- return await this.renderButton(method, {
430
+ const buttonInterface = await this.renderButton(method, {
388
431
  htmlNode,
389
432
  onMethodRenderError: options.onMethodRenderError,
390
433
  onMethodRender: options.onMethodRender,
391
434
  });
435
+ this.paymentMethodsInterfaces.push(buttonInterface);
436
+ return buttonInterface;
392
437
  }
393
438
  catch (error) {
394
439
  throw new PrimerError('Failed to initialize Primer checkout', error);
@@ -463,8 +508,8 @@ class PrimerWrapper {
463
508
  ]);
464
509
  const onDestroy = () => {
465
510
  pmManager.removeHostedInputs();
466
- elements.cardholderName.removeEventListener('change', cardHolderOnChange);
467
- elements.button.removeEventListener('click', onSubmitHandler);
511
+ elements.cardholderName?.removeEventListener('change', cardHolderOnChange);
512
+ elements.button?.removeEventListener('click', onSubmitHandler);
468
513
  };
469
514
  this.destroyCallbacks.push(onDestroy);
470
515
  onMethodRender(exports.PaymentMethod.PAYMENT_CARD);
@@ -473,7 +518,12 @@ class PrimerWrapper {
473
518
  cardNumberInput.setDisabled(disabled);
474
519
  expiryInput.setDisabled(disabled);
475
520
  cvvInput.setDisabled(disabled);
476
- elements.button.disabled = disabled;
521
+ if (elements.button) {
522
+ elements.button.disabled = disabled;
523
+ }
524
+ if (elements.cardholderName) {
525
+ elements.cardholderName.disabled = disabled;
526
+ }
477
527
  },
478
528
  submit: () => onSubmitHandler(),
479
529
  destroy: () => {
@@ -512,12 +562,13 @@ class PrimerWrapper {
512
562
  });
513
563
  }
514
564
  async renderCheckout(clientToken, checkoutOptions, checkoutRenderOptions) {
515
- const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, } = checkoutRenderOptions;
565
+ const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, } = checkoutRenderOptions;
516
566
  await this.initializeHeadlessCheckout(clientToken, checkoutOptions);
517
- for (const method of this.availableMethods) {
567
+ onMethodsAvailable?.(this.availableMethods);
568
+ await Promise.all(this.availableMethods.map(method => {
518
569
  if (method === exports.PaymentMethod.PAYMENT_CARD) {
519
570
  // For card, use the main container
520
- await this.initMethod(method, container, {
571
+ return this.initMethod(method, container, {
521
572
  cardElements,
522
573
  onSubmit,
523
574
  onInputChange,
@@ -533,12 +584,12 @@ class PrimerWrapper {
533
584
  };
534
585
  // For buttons, use the specific button container element
535
586
  const buttonElement = buttonElementsMap[method];
536
- await this.initMethod(method, buttonElement, {
587
+ return this.initMethod(method, buttonElement, {
537
588
  onMethodRender,
538
589
  onMethodRenderError,
539
590
  });
540
591
  }
541
- }
592
+ }));
542
593
  this.isInitialized = true;
543
594
  }
544
595
  wrapTokenizeHandler(handler) {
@@ -834,12 +885,6 @@ class CheckoutInstance extends EventEmitter {
834
885
  constructor(config) {
835
886
  super();
836
887
  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
888
  this.handleInputChange = (inputName, error) => {
844
889
  this.emit(EVENTS.INPUT_ERROR, { name: inputName, error });
845
890
  };
@@ -896,8 +941,12 @@ class CheckoutInstance extends EventEmitter {
896
941
  this._setState('ready');
897
942
  }
898
943
  };
944
+ this.handleMethodsAvailable = (methods) => {
945
+ this.emit(EVENTS.METHODS_AVAILABLE, methods);
946
+ };
899
947
  this.onLoaderChangeWithRace = (state) => {
900
948
  const isLoading = !!(state ? ++this.counter : --this.counter);
949
+ this.primerWrapper.disableButtons(isLoading);
901
950
  this.emit(EVENTS.LOADER_CHANGE, isLoading);
902
951
  };
903
952
  this.id = generateId('checkout_');
@@ -965,14 +1014,32 @@ class CheckoutInstance extends EventEmitter {
965
1014
  timeout: DEFAULTS.REQUEST_TIMEOUT,
966
1015
  retryAttempts: DEFAULTS.RETRY_ATTEMPTS,
967
1016
  });
968
- const sessionResponse = await this.apiClient.createClientSession({
1017
+ const sessionParams = {
969
1018
  priceId: this.checkoutConfig.priceId,
970
1019
  externalId: this.checkoutConfig.customer.externalId,
971
1020
  email: this.checkoutConfig.customer.email,
972
1021
  region: this.region || DEFAULTS.REGION,
973
1022
  clientMetadata: this.checkoutConfig.clientMetadata,
974
1023
  countryCode: this.checkoutConfig.customer.countryCode,
975
- });
1024
+ };
1025
+ const cacheKey = [
1026
+ this.orgId,
1027
+ this.checkoutConfig.priceId,
1028
+ this.checkoutConfig.customer.externalId,
1029
+ this.checkoutConfig.customer.email,
1030
+ ].join('-');
1031
+ let sessionResponse;
1032
+ // Return cached response if payload hasn't changed
1033
+ const cachedResponse = await CheckoutInstance.sessionCache.get(cacheKey);
1034
+ if (cachedResponse) {
1035
+ sessionResponse = cachedResponse;
1036
+ }
1037
+ else {
1038
+ const sessionRequest = this.apiClient.createClientSession(sessionParams);
1039
+ // Cache the successful response
1040
+ CheckoutInstance.sessionCache.set(cacheKey, sessionRequest);
1041
+ sessionResponse = await sessionRequest;
1042
+ }
976
1043
  const sessionData = this.apiClient.processSessionResponse(sessionResponse);
977
1044
  this.orderId = sessionData.orderId;
978
1045
  this.clientToken = sessionData.clientToken;
@@ -1019,9 +1086,8 @@ class CheckoutInstance extends EventEmitter {
1019
1086
  let checkoutOptions;
1020
1087
  if (!this.checkoutConfig.cardSelectors ||
1021
1088
  !this.checkoutConfig.paymentButtonSelectors) {
1022
- if (this.checkoutConfig.paymentMethodOrder) {
1023
- this.paymentMethodOrder = this.checkoutConfig.paymentMethodOrder;
1024
- }
1089
+ this.checkoutConfig.paymentMethodOrder =
1090
+ this.checkoutConfig.paymentMethodOrder || DEFAULT_PAYMENT_METHOD_ORDER;
1025
1091
  const defaultSkinCheckoutOptions = await this.getDefaultSkinCheckoutOptions();
1026
1092
  if (!defaultSkinCheckoutOptions.cardElements ||
1027
1093
  !defaultSkinCheckoutOptions.paymentButtonElements) {
@@ -1033,14 +1099,14 @@ class CheckoutInstance extends EventEmitter {
1033
1099
  checkoutOptions = this.getCheckoutOptions(defaultSkinCheckoutOptions);
1034
1100
  }
1035
1101
  else {
1102
+ if (this.checkoutConfig.paymentMethodOrder) {
1103
+ // eslint-disable-next-line no-console
1104
+ console.warn('paymentMethodOrder is using only for default skin and will be ignored if you are using custom checkout');
1105
+ }
1036
1106
  cardElements = this.convertCardSelectorsToElements(this.checkoutConfig.cardSelectors, containerElement);
1037
1107
  paymentButtonElements = this.convertPaymentButtonSelectorsToElements(this.checkoutConfig.paymentButtonSelectors);
1038
1108
  checkoutOptions = this.getCheckoutOptions({});
1039
1109
  }
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
1110
  await this.primerWrapper.renderCheckout(this.clientToken, checkoutOptions, {
1045
1111
  container: containerElement,
1046
1112
  cardElements,
@@ -1048,6 +1114,8 @@ class CheckoutInstance extends EventEmitter {
1048
1114
  onSubmit: this.handleSubmit,
1049
1115
  onInputChange: this.handleInputChange,
1050
1116
  onMethodRender: this.handleMethodRender,
1117
+ onMethodsAvailable: this.handleMethodsAvailable,
1118
+ onMethodRenderError: this.handleMethodRenderError,
1051
1119
  });
1052
1120
  }
1053
1121
  async _processPaymentResult(result, primerHandler) {
@@ -1128,6 +1196,8 @@ class CheckoutInstance extends EventEmitter {
1128
1196
  }
1129
1197
  try {
1130
1198
  this._setState('updating');
1199
+ // Invalidate session cache
1200
+ CheckoutInstance.sessionCache.clear();
1131
1201
  await this.apiClient.updateClientSession({
1132
1202
  orderId: this.orderId,
1133
1203
  clientToken: this.clientToken,
@@ -1197,7 +1267,7 @@ class CheckoutInstance extends EventEmitter {
1197
1267
  async getDefaultSkinCheckoutOptions() {
1198
1268
  const skinFactory = (await Promise.resolve().then(function () { return require('./chunk-index.cjs.js'); }))
1199
1269
  .default;
1200
- const skin = await skinFactory(this.primerWrapper, this.checkoutConfig.container, this.paymentMethodOrder);
1270
+ const skin = await skinFactory(this.checkoutConfig);
1201
1271
  this.on(EVENTS.INPUT_ERROR, skin.onInputError);
1202
1272
  this.on(EVENTS.STATUS_CHANGE, skin.onStatusChange);
1203
1273
  this.on(EVENTS.ERROR, (error) => skin.onError(error));
@@ -1208,13 +1278,16 @@ class CheckoutInstance extends EventEmitter {
1208
1278
  this.on(EVENTS.START_PURCHASE, skin.onStartPurchase);
1209
1279
  this.on(EVENTS.PURCHASE_FAILURE, skin.onPurchaseFailure);
1210
1280
  this.on(EVENTS.PURCHASE_COMPLETED, skin.onPurchaseCompleted);
1281
+ this.on(EVENTS.METHODS_AVAILABLE, skin.onMethodsAvailable);
1211
1282
  return skin.getCheckoutOptions();
1212
1283
  }
1213
1284
  async getCardDefaultSkinCheckoutOptions(node) {
1214
1285
  const CardSkin = (await Promise.resolve().then(function () { return require('./chunk-index.cjs2.js'); })).default;
1215
- const skin = new CardSkin(node);
1286
+ const skin = new CardSkin(node, this.checkoutConfig);
1216
1287
  skin.init();
1217
1288
  this.on(EVENTS.INPUT_ERROR, skin.onInputError);
1289
+ this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
1290
+ this.on(EVENTS.SUCCESS, skin.onDestroy);
1218
1291
  return skin.getCheckoutOptions();
1219
1292
  }
1220
1293
  showInitializingLoader() {
@@ -1224,6 +1297,7 @@ class CheckoutInstance extends EventEmitter {
1224
1297
  hideLoader();
1225
1298
  }
1226
1299
  }
1300
+ CheckoutInstance.sessionCache = new Map();
1227
1301
 
1228
1302
  /**
1229
1303
  * @fileoverview Public API with configuration and orchestration logic
@@ -1279,6 +1353,28 @@ async function createClientSession(params) {
1279
1353
  });
1280
1354
  return apiClient.processSessionResponse(sessionResponse);
1281
1355
  }
1356
+ async function silentPurchase(options) {
1357
+ const { priceId, externalId, clientMetadata, orgId, baseUrl } = options;
1358
+ const apiClient = new APIClient({
1359
+ baseUrl: baseUrl,
1360
+ orgId: orgId,
1361
+ timeout: DEFAULTS.REQUEST_TIMEOUT,
1362
+ retryAttempts: DEFAULTS.RETRY_ATTEMPTS,
1363
+ });
1364
+ const response = await apiClient.oneClick({
1365
+ pp_ident: priceId,
1366
+ external_id: externalId,
1367
+ client_metadata: clientMetadata,
1368
+ });
1369
+ if (response.status !== 'success' &&
1370
+ response.error.some(({ code }) => code === 'double_purchase')) {
1371
+ throw new APIError('This product was already purchased');
1372
+ }
1373
+ else if (response.status !== 'success') {
1374
+ return false;
1375
+ }
1376
+ return true;
1377
+ }
1282
1378
  async function initMethod(method, element, options) {
1283
1379
  const checkoutInstance = new CheckoutInstance({
1284
1380
  orgId: options.orgId,
@@ -1291,6 +1387,11 @@ async function initMethod(method, element, options) {
1291
1387
  },
1292
1388
  container: '',
1293
1389
  clientMetadata: options.meta,
1390
+ card: options.card,
1391
+ style: options.style,
1392
+ applePay: options.applePay,
1393
+ paypal: options.paypal,
1394
+ googlePay: options.googlePay,
1294
1395
  },
1295
1396
  });
1296
1397
  checkoutInstance._ensureNotDestroyed();
@@ -1307,7 +1408,6 @@ async function initMethod(method, element, options) {
1307
1408
  if (method === exports.PaymentMethod.PAYMENT_CARD) {
1308
1409
  const cardDefaultOptions = await checkoutInstance['getCardDefaultSkinCheckoutOptions'](element);
1309
1410
  const checkoutOptions = checkoutInstance['getCheckoutOptions']({
1310
- style: options.styles,
1311
1411
  ...cardDefaultOptions,
1312
1412
  });
1313
1413
  await checkoutInstance.primerWrapper.initializeHeadlessCheckout(checkoutInstance.clientToken, checkoutOptions);
@@ -1319,9 +1419,7 @@ async function initMethod(method, element, options) {
1319
1419
  onMethodRenderError: checkoutInstance['handleMethodRenderError'],
1320
1420
  });
1321
1421
  }
1322
- await checkoutInstance.primerWrapper.initializeHeadlessCheckout(checkoutInstance.clientToken, checkoutInstance['getCheckoutOptions']({
1323
- style: options.styles,
1324
- }));
1422
+ await checkoutInstance.primerWrapper.initializeHeadlessCheckout(checkoutInstance.clientToken, checkoutInstance['getCheckoutOptions']({}));
1325
1423
  return checkoutInstance.primerWrapper.initMethod(method, element, {
1326
1424
  onMethodRender: checkoutInstance['handleMethodRender'],
1327
1425
  onMethodRenderError: checkoutInstance['handleMethodRenderError'],
@@ -1336,6 +1434,7 @@ const Billing = {
1336
1434
  createCheckout: createCheckout,
1337
1435
  createClientSession: createClientSession,
1338
1436
  initMethod: initMethod,
1437
+ silentPurchase: silentPurchase,
1339
1438
  };
1340
1439
  if (typeof window !== 'undefined') {
1341
1440
  window.Billing = Billing;