@funnelfox/billing 0.6.7 → 0.7.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.7';
423
+ const SDK_VERSION = '0.7.0';
424
424
  const DEFAULTS = {
425
425
  BASE_URL: 'https://billing.funnelfox.com',
426
426
  REGION: 'default',
@@ -671,6 +671,8 @@ class PrimerWrapper {
671
671
  onMethodRenderError: options.onMethodRenderError,
672
672
  onMethodRender: options.onMethodRender,
673
673
  onCardInputValueChange: options.onCardInputValueChange,
674
+ isCardholderNameRequired: options.isCardholderNameRequired,
675
+ isPostalCodeRequired: options.isPostalCodeRequired,
674
676
  });
675
677
  this.paymentMethodsInterfaces.push(cardInterface);
676
678
  return cardInterface;
@@ -689,7 +691,7 @@ class PrimerWrapper {
689
691
  throw new PrimerError('Failed to initialize Primer checkout', error);
690
692
  }
691
693
  }
692
- async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, onMethodRenderError, onMethodRender, }) {
694
+ async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, isCardholderNameRequired, isPostalCodeRequired, onMethodRenderError, onMethodRender, }) {
693
695
  try {
694
696
  if (!this.currentHeadless) {
695
697
  throw new PrimerError('Headless checkout not found');
@@ -705,8 +707,10 @@ class PrimerWrapper {
705
707
  if (!pmManager)
706
708
  return false;
707
709
  const { valid, validationErrors } = await pmManager.validate();
708
- const cardHolderError = validationErrors.find(v => v.name === 'cardholderName');
709
- dispatchError('cardholderName', cardHolderError?.message || null);
710
+ const cardHolderError = isCardholderNameRequired?.()
711
+ ? validationErrors.find(v => v.name === 'cardholderName')?.message
712
+ : null;
713
+ dispatchError('cardholderName', cardHolderError);
710
714
  let emailError = null;
711
715
  if (hasEmail) {
712
716
  const emailAddress = elements.emailAddress?.value?.trim();
@@ -715,11 +719,19 @@ class PrimerWrapper {
715
719
  : null;
716
720
  dispatchError('emailAddress', emailError);
717
721
  }
718
- return valid && !emailError;
722
+ const postalCodeError = getPostalCodeError();
723
+ dispatchError('postalCode', postalCodeError);
724
+ return valid && !emailError && !cardHolderError && !postalCodeError;
719
725
  };
720
726
  const dispatchError = (inputName, error) => {
721
727
  onInputChange(inputName, error);
722
728
  };
729
+ const getPostalCodeError = () => {
730
+ const postalCode = elements.postalCode?.value?.trim();
731
+ return isPostalCodeRequired?.() && !postalCode
732
+ ? 'Please enter a postal code'
733
+ : null;
734
+ };
723
735
  const onHostedInputChange = (name) => (event) => {
724
736
  const input = event;
725
737
  if (input.submitted) {
@@ -742,7 +754,22 @@ class PrimerWrapper {
742
754
  };
743
755
  elements.emailAddress.addEventListener('input', emailAddressOnChange);
744
756
  }
757
+ const countrySelectorOnChange = (e) => {
758
+ const countryCode = e.target.value.trim();
759
+ onCardInputValueChange?.('countryCode', countryCode);
760
+ if (!isPostalCodeRequired?.()) {
761
+ dispatchError('postalCode', null);
762
+ }
763
+ };
764
+ const postalCodeOnChange = (e) => {
765
+ const postalCode = e.target.value.trim();
766
+ onCardInputValueChange?.('postalCode', postalCode);
767
+ dispatchError('postalCode', getPostalCodeError());
768
+ };
745
769
  elements.cardholderName?.addEventListener('input', cardHolderOnChange);
770
+ elements.emailAddress?.addEventListener('input', emailAddressOnChange);
771
+ elements.countrySelector?.addEventListener('change', countrySelectorOnChange);
772
+ elements.postalCode?.addEventListener('input', postalCodeOnChange);
746
773
  cardNumberInput.addEventListener('change', onHostedInputChange('cardNumber'));
747
774
  expiryInput.addEventListener('change', onHostedInputChange('expiryDate'));
748
775
  cvvInput.addEventListener('change', onHostedInputChange('cvv'));
@@ -785,6 +812,8 @@ class PrimerWrapper {
785
812
  pmManager.removeHostedInputs();
786
813
  elements.cardholderName?.removeEventListener('input', cardHolderOnChange);
787
814
  elements.emailAddress?.removeEventListener('input', emailAddressOnChange);
815
+ elements.countrySelector?.removeEventListener('change', countrySelectorOnChange);
816
+ elements.postalCode?.removeEventListener('input', postalCodeOnChange);
788
817
  elements.button?.removeEventListener('click', onSubmitHandler);
789
818
  };
790
819
  this.destroyCallbacks.push(onDestroy);
@@ -803,6 +832,12 @@ class PrimerWrapper {
803
832
  if (elements.emailAddress) {
804
833
  elements.emailAddress.disabled = disabled;
805
834
  }
835
+ if (elements.countrySelector) {
836
+ elements.countrySelector.disabled = disabled;
837
+ }
838
+ if (elements.postalCode) {
839
+ elements.postalCode.disabled = disabled;
840
+ }
806
841
  },
807
842
  submit: () => onSubmitHandler(),
808
843
  destroy: () => {
@@ -825,7 +860,7 @@ class PrimerWrapper {
825
860
  }, method);
826
861
  }
827
862
  async renderCheckout(clientToken, checkoutOptions, checkoutRenderOptions) {
828
- const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, } = checkoutRenderOptions;
863
+ const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, isCardholderNameRequired, isPostalCodeRequired, } = checkoutRenderOptions;
829
864
  await this.initializeHeadlessCheckout(clientToken, checkoutOptions);
830
865
  onMethodsAvailable?.(this.availableMethods);
831
866
  await Promise.all(this.availableMethods.map(method => {
@@ -838,6 +873,8 @@ class PrimerWrapper {
838
873
  onMethodRender,
839
874
  onMethodRenderError,
840
875
  onCardInputValueChange,
876
+ isCardholderNameRequired,
877
+ isPostalCodeRequired,
841
878
  });
842
879
  }
843
880
  else {
@@ -1052,6 +1089,12 @@ class APIClient {
1052
1089
  if (params.email !== undefined) {
1053
1090
  payload.email_address = params.email;
1054
1091
  }
1092
+ if (params.countryCode !== undefined) {
1093
+ payload.country_code = params.countryCode;
1094
+ }
1095
+ if (params.postalCode !== undefined) {
1096
+ payload.postal_code = params.postalCode;
1097
+ }
1055
1098
  return (await this.request(API_ENDPOINTS.CREATE_PAYMENT, {
1056
1099
  method: 'POST',
1057
1100
  body: JSON.stringify(payload),
@@ -1364,6 +1407,7 @@ class CheckoutInstance extends EventEmitter {
1364
1407
  super();
1365
1408
  this.counter = 0;
1366
1409
  this.radarSessionId = null;
1410
+ this.cardSessionFieldConfig = {};
1367
1411
  this.handleInputChange = (inputName, error) => {
1368
1412
  this.emit(EVENTS.INPUT_ERROR, { name: inputName, error });
1369
1413
  };
@@ -1381,6 +1425,17 @@ class CheckoutInstance extends EventEmitter {
1381
1425
  this.handleCardInputValueChange = (inputName, value) => {
1382
1426
  if (inputName === 'emailAddress') {
1383
1427
  this.cardEmailAddress = value?.trim() || undefined;
1428
+ return;
1429
+ }
1430
+ if (inputName === 'countryCode') {
1431
+ this.cardCountryCode = this.normalizeCountryCode(value);
1432
+ if (!this.isPostalCodeVisible()) {
1433
+ this.cardPostalCode = undefined;
1434
+ }
1435
+ return;
1436
+ }
1437
+ if (inputName === 'postalCode') {
1438
+ this.cardPostalCode = value?.trim() || undefined;
1384
1439
  }
1385
1440
  };
1386
1441
  this.handleMethodRender = (method) => {
@@ -1406,6 +1461,8 @@ class CheckoutInstance extends EventEmitter {
1406
1461
  orderId: this.orderId,
1407
1462
  paymentMethodToken: paymentMethodTokenData.token,
1408
1463
  email: this.getPaymentEmailAddress(),
1464
+ countryCode: this.getPaymentCountryCode(),
1465
+ postalCode: this.getPaymentPostalCode(),
1409
1466
  clientMetadata: {
1410
1467
  radarSessionId,
1411
1468
  },
@@ -1478,6 +1535,8 @@ class CheckoutInstance extends EventEmitter {
1478
1535
  this.primerWrapper = new PrimerWrapper();
1479
1536
  this.isDestroyed = false;
1480
1537
  this.cardEmailAddress = this.checkoutConfig.customer.email;
1538
+ this.shouldApplySessionCardholderNameConfig =
1539
+ this.checkoutConfig.card?.cardholderName?.required === undefined;
1481
1540
  this._setupCallbackBridges();
1482
1541
  }
1483
1542
  _setupCallbackBridges() {
@@ -1517,7 +1576,7 @@ class CheckoutInstance extends EventEmitter {
1517
1576
  this.hideInitializingLoader();
1518
1577
  }
1519
1578
  }
1520
- async createSession(method) {
1579
+ async createSession() {
1521
1580
  this.apiClient = new APIClient({
1522
1581
  baseUrl: this.baseUrl || DEFAULTS.BASE_URL,
1523
1582
  orgId: this.orgId,
@@ -1532,14 +1591,11 @@ class CheckoutInstance extends EventEmitter {
1532
1591
  clientMetadata: this.checkoutConfig.clientMetadata,
1533
1592
  countryCode: this.checkoutConfig.customer.countryCode,
1534
1593
  };
1535
- this.sessionMethod = method;
1536
1594
  const cacheKey = [
1537
- //this.id,
1538
1595
  this.orgId,
1539
1596
  this.checkoutConfig.priceId,
1540
1597
  this.checkoutConfig.customer.externalId,
1541
1598
  this.checkoutConfig.customer.email,
1542
- //method || 'default',
1543
1599
  ].join('-');
1544
1600
  let sessionResponse;
1545
1601
  // Return cached response if payload hasn't changed
@@ -1573,7 +1629,9 @@ class CheckoutInstance extends EventEmitter {
1573
1629
  this.clientToken = sessionData.clientToken;
1574
1630
  }
1575
1631
  applySessionCardFieldConfig(response) {
1576
- const cardConfig = this.checkoutConfig.card || {};
1632
+ const cardConfig = {
1633
+ ...(this.checkoutConfig.card || {}),
1634
+ };
1577
1635
  if (cardConfig.emailAddress?.visible === undefined &&
1578
1636
  response.data?.show_email_field !== undefined) {
1579
1637
  cardConfig.emailAddress = {
@@ -1581,19 +1639,41 @@ class CheckoutInstance extends EventEmitter {
1581
1639
  visible: response.data.show_email_field,
1582
1640
  };
1583
1641
  }
1584
- if (cardConfig.cardholderName?.required === undefined &&
1642
+ if (this.shouldApplySessionCardholderNameConfig &&
1585
1643
  response.data?.show_cardholder_name_field !== undefined) {
1586
1644
  cardConfig.cardholderName = {
1587
1645
  ...cardConfig.cardholderName,
1588
1646
  required: response.data.show_cardholder_name_field,
1589
1647
  };
1590
1648
  }
1649
+ const countryFieldOverrides = this.normalizeCountryFieldOverrides(response.data?.country_field_overrides);
1650
+ const detectedCountryCode = this.normalizeCountryCode(response.data?.detected_country_code) ||
1651
+ this.cardCountryCode;
1652
+ this.cardSessionFieldConfig = {
1653
+ ...this.cardSessionFieldConfig,
1654
+ showCountrySelector: response.data?.show_country_selector_field ??
1655
+ this.cardSessionFieldConfig.showCountrySelector,
1656
+ showPostalCode: response.data?.show_postal_code_field ??
1657
+ this.cardSessionFieldConfig.showPostalCode,
1658
+ detectedCountryCode: detectedCountryCode || this.cardSessionFieldConfig.detectedCountryCode,
1659
+ validCountries: response.data?.valid_countries ||
1660
+ this.cardSessionFieldConfig.validCountries,
1661
+ countryFieldOverrides: countryFieldOverrides ||
1662
+ this.cardSessionFieldConfig.countryFieldOverrides,
1663
+ };
1591
1664
  if (Object.keys(cardConfig).length > 0) {
1592
1665
  this.checkoutConfig.card = cardConfig;
1593
1666
  }
1667
+ this.cardCountryCode =
1668
+ this.cardSessionFieldConfig.detectedCountryCode || this.cardCountryCode;
1669
+ if (!this.isPostalCodeVisible()) {
1670
+ this.cardPostalCode = undefined;
1671
+ }
1594
1672
  }
1595
1673
  getPrimerCardConfig() {
1596
- const cardConfig = { ...(this.checkoutConfig.card || {}) };
1674
+ const cardConfig = {
1675
+ ...(this.checkoutConfig.card || {}),
1676
+ };
1597
1677
  delete cardConfig.emailAddress;
1598
1678
  return Object.keys(cardConfig).length
1599
1679
  ? cardConfig
@@ -1703,6 +1783,8 @@ class CheckoutInstance extends EventEmitter {
1703
1783
  onSubmit: this.handleSubmit,
1704
1784
  onInputChange: this.handleInputChange,
1705
1785
  onCardInputValueChange: this.handleCardInputValueChange,
1786
+ isCardholderNameRequired: () => this.isCardholderNameRequired(),
1787
+ isPostalCodeRequired: () => this.isPostalCodeVisible(),
1706
1788
  onMethodRender: this.handleMethodRender,
1707
1789
  onMethodsAvailable: this.handleMethodsAvailable,
1708
1790
  onMethodRenderError: this.handleMethodRenderError,
@@ -1861,12 +1943,58 @@ class CheckoutInstance extends EventEmitter {
1861
1943
  isProcessing() {
1862
1944
  return ['processing', 'action_required'].includes(this.state);
1863
1945
  }
1946
+ normalizeCountryCode(countryCode) {
1947
+ const normalized = countryCode?.trim().toUpperCase();
1948
+ return normalized || undefined;
1949
+ }
1950
+ normalizeCountryFieldOverrides(overrides) {
1951
+ if (!overrides) {
1952
+ return undefined;
1953
+ }
1954
+ return Object.entries(overrides).reduce((result, [countryCode, override]) => {
1955
+ const normalizedCountryCode = this.normalizeCountryCode(countryCode);
1956
+ if (normalizedCountryCode && override) {
1957
+ result[normalizedCountryCode] = override;
1958
+ }
1959
+ return result;
1960
+ }, {});
1961
+ }
1962
+ getSelectedCountryCode() {
1963
+ return (this.normalizeCountryCode(this.cardCountryCode) ||
1964
+ this.normalizeCountryCode(this.cardSessionFieldConfig.detectedCountryCode));
1965
+ }
1966
+ getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
1967
+ if (!countryCode) {
1968
+ return undefined;
1969
+ }
1970
+ return this.cardSessionFieldConfig.countryFieldOverrides?.[countryCode];
1971
+ }
1972
+ isCardholderNameRequired() {
1973
+ return !!this.checkoutConfig.card?.cardholderName?.required;
1974
+ }
1975
+ isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
1976
+ const defaultValue = !!this.cardSessionFieldConfig.showPostalCode;
1977
+ const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
1978
+ if (overrideValue === null || overrideValue === undefined) {
1979
+ return defaultValue;
1980
+ }
1981
+ return overrideValue;
1982
+ }
1983
+ getPaymentCountryCode() {
1984
+ return this.getSelectedCountryCode();
1985
+ }
1986
+ getPaymentPostalCode() {
1987
+ if (!this.isPostalCodeVisible()) {
1988
+ return undefined;
1989
+ }
1990
+ return this.cardPostalCode?.trim() || undefined;
1991
+ }
1864
1992
  // Creates containers to render hosted inputs with labels and error messages,
1865
1993
  // a card holder input with label and error, and a submit button.
1866
1994
  async getDefaultSkinCheckoutOptions() {
1867
1995
  const skinFactory = (await import('./chunk-index.es2.js'))
1868
1996
  .default;
1869
- const skin = await skinFactory(this.checkoutConfig);
1997
+ const skin = await skinFactory(this.checkoutConfig, this.cardSessionFieldConfig);
1870
1998
  this.on(EVENTS.INPUT_ERROR, skin.onInputError);
1871
1999
  this.on(EVENTS.STATUS_CHANGE, skin.onStatusChange);
1872
2000
  this.on(EVENTS.ERROR, (error) => skin.onError(error));
@@ -1882,7 +2010,7 @@ class CheckoutInstance extends EventEmitter {
1882
2010
  }
1883
2011
  async getCardDefaultSkinCheckoutOptions(node) {
1884
2012
  const CardSkin = (await import('./chunk-index.es3.js')).default;
1885
- const skin = new CardSkin(node, this.checkoutConfig);
2013
+ const skin = new CardSkin(node, this.checkoutConfig, this.cardSessionFieldConfig);
1886
2014
  skin.init();
1887
2015
  this.on(EVENTS.INPUT_ERROR, skin.onInputError);
1888
2016
  this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
@@ -1899,7 +2027,7 @@ class CheckoutInstance extends EventEmitter {
1899
2027
  async initMethod(method, element, callbacks) {
1900
2028
  this._ensureNotDestroyed();
1901
2029
  if (!this.isReady()) {
1902
- await this.createSession(method);
2030
+ await this.createSession();
1903
2031
  }
1904
2032
  if (callbacks.onRenderSuccess) {
1905
2033
  this.on(EVENTS.METHOD_RENDER, callbacks.onRenderSuccess);
@@ -1943,6 +2071,8 @@ class CheckoutInstance extends EventEmitter {
1943
2071
  onSubmit: this.handleSubmit,
1944
2072
  onInputChange: this.handleInputChange,
1945
2073
  onCardInputValueChange: this.handleCardInputValueChange,
2074
+ isCardholderNameRequired: () => this.isCardholderNameRequired(),
2075
+ isPostalCodeRequired: () => this.isPostalCodeVisible(),
1946
2076
  onMethodRender: this.handleMethodRender,
1947
2077
  onMethodRenderError: this.handleMethodRenderError,
1948
2078
  };
@@ -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=\"cardHolderInput\">Cardholder name</label>\n <input class=\"ff-card-form-text-input\" id=\"cardHolderInput\" type=\"text\" pattern=\"[A-Za-z\\s]+\" placeholder=\"Full name on card\">\n <div class=\"errorContainer\"></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 id=\"countrySelectorField\">\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\">Zip code</label>\n <input class=\"ff-card-form-text-input\" id=\"postalCodeInput\" placeholder=\"12345\">\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-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-card-form-select:disabled {\n color: #6b7280;\n cursor: not-allowed;\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();
@@ -20,15 +20,20 @@ class CardSkin {
20
20
  cvv: cardInputElements.cvv.parentElement,
21
21
  cardholderName: cardInputElements.cardholderName?.parentElement,
22
22
  emailAddress: cardInputElements.emailAddress?.parentElement,
23
+ postalCode: cardInputElements.postalCode?.parentElement,
23
24
  };
24
25
  const errorContainer = elementsMap[name]?.querySelector('.errorContainer');
25
26
  if (errorContainer) {
26
27
  errorContainer.textContent = error || '';
27
28
  }
28
- if (name === 'cardholderName' || name === 'emailAddress') {
29
+ if (name === 'cardholderName' ||
30
+ name === 'emailAddress' ||
31
+ name === 'postalCode') {
29
32
  const field = name === 'cardholderName'
30
33
  ? cardInputElements.cardholderName
31
- : cardInputElements.emailAddress;
34
+ : name === 'emailAddress'
35
+ ? cardInputElements.emailAddress
36
+ : cardInputElements.postalCode;
32
37
  if (error) {
33
38
  field?.classList?.add('error');
34
39
  }
@@ -50,21 +55,92 @@ class CardSkin {
50
55
  }
51
56
  this.containerEl = containerEl;
52
57
  this.checkoutConfig = checkoutConfig;
58
+ this.cardSessionFieldConfig = cardSessionFieldConfig;
53
59
  this.containerEl.style.display = 'none';
54
60
  }
61
+ normalizeCountryCode(countryCode) {
62
+ const normalized = countryCode?.trim().toUpperCase();
63
+ return normalized || undefined;
64
+ }
65
+ getSelectedCountryCode() {
66
+ const selector = this.containerEl.querySelector('#countrySelectorInput');
67
+ return (this.normalizeCountryCode(selector?.value) ||
68
+ this.normalizeCountryCode(this.cardSessionFieldConfig?.detectedCountryCode));
69
+ }
70
+ getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
71
+ if (!countryCode) {
72
+ return undefined;
73
+ }
74
+ return this.cardSessionFieldConfig?.countryFieldOverrides?.[countryCode];
75
+ }
76
+ isCountrySelectorVisible() {
77
+ return !!this.cardSessionFieldConfig?.showCountrySelector;
78
+ }
79
+ isCardholderNameVisible() {
80
+ return !!this.checkoutConfig.card?.cardholderName?.required;
81
+ }
82
+ isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
83
+ const defaultVisible = !!this.cardSessionFieldConfig?.showPostalCode;
84
+ const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
85
+ if (overrideValue === null || overrideValue === undefined) {
86
+ return defaultVisible;
87
+ }
88
+ return overrideValue;
89
+ }
90
+ setFieldVisibility(inputId, isVisible) {
91
+ const field = this.containerEl.querySelector(`#${inputId}`);
92
+ if (field?.parentElement) {
93
+ field.parentElement.style.display = isVisible ? '' : 'none';
94
+ }
95
+ }
96
+ setContainerVisibility(containerId, isVisible) {
97
+ const container = this.containerEl.querySelector(`#${containerId}`);
98
+ if (container) {
99
+ container.style.display = isVisible ? '' : 'none';
100
+ }
101
+ }
102
+ populateCountrySelector(selectEl) {
103
+ const validCountries = this.cardSessionFieldConfig?.validCountries || [];
104
+ const selectedCountryCode = this.getSelectedCountryCode();
105
+ selectEl.innerHTML = '';
106
+ selectEl.disabled = false;
107
+ if (!validCountries.length) {
108
+ const fallbackOption = document.createElement('option');
109
+ fallbackOption.value = selectedCountryCode || '';
110
+ fallbackOption.textContent = selectedCountryCode
111
+ ? `Detected country: ${selectedCountryCode}`
112
+ : 'Country unavailable';
113
+ selectEl.appendChild(fallbackOption);
114
+ selectEl.disabled = true;
115
+ return;
116
+ }
117
+ const placeholderOption = document.createElement('option');
118
+ placeholderOption.value = '';
119
+ placeholderOption.textContent = 'Select country';
120
+ selectEl.appendChild(placeholderOption);
121
+ validCountries.forEach(country => {
122
+ const option = document.createElement('option');
123
+ option.value = country.code;
124
+ option.textContent = country.name;
125
+ selectEl.appendChild(option);
126
+ });
127
+ if (selectedCountryCode) {
128
+ selectEl.value = selectedCountryCode;
129
+ }
130
+ }
131
+ updateDynamicFieldVisibility(countryCode = this.getSelectedCountryCode()) {
132
+ this.setFieldVisibility('cardHolderInput', this.isCardholderNameVisible());
133
+ this.setFieldVisibility('postalCodeInput', this.isPostalCodeVisible(countryCode));
134
+ const postalCodeInput = this.containerEl.querySelector('#postalCodeInput');
135
+ if (!this.isPostalCodeVisible(countryCode) && postalCodeInput) {
136
+ postalCodeInput.value = '';
137
+ }
138
+ }
55
139
  wireCardInputs() {
56
140
  const cardNumber = this.containerEl.querySelector('#cardNumberInput');
57
141
  const expiryDate = this.containerEl.querySelector('#expiryInput');
58
142
  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
- }
143
+ const cardholderName = this.containerEl.querySelector('#cardHolderInput');
68
144
  const hasEmailInput = !!this.checkoutConfig?.card?.emailAddress?.visible;
69
145
  let emailAddress = undefined;
70
146
  if (hasEmailInput) {
@@ -77,11 +153,23 @@ class CardSkin {
77
153
  else {
78
154
  this.containerEl.querySelector('#emailAddressInput').parentElement.style.display = 'none';
79
155
  }
156
+ const countrySelector = this.containerEl.querySelector('#countrySelectorInput');
157
+ const postalCode = this.containerEl.querySelector('#postalCodeInput');
158
+ if (countrySelector) {
159
+ this.populateCountrySelector(countrySelector);
160
+ countrySelector.addEventListener('change', () => {
161
+ this.updateDynamicFieldVisibility(this.normalizeCountryCode(countrySelector.value));
162
+ });
163
+ }
164
+ this.setContainerVisibility('countrySelectorField', this.isCountrySelectorVisible());
165
+ this.updateDynamicFieldVisibility();
80
166
  if (!cardNumber ||
81
167
  !expiryDate ||
82
168
  !cvv ||
83
- (hasCardholderInput && !cardholderName) ||
84
- (hasEmailInput && !emailAddress)) {
169
+ !cardholderName ||
170
+ (hasEmailInput && !emailAddress) ||
171
+ !countrySelector ||
172
+ !postalCode) {
85
173
  throw new Error('One or more card input elements are missing in the default skin');
86
174
  }
87
175
  this.cardInputElements = {
@@ -90,6 +178,8 @@ class CardSkin {
90
178
  cvv,
91
179
  cardholderName,
92
180
  emailAddress,
181
+ countrySelector,
182
+ postalCode,
93
183
  };
94
184
  }
95
185
  async init() {
@@ -105,11 +195,6 @@ class CardSkin {
105
195
  getCheckoutOptions() {
106
196
  return {
107
197
  cardElements: this.getCardInputElements(),
108
- card: {
109
- cardholderName: {
110
- required: !!this.checkoutConfig?.card?.cardholderName?.required,
111
- },
112
- },
113
198
  };
114
199
  }
115
200
  }