@funnelfox/billing 0.6.4 → 0.6.5-beta.0

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.
@@ -420,7 +420,7 @@ var PaymentMethod;
420
420
  /**
421
421
  * @fileoverview Constants for Funnefox SDK
422
422
  */
423
- const SDK_VERSION = '0.6.4';
423
+ const SDK_VERSION = '0.6.5-beta.0';
424
424
  const DEFAULTS = {
425
425
  BASE_URL: 'https://billing.funnelfox.com',
426
426
  REGION: 'default',
@@ -689,7 +689,7 @@ class PrimerWrapper {
689
689
  throw new PrimerError('Failed to initialize Primer checkout', error);
690
690
  }
691
691
  }
692
- async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, onMethodRenderError, onMethodRender, }) {
692
+ async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, isCardholderNameRequired, onMethodRenderError, onMethodRender, }) {
693
693
  try {
694
694
  if (!this.currentHeadless) {
695
695
  throw new PrimerError('Headless checkout not found');
@@ -703,15 +703,18 @@ class PrimerWrapper {
703
703
  const validateForm = async () => {
704
704
  if (!pmManager)
705
705
  return false;
706
- const { valid, validationErrors } = await pmManager.validate();
707
- const cardHolderError = validationErrors.find(v => v.name === 'cardholderName');
708
- dispatchError('cardholderName', cardHolderError?.message || null);
706
+ const { valid } = await pmManager.validate();
707
+ const cardholderName = elements.cardholderName?.value?.trim();
708
+ const cardHolderError = isCardholderNameRequired?.() && !cardholderName
709
+ ? 'Please enter the cardholder name'
710
+ : null;
711
+ dispatchError('cardholderName', cardHolderError);
709
712
  const emailAddress = elements.emailAddress?.value?.trim();
710
713
  const emailError = emailAddress && !isValidEmail(emailAddress)
711
714
  ? 'Please enter a valid email address'
712
715
  : null;
713
716
  dispatchError('emailAddress', emailError);
714
- return valid && !emailError;
717
+ return valid && !emailError && !cardHolderError;
715
718
  };
716
719
  const dispatchError = (inputName, error) => {
717
720
  onInputChange(inputName, error);
@@ -734,8 +737,18 @@ class PrimerWrapper {
734
737
  ? 'Please enter a valid email address'
735
738
  : null);
736
739
  };
740
+ const countrySelectorOnChange = (e) => {
741
+ const countryCode = e.target.value.trim();
742
+ onCardInputValueChange?.('countryCode', countryCode);
743
+ };
744
+ const postalCodeOnChange = (e) => {
745
+ const postalCode = e.target.value.trim();
746
+ onCardInputValueChange?.('postalCode', postalCode);
747
+ };
737
748
  elements.cardholderName?.addEventListener('input', cardHolderOnChange);
738
749
  elements.emailAddress?.addEventListener('input', emailAddressOnChange);
750
+ elements.countrySelector?.addEventListener('change', countrySelectorOnChange);
751
+ elements.postalCode?.addEventListener('input', postalCodeOnChange);
739
752
  cardNumberInput.addEventListener('change', onHostedInputChange('cardNumber'));
740
753
  expiryInput.addEventListener('change', onHostedInputChange('expiryDate'));
741
754
  cvvInput.addEventListener('change', onHostedInputChange('cvv'));
@@ -777,6 +790,8 @@ class PrimerWrapper {
777
790
  pmManager.removeHostedInputs();
778
791
  elements.cardholderName?.removeEventListener('input', cardHolderOnChange);
779
792
  elements.emailAddress?.removeEventListener('input', emailAddressOnChange);
793
+ elements.countrySelector?.removeEventListener('change', countrySelectorOnChange);
794
+ elements.postalCode?.removeEventListener('input', postalCodeOnChange);
780
795
  elements.button?.removeEventListener('click', onSubmitHandler);
781
796
  };
782
797
  this.destroyCallbacks.push(onDestroy);
@@ -795,6 +810,12 @@ class PrimerWrapper {
795
810
  if (elements.emailAddress) {
796
811
  elements.emailAddress.disabled = disabled;
797
812
  }
813
+ if (elements.countrySelector) {
814
+ elements.countrySelector.disabled = disabled;
815
+ }
816
+ if (elements.postalCode) {
817
+ elements.postalCode.disabled = disabled;
818
+ }
798
819
  },
799
820
  submit: () => onSubmitHandler(),
800
821
  destroy: () => {
@@ -817,7 +838,7 @@ class PrimerWrapper {
817
838
  });
818
839
  }
819
840
  async renderCheckout(clientToken, checkoutOptions, checkoutRenderOptions) {
820
- const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, } = checkoutRenderOptions;
841
+ const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, isCardholderNameRequired, } = checkoutRenderOptions;
821
842
  await this.initializeHeadlessCheckout(clientToken, checkoutOptions);
822
843
  onMethodsAvailable?.(this.availableMethods);
823
844
  await Promise.all(this.availableMethods.map(method => {
@@ -830,6 +851,7 @@ class PrimerWrapper {
830
851
  onMethodRender,
831
852
  onMethodRenderError,
832
853
  onCardInputValueChange,
854
+ isCardholderNameRequired,
833
855
  });
834
856
  }
835
857
  else {
@@ -1044,6 +1066,12 @@ class APIClient {
1044
1066
  if (params.email !== undefined) {
1045
1067
  payload.email_address = params.email;
1046
1068
  }
1069
+ if (params.countryCode !== undefined) {
1070
+ payload.country_code = params.countryCode;
1071
+ }
1072
+ if (params.postalCode !== undefined) {
1073
+ payload.postal_code = params.postalCode;
1074
+ }
1047
1075
  return (await this.request(API_ENDPOINTS.CREATE_PAYMENT, {
1048
1076
  method: 'POST',
1049
1077
  body: JSON.stringify(payload),
@@ -1356,12 +1384,24 @@ class CheckoutInstance extends EventEmitter {
1356
1384
  super();
1357
1385
  this.counter = 0;
1358
1386
  this.radarSessionId = null;
1387
+ this.cardSessionFieldConfig = {};
1359
1388
  this.handleInputChange = (inputName, error) => {
1360
1389
  this.emit(EVENTS.INPUT_ERROR, { name: inputName, error });
1361
1390
  };
1362
1391
  this.handleCardInputValueChange = (inputName, value) => {
1363
1392
  if (inputName === 'emailAddress') {
1364
1393
  this.cardEmailAddress = value?.trim() || undefined;
1394
+ return;
1395
+ }
1396
+ if (inputName === 'countryCode') {
1397
+ this.cardCountryCode = this.normalizeCountryCode(value);
1398
+ if (!this.isPostalCodeVisible()) {
1399
+ this.cardPostalCode = undefined;
1400
+ }
1401
+ return;
1402
+ }
1403
+ if (inputName === 'postalCode') {
1404
+ this.cardPostalCode = value?.trim() || undefined;
1365
1405
  }
1366
1406
  };
1367
1407
  this.handleMethodRender = (method) => {
@@ -1387,6 +1427,8 @@ class CheckoutInstance extends EventEmitter {
1387
1427
  orderId: this.orderId,
1388
1428
  paymentMethodToken: paymentMethodTokenData.token,
1389
1429
  email: this.getPaymentEmailAddress(),
1430
+ countryCode: this.getPaymentCountryCode(),
1431
+ postalCode: this.getPaymentPostalCode(),
1390
1432
  clientMetadata: {
1391
1433
  radarSessionId,
1392
1434
  },
@@ -1459,6 +1501,8 @@ class CheckoutInstance extends EventEmitter {
1459
1501
  this.primerWrapper = new PrimerWrapper();
1460
1502
  this.isDestroyed = false;
1461
1503
  this.cardEmailAddress = this.checkoutConfig.customer.email;
1504
+ this.shouldApplySessionCardholderNameConfig =
1505
+ this.checkoutConfig.card?.cardholderName?.required === undefined;
1462
1506
  this._setupCallbackBridges();
1463
1507
  }
1464
1508
  _setupCallbackBridges() {
@@ -1551,7 +1595,9 @@ class CheckoutInstance extends EventEmitter {
1551
1595
  this.clientToken = sessionData.clientToken;
1552
1596
  }
1553
1597
  applySessionCardFieldConfig(response) {
1554
- const cardConfig = this.checkoutConfig.card || {};
1598
+ const cardConfig = {
1599
+ ...(this.checkoutConfig.card || {}),
1600
+ };
1555
1601
  if (cardConfig.emailAddress?.visible === undefined &&
1556
1602
  response.data?.show_email_field !== undefined) {
1557
1603
  cardConfig.emailAddress = {
@@ -1559,20 +1605,49 @@ class CheckoutInstance extends EventEmitter {
1559
1605
  visible: response.data.show_email_field,
1560
1606
  };
1561
1607
  }
1562
- if (cardConfig.cardholderName?.required === undefined &&
1608
+ if (this.shouldApplySessionCardholderNameConfig &&
1563
1609
  response.data?.show_cardholder_name_field !== undefined) {
1564
1610
  cardConfig.cardholderName = {
1565
1611
  ...cardConfig.cardholderName,
1566
1612
  required: response.data.show_cardholder_name_field,
1567
1613
  };
1568
1614
  }
1615
+ const countryFieldOverrides = this.normalizeCountryFieldOverrides(response.data?.country_field_overrides);
1616
+ const detectedCountryCode = this.normalizeCountryCode(response.data?.detected_country_code) ||
1617
+ this.cardCountryCode;
1618
+ this.cardSessionFieldConfig = {
1619
+ ...this.cardSessionFieldConfig,
1620
+ showCountrySelector: response.data?.show_country_selector_field ??
1621
+ this.cardSessionFieldConfig.showCountrySelector,
1622
+ showPostalCode: response.data?.show_postal_code_field ??
1623
+ this.cardSessionFieldConfig.showPostalCode,
1624
+ detectedCountryCode: detectedCountryCode || this.cardSessionFieldConfig.detectedCountryCode,
1625
+ validCountries: response.data?.valid_countries ||
1626
+ this.cardSessionFieldConfig.validCountries,
1627
+ countryFieldOverrides: countryFieldOverrides ||
1628
+ this.cardSessionFieldConfig.countryFieldOverrides,
1629
+ applyCardholderNameOverrides: this.shouldApplySessionCardholderNameConfig,
1630
+ };
1569
1631
  if (Object.keys(cardConfig).length > 0) {
1570
1632
  this.checkoutConfig.card = cardConfig;
1571
1633
  }
1634
+ this.cardCountryCode =
1635
+ this.cardSessionFieldConfig.detectedCountryCode || this.cardCountryCode;
1636
+ if (!this.isPostalCodeVisible()) {
1637
+ this.cardPostalCode = undefined;
1638
+ }
1572
1639
  }
1573
1640
  getPrimerCardConfig() {
1574
- const cardConfig = { ...(this.checkoutConfig.card || {}) };
1641
+ const cardConfig = {
1642
+ ...(this.checkoutConfig.card || {}),
1643
+ };
1575
1644
  delete cardConfig.emailAddress;
1645
+ if (cardConfig.cardholderName) {
1646
+ cardConfig.cardholderName = {
1647
+ ...cardConfig.cardholderName,
1648
+ required: false,
1649
+ };
1650
+ }
1576
1651
  return Object.keys(cardConfig).length
1577
1652
  ? cardConfig
1578
1653
  : undefined;
@@ -1692,6 +1767,7 @@ class CheckoutInstance extends EventEmitter {
1692
1767
  onSubmit: this.handleSubmit,
1693
1768
  onInputChange: this.handleInputChange,
1694
1769
  onCardInputValueChange: this.handleCardInputValueChange,
1770
+ isCardholderNameRequired: () => this.isCardholderNameRequired(),
1695
1771
  onMethodRender: this.handleMethodRender,
1696
1772
  onMethodsAvailable: this.handleMethodsAvailable,
1697
1773
  onMethodRenderError: this.handleMethodRenderError,
@@ -1850,12 +1926,68 @@ class CheckoutInstance extends EventEmitter {
1850
1926
  isProcessing() {
1851
1927
  return ['processing', 'action_required'].includes(this.state);
1852
1928
  }
1929
+ normalizeCountryCode(countryCode) {
1930
+ const normalized = countryCode?.trim().toUpperCase();
1931
+ return normalized || undefined;
1932
+ }
1933
+ normalizeCountryFieldOverrides(overrides) {
1934
+ if (!overrides) {
1935
+ return undefined;
1936
+ }
1937
+ return Object.entries(overrides).reduce((result, [countryCode, override]) => {
1938
+ const normalizedCountryCode = this.normalizeCountryCode(countryCode);
1939
+ if (normalizedCountryCode && override) {
1940
+ result[normalizedCountryCode] = override;
1941
+ }
1942
+ return result;
1943
+ }, {});
1944
+ }
1945
+ getSelectedCountryCode() {
1946
+ return (this.normalizeCountryCode(this.cardCountryCode) ||
1947
+ this.normalizeCountryCode(this.cardSessionFieldConfig.detectedCountryCode));
1948
+ }
1949
+ getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
1950
+ if (!countryCode) {
1951
+ return undefined;
1952
+ }
1953
+ return this.cardSessionFieldConfig.countryFieldOverrides?.[countryCode];
1954
+ }
1955
+ isCardholderNameRequired(countryCode = this.getSelectedCountryCode()) {
1956
+ const defaultValue = !!this.checkoutConfig.card?.cardholderName?.required;
1957
+ const shouldApplyOverrides = this.cardSessionFieldConfig.applyCardholderNameOverrides &&
1958
+ this.shouldApplySessionCardholderNameConfig;
1959
+ if (!shouldApplyOverrides) {
1960
+ return defaultValue;
1961
+ }
1962
+ const overrideValue = this.getCountryFieldOverride(countryCode)?.show_cardholder_name;
1963
+ if (overrideValue === null || overrideValue === undefined) {
1964
+ return defaultValue;
1965
+ }
1966
+ return overrideValue;
1967
+ }
1968
+ isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
1969
+ const defaultValue = !!this.cardSessionFieldConfig.showPostalCode;
1970
+ const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
1971
+ if (overrideValue === null || overrideValue === undefined) {
1972
+ return defaultValue;
1973
+ }
1974
+ return overrideValue;
1975
+ }
1976
+ getPaymentCountryCode() {
1977
+ return this.getSelectedCountryCode();
1978
+ }
1979
+ getPaymentPostalCode() {
1980
+ if (!this.isPostalCodeVisible()) {
1981
+ return undefined;
1982
+ }
1983
+ return this.cardPostalCode?.trim() || undefined;
1984
+ }
1853
1985
  // Creates containers to render hosted inputs with labels and error messages,
1854
1986
  // a card holder input with label and error, and a submit button.
1855
1987
  async getDefaultSkinCheckoutOptions() {
1856
1988
  const skinFactory = (await import('./chunk-index.es2.js'))
1857
1989
  .default;
1858
- const skin = await skinFactory(this.checkoutConfig);
1990
+ const skin = await skinFactory(this.checkoutConfig, this.cardSessionFieldConfig);
1859
1991
  this.on(EVENTS.INPUT_ERROR, skin.onInputError);
1860
1992
  this.on(EVENTS.STATUS_CHANGE, skin.onStatusChange);
1861
1993
  this.on(EVENTS.ERROR, (error) => skin.onError(error));
@@ -1871,7 +2003,7 @@ class CheckoutInstance extends EventEmitter {
1871
2003
  }
1872
2004
  async getCardDefaultSkinCheckoutOptions(node) {
1873
2005
  const CardSkin = (await import('./chunk-index.es3.js')).default;
1874
- const skin = new CardSkin(node, this.checkoutConfig);
2006
+ const skin = new CardSkin(node, this.checkoutConfig, this.cardSessionFieldConfig);
1875
2007
  skin.init();
1876
2008
  this.on(EVENTS.INPUT_ERROR, skin.onInputError);
1877
2009
  this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
@@ -1932,6 +2064,7 @@ class CheckoutInstance extends EventEmitter {
1932
2064
  onSubmit: this.handleSubmit,
1933
2065
  onInputChange: this.handleInputChange,
1934
2066
  onCardInputValueChange: this.handleCardInputValueChange,
2067
+ isCardholderNameRequired: () => this.isCardholderNameRequired(),
1935
2068
  onMethodRender: this.handleMethodRender,
1936
2069
  onMethodRenderError: this.handleMethodRenderError,
1937
2070
  };
@@ -27,7 +27,7 @@ const paymentMethodTemplates = {
27
27
  [PaymentMethod.APPLE_PAY]: applePayTemplate,
28
28
  };
29
29
  class DefaultSkin {
30
- constructor(checkoutConfig) {
30
+ constructor(checkoutConfig, cardSessionFieldConfig) {
31
31
  this.onLoaderChange = (isLoading) => {
32
32
  document
33
33
  .querySelectorAll(`${this.containerSelector} .loader-container`)
@@ -116,6 +116,7 @@ class DefaultSkin {
116
116
  }
117
117
  this.containerEl = containerEl;
118
118
  this.checkoutConfig = checkoutConfig;
119
+ this.cardSessionFieldConfig = cardSessionFieldConfig;
119
120
  }
120
121
  initAccordion() {
121
122
  const paymentMethodCards = this.containerEl.querySelectorAll('.ff-payment-method-card');
@@ -164,7 +165,7 @@ class DefaultSkin {
164
165
  this.paymentMethodOrder.forEach(paymentMethod => {
165
166
  paymentMethodContainers.insertAdjacentHTML('beforeend', paymentMethodTemplates[paymentMethod]);
166
167
  });
167
- this.cardInstance = new CardSkin(document.querySelector('#cardForm'), this.checkoutConfig);
168
+ this.cardInstance = new CardSkin(document.querySelector('#cardForm'), this.checkoutConfig, this.cardSessionFieldConfig);
168
169
  this.cardInstance.init();
169
170
  this.wireCardInputs();
170
171
  }
@@ -195,8 +196,8 @@ class DefaultSkin {
195
196
  };
196
197
  }
197
198
  }
198
- const createDefaultSkin = async (checkoutConfig) => {
199
- const skin = new DefaultSkin(checkoutConfig);
199
+ const createDefaultSkin = async (checkoutConfig, cardSessionFieldConfig) => {
200
+ const skin = new DefaultSkin(checkoutConfig, cardSessionFieldConfig);
200
201
  await skin['init']();
201
202
  return skin;
202
203
  };
@@ -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<div>\n <label class=\"ff-card-form-label\" for=\"emailAddressInput\">Email</label>\n <input class=\"ff-card-form-text-input\" id=\"emailAddressInput\" placeholder=\"Email\" type=\"email\">\n <div class=\"errorContainer\"></div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"cardHolderInput\">Card holder</label>\n <input class=\"ff-card-form-text-input\" id=\"cardHolderInput\" placeholder=\"Card holder\">\n <div class=\"errorContainer\"></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=\"emailAddressInput\">Email</label>\n <input class=\"ff-card-form-text-input\" id=\"emailAddressInput\" placeholder=\"Email\" type=\"email\">\n <div class=\"errorContainer\"></div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"cardHolderInput\">Card holder</label>\n <input class=\"ff-card-form-text-input\" id=\"cardHolderInput\" placeholder=\"Card holder\">\n <div class=\"errorContainer\"></div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"countrySelectorInput\">Country</label>\n <div class=\"ff-select-wrap\">\n <select class=\"ff-card-form-text-input ff-card-form-select\" id=\"countrySelectorInput\"></select>\n <div class=\"ff-select-arrow\" aria-hidden=\"true\"></div>\n </div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"postalCodeInput\">Postal code</label>\n <input class=\"ff-card-form-text-input\" id=\"postalCodeInput\" placeholder=\"Postal code\">\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-text-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-text-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 }";
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-text-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-text-input.error {\n border-color: #e32f41;\n }\n\n.ff-select-wrap {\n position: relative;\n}\n\n.ff-card-form-select {\n padding-right: 34px;\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n background-image: none;\n}\n\n.ff-card-form-select::-ms-expand {\n display: none;\n}\n\n.ff-select-arrow {\n position: absolute;\n top: 50%;\n right: 12px;\n width: 8px;\n height: 8px;\n border-right: 1.5px solid #6b7280;\n border-bottom: 1.5px solid #6b7280;\n transform: translateY(-65%) rotate(45deg);\n pointer-events: none;\n}\n\n.ff-select-wrap:focus-within .ff-select-arrow {\n border-right-color: #111827;\n border-bottom-color: #111827;\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, checkoutConfig) {
13
+ constructor(containerEl, checkoutConfig, cardSessionFieldConfig) {
14
14
  this.onInputError = (event) => {
15
15
  const { name, error } = event;
16
16
  const cardInputElements = this.getCardInputElements();
@@ -50,21 +50,85 @@ class CardSkin {
50
50
  }
51
51
  this.containerEl = containerEl;
52
52
  this.checkoutConfig = checkoutConfig;
53
+ this.cardSessionFieldConfig = cardSessionFieldConfig;
53
54
  this.containerEl.style.display = 'none';
54
55
  }
56
+ normalizeCountryCode(countryCode) {
57
+ const normalized = countryCode?.trim().toUpperCase();
58
+ return normalized || undefined;
59
+ }
60
+ getSelectedCountryCode() {
61
+ const selector = this.containerEl.querySelector('#countrySelectorInput');
62
+ return (this.normalizeCountryCode(selector?.value) ||
63
+ this.normalizeCountryCode(this.cardSessionFieldConfig?.detectedCountryCode));
64
+ }
65
+ getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
66
+ if (!countryCode) {
67
+ return undefined;
68
+ }
69
+ return this.cardSessionFieldConfig?.countryFieldOverrides?.[countryCode];
70
+ }
71
+ isCountrySelectorVisible() {
72
+ return !!(this.cardSessionFieldConfig?.showCountrySelector &&
73
+ this.cardSessionFieldConfig?.validCountries?.length);
74
+ }
75
+ isCardholderNameVisible(countryCode = this.getSelectedCountryCode()) {
76
+ const defaultVisible = !!this.checkoutConfig.card?.cardholderName?.required;
77
+ const shouldApplyOverrides = !!this.cardSessionFieldConfig?.applyCardholderNameOverrides;
78
+ if (!shouldApplyOverrides) {
79
+ return defaultVisible;
80
+ }
81
+ const overrideValue = this.getCountryFieldOverride(countryCode)?.show_cardholder_name;
82
+ if (overrideValue === null || overrideValue === undefined) {
83
+ return defaultVisible;
84
+ }
85
+ return overrideValue;
86
+ }
87
+ isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
88
+ const defaultVisible = !!this.cardSessionFieldConfig?.showPostalCode;
89
+ const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
90
+ if (overrideValue === null || overrideValue === undefined) {
91
+ return defaultVisible;
92
+ }
93
+ return overrideValue;
94
+ }
95
+ setFieldVisibility(inputId, isVisible) {
96
+ const field = this.containerEl.querySelector(`#${inputId}`);
97
+ if (field?.parentElement) {
98
+ field.parentElement.style.display = isVisible ? '' : 'none';
99
+ }
100
+ }
101
+ populateCountrySelector(selectEl) {
102
+ const validCountries = this.cardSessionFieldConfig?.validCountries || [];
103
+ const selectedCountryCode = this.getSelectedCountryCode();
104
+ selectEl.innerHTML = '';
105
+ const placeholderOption = document.createElement('option');
106
+ placeholderOption.value = '';
107
+ placeholderOption.textContent = 'Select country';
108
+ selectEl.appendChild(placeholderOption);
109
+ validCountries.forEach(country => {
110
+ const option = document.createElement('option');
111
+ option.value = country.code;
112
+ option.textContent = country.name;
113
+ selectEl.appendChild(option);
114
+ });
115
+ if (selectedCountryCode) {
116
+ selectEl.value = selectedCountryCode;
117
+ }
118
+ }
119
+ updateDynamicFieldVisibility(countryCode = this.getSelectedCountryCode()) {
120
+ this.setFieldVisibility('cardHolderInput', this.isCardholderNameVisible(countryCode));
121
+ this.setFieldVisibility('postalCodeInput', this.isPostalCodeVisible(countryCode));
122
+ const postalCodeInput = this.containerEl.querySelector('#postalCodeInput');
123
+ if (!this.isPostalCodeVisible(countryCode) && postalCodeInput) {
124
+ postalCodeInput.value = '';
125
+ }
126
+ }
55
127
  wireCardInputs() {
56
128
  const cardNumber = this.containerEl.querySelector('#cardNumberInput');
57
129
  const expiryDate = this.containerEl.querySelector('#expiryInput');
58
130
  const cvv = this.containerEl.querySelector('#cvvInput');
59
- const hasCardholderInput = !!this.checkoutConfig?.card?.cardholderName?.required;
60
- let cardholderName = undefined;
61
- if (hasCardholderInput) {
62
- cardholderName =
63
- this.containerEl.querySelector('#cardHolderInput');
64
- }
65
- else {
66
- this.containerEl.querySelector('#cardHolderInput').parentElement.style.display = 'none';
67
- }
131
+ const cardholderName = this.containerEl.querySelector('#cardHolderInput');
68
132
  const hasEmailInput = !!this.checkoutConfig?.card?.emailAddress?.visible;
69
133
  let emailAddress = undefined;
70
134
  if (hasEmailInput) {
@@ -77,11 +141,23 @@ class CardSkin {
77
141
  else {
78
142
  this.containerEl.querySelector('#emailAddressInput').parentElement.style.display = 'none';
79
143
  }
144
+ const countrySelector = this.containerEl.querySelector('#countrySelectorInput');
145
+ const postalCode = this.containerEl.querySelector('#postalCodeInput');
146
+ if (countrySelector) {
147
+ this.populateCountrySelector(countrySelector);
148
+ countrySelector.addEventListener('change', () => {
149
+ this.updateDynamicFieldVisibility(this.normalizeCountryCode(countrySelector.value));
150
+ });
151
+ }
152
+ this.setFieldVisibility('countrySelectorInput', this.isCountrySelectorVisible());
153
+ this.updateDynamicFieldVisibility();
80
154
  if (!cardNumber ||
81
155
  !expiryDate ||
82
156
  !cvv ||
83
- (hasCardholderInput && !cardholderName) ||
84
- (hasEmailInput && !emailAddress)) {
157
+ !cardholderName ||
158
+ (hasEmailInput && !emailAddress) ||
159
+ !countrySelector ||
160
+ !postalCode) {
85
161
  throw new Error('One or more card input elements are missing in the default skin');
86
162
  }
87
163
  this.cardInputElements = {
@@ -90,6 +166,8 @@ class CardSkin {
90
166
  cvv,
91
167
  cardholderName,
92
168
  emailAddress,
169
+ countrySelector,
170
+ postalCode,
93
171
  };
94
172
  }
95
173
  async init() {
@@ -107,7 +185,7 @@ class CardSkin {
107
185
  cardElements: this.getCardInputElements(),
108
186
  card: {
109
187
  cardholderName: {
110
- required: !!this.checkoutConfig?.card?.cardholderName?.required,
188
+ required: false,
111
189
  },
112
190
  },
113
191
  };