@funnelfox/billing 0.6.7-hotfix.3 → 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.
@@ -422,7 +422,7 @@ exports.PaymentMethod = void 0;
422
422
  /**
423
423
  * @fileoverview Constants for Funnefox SDK
424
424
  */
425
- const SDK_VERSION = '0.6.7-hotfix.3';
425
+ const SDK_VERSION = '0.7.0';
426
426
  const DEFAULTS = {
427
427
  BASE_URL: 'https://billing.funnelfox.com',
428
428
  REGION: 'default',
@@ -673,6 +673,8 @@ class PrimerWrapper {
673
673
  onMethodRenderError: options.onMethodRenderError,
674
674
  onMethodRender: options.onMethodRender,
675
675
  onCardInputValueChange: options.onCardInputValueChange,
676
+ isCardholderNameRequired: options.isCardholderNameRequired,
677
+ isPostalCodeRequired: options.isPostalCodeRequired,
676
678
  });
677
679
  this.paymentMethodsInterfaces.push(cardInterface);
678
680
  return cardInterface;
@@ -691,7 +693,7 @@ class PrimerWrapper {
691
693
  throw new PrimerError('Failed to initialize Primer checkout', error);
692
694
  }
693
695
  }
694
- async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, onMethodRenderError, onMethodRender, }) {
696
+ async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, isCardholderNameRequired, isPostalCodeRequired, onMethodRenderError, onMethodRender, }) {
695
697
  try {
696
698
  if (!this.currentHeadless) {
697
699
  throw new PrimerError('Headless checkout not found');
@@ -707,8 +709,10 @@ class PrimerWrapper {
707
709
  if (!pmManager)
708
710
  return false;
709
711
  const { valid, validationErrors } = await pmManager.validate();
710
- const cardHolderError = validationErrors.find(v => v.name === 'cardholderName');
711
- dispatchError('cardholderName', cardHolderError?.message || null);
712
+ const cardHolderError = isCardholderNameRequired?.()
713
+ ? validationErrors.find(v => v.name === 'cardholderName')?.message
714
+ : null;
715
+ dispatchError('cardholderName', cardHolderError);
712
716
  let emailError = null;
713
717
  if (hasEmail) {
714
718
  const emailAddress = elements.emailAddress?.value?.trim();
@@ -717,11 +721,19 @@ class PrimerWrapper {
717
721
  : null;
718
722
  dispatchError('emailAddress', emailError);
719
723
  }
720
- return valid && !emailError;
724
+ const postalCodeError = getPostalCodeError();
725
+ dispatchError('postalCode', postalCodeError);
726
+ return valid && !emailError && !cardHolderError && !postalCodeError;
721
727
  };
722
728
  const dispatchError = (inputName, error) => {
723
729
  onInputChange(inputName, error);
724
730
  };
731
+ const getPostalCodeError = () => {
732
+ const postalCode = elements.postalCode?.value?.trim();
733
+ return isPostalCodeRequired?.() && !postalCode
734
+ ? 'Please enter a postal code'
735
+ : null;
736
+ };
725
737
  const onHostedInputChange = (name) => (event) => {
726
738
  const input = event;
727
739
  if (input.submitted) {
@@ -744,7 +756,22 @@ class PrimerWrapper {
744
756
  };
745
757
  elements.emailAddress.addEventListener('input', emailAddressOnChange);
746
758
  }
759
+ const countrySelectorOnChange = (e) => {
760
+ const countryCode = e.target.value.trim();
761
+ onCardInputValueChange?.('countryCode', countryCode);
762
+ if (!isPostalCodeRequired?.()) {
763
+ dispatchError('postalCode', null);
764
+ }
765
+ };
766
+ const postalCodeOnChange = (e) => {
767
+ const postalCode = e.target.value.trim();
768
+ onCardInputValueChange?.('postalCode', postalCode);
769
+ dispatchError('postalCode', getPostalCodeError());
770
+ };
747
771
  elements.cardholderName?.addEventListener('input', cardHolderOnChange);
772
+ elements.emailAddress?.addEventListener('input', emailAddressOnChange);
773
+ elements.countrySelector?.addEventListener('change', countrySelectorOnChange);
774
+ elements.postalCode?.addEventListener('input', postalCodeOnChange);
748
775
  cardNumberInput.addEventListener('change', onHostedInputChange('cardNumber'));
749
776
  expiryInput.addEventListener('change', onHostedInputChange('expiryDate'));
750
777
  cvvInput.addEventListener('change', onHostedInputChange('cvv'));
@@ -787,6 +814,8 @@ class PrimerWrapper {
787
814
  pmManager.removeHostedInputs();
788
815
  elements.cardholderName?.removeEventListener('input', cardHolderOnChange);
789
816
  elements.emailAddress?.removeEventListener('input', emailAddressOnChange);
817
+ elements.countrySelector?.removeEventListener('change', countrySelectorOnChange);
818
+ elements.postalCode?.removeEventListener('input', postalCodeOnChange);
790
819
  elements.button?.removeEventListener('click', onSubmitHandler);
791
820
  };
792
821
  this.destroyCallbacks.push(onDestroy);
@@ -805,6 +834,12 @@ class PrimerWrapper {
805
834
  if (elements.emailAddress) {
806
835
  elements.emailAddress.disabled = disabled;
807
836
  }
837
+ if (elements.countrySelector) {
838
+ elements.countrySelector.disabled = disabled;
839
+ }
840
+ if (elements.postalCode) {
841
+ elements.postalCode.disabled = disabled;
842
+ }
808
843
  },
809
844
  submit: () => onSubmitHandler(),
810
845
  destroy: () => {
@@ -827,7 +862,7 @@ class PrimerWrapper {
827
862
  }, method);
828
863
  }
829
864
  async renderCheckout(clientToken, checkoutOptions, checkoutRenderOptions) {
830
- const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, } = checkoutRenderOptions;
865
+ const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, isCardholderNameRequired, isPostalCodeRequired, } = checkoutRenderOptions;
831
866
  await this.initializeHeadlessCheckout(clientToken, checkoutOptions);
832
867
  onMethodsAvailable?.(this.availableMethods);
833
868
  await Promise.all(this.availableMethods.map(method => {
@@ -840,6 +875,8 @@ class PrimerWrapper {
840
875
  onMethodRender,
841
876
  onMethodRenderError,
842
877
  onCardInputValueChange,
878
+ isCardholderNameRequired,
879
+ isPostalCodeRequired,
843
880
  });
844
881
  }
845
882
  else {
@@ -1054,6 +1091,12 @@ class APIClient {
1054
1091
  if (params.email !== undefined) {
1055
1092
  payload.email_address = params.email;
1056
1093
  }
1094
+ if (params.countryCode !== undefined) {
1095
+ payload.country_code = params.countryCode;
1096
+ }
1097
+ if (params.postalCode !== undefined) {
1098
+ payload.postal_code = params.postalCode;
1099
+ }
1057
1100
  return (await this.request(API_ENDPOINTS.CREATE_PAYMENT, {
1058
1101
  method: 'POST',
1059
1102
  body: JSON.stringify(payload),
@@ -1366,6 +1409,7 @@ class CheckoutInstance extends EventEmitter {
1366
1409
  super();
1367
1410
  this.counter = 0;
1368
1411
  this.radarSessionId = null;
1412
+ this.cardSessionFieldConfig = {};
1369
1413
  this.handleInputChange = (inputName, error) => {
1370
1414
  this.emit(EVENTS.INPUT_ERROR, { name: inputName, error });
1371
1415
  };
@@ -1383,6 +1427,17 @@ class CheckoutInstance extends EventEmitter {
1383
1427
  this.handleCardInputValueChange = (inputName, value) => {
1384
1428
  if (inputName === 'emailAddress') {
1385
1429
  this.cardEmailAddress = value?.trim() || undefined;
1430
+ return;
1431
+ }
1432
+ if (inputName === 'countryCode') {
1433
+ this.cardCountryCode = this.normalizeCountryCode(value);
1434
+ if (!this.isPostalCodeVisible()) {
1435
+ this.cardPostalCode = undefined;
1436
+ }
1437
+ return;
1438
+ }
1439
+ if (inputName === 'postalCode') {
1440
+ this.cardPostalCode = value?.trim() || undefined;
1386
1441
  }
1387
1442
  };
1388
1443
  this.handleMethodRender = (method) => {
@@ -1408,6 +1463,8 @@ class CheckoutInstance extends EventEmitter {
1408
1463
  orderId: this.orderId,
1409
1464
  paymentMethodToken: paymentMethodTokenData.token,
1410
1465
  email: this.getPaymentEmailAddress(),
1466
+ countryCode: this.getPaymentCountryCode(),
1467
+ postalCode: this.getPaymentPostalCode(),
1411
1468
  clientMetadata: {
1412
1469
  radarSessionId,
1413
1470
  },
@@ -1480,6 +1537,8 @@ class CheckoutInstance extends EventEmitter {
1480
1537
  this.primerWrapper = new PrimerWrapper();
1481
1538
  this.isDestroyed = false;
1482
1539
  this.cardEmailAddress = this.checkoutConfig.customer.email;
1540
+ this.shouldApplySessionCardholderNameConfig =
1541
+ this.checkoutConfig.card?.cardholderName?.required === undefined;
1483
1542
  this._setupCallbackBridges();
1484
1543
  }
1485
1544
  _setupCallbackBridges() {
@@ -1519,7 +1578,7 @@ class CheckoutInstance extends EventEmitter {
1519
1578
  this.hideInitializingLoader();
1520
1579
  }
1521
1580
  }
1522
- async createSession(method) {
1581
+ async createSession() {
1523
1582
  this.apiClient = new APIClient({
1524
1583
  baseUrl: this.baseUrl || DEFAULTS.BASE_URL,
1525
1584
  orgId: this.orgId,
@@ -1534,14 +1593,11 @@ class CheckoutInstance extends EventEmitter {
1534
1593
  clientMetadata: this.checkoutConfig.clientMetadata,
1535
1594
  countryCode: this.checkoutConfig.customer.countryCode,
1536
1595
  };
1537
- this.sessionMethod = method;
1538
1596
  const cacheKey = [
1539
- //this.id,
1540
1597
  this.orgId,
1541
1598
  this.checkoutConfig.priceId,
1542
1599
  this.checkoutConfig.customer.externalId,
1543
1600
  this.checkoutConfig.customer.email,
1544
- //method || 'default',
1545
1601
  ].join('-');
1546
1602
  let sessionResponse;
1547
1603
  // Return cached response if payload hasn't changed
@@ -1575,7 +1631,9 @@ class CheckoutInstance extends EventEmitter {
1575
1631
  this.clientToken = sessionData.clientToken;
1576
1632
  }
1577
1633
  applySessionCardFieldConfig(response) {
1578
- const cardConfig = this.checkoutConfig.card || {};
1634
+ const cardConfig = {
1635
+ ...(this.checkoutConfig.card || {}),
1636
+ };
1579
1637
  if (cardConfig.emailAddress?.visible === undefined &&
1580
1638
  response.data?.show_email_field !== undefined) {
1581
1639
  cardConfig.emailAddress = {
@@ -1583,19 +1641,41 @@ class CheckoutInstance extends EventEmitter {
1583
1641
  visible: response.data.show_email_field,
1584
1642
  };
1585
1643
  }
1586
- if (cardConfig.cardholderName?.required === undefined &&
1644
+ if (this.shouldApplySessionCardholderNameConfig &&
1587
1645
  response.data?.show_cardholder_name_field !== undefined) {
1588
1646
  cardConfig.cardholderName = {
1589
1647
  ...cardConfig.cardholderName,
1590
1648
  required: response.data.show_cardholder_name_field,
1591
1649
  };
1592
1650
  }
1651
+ const countryFieldOverrides = this.normalizeCountryFieldOverrides(response.data?.country_field_overrides);
1652
+ const detectedCountryCode = this.normalizeCountryCode(response.data?.detected_country_code) ||
1653
+ this.cardCountryCode;
1654
+ this.cardSessionFieldConfig = {
1655
+ ...this.cardSessionFieldConfig,
1656
+ showCountrySelector: response.data?.show_country_selector_field ??
1657
+ this.cardSessionFieldConfig.showCountrySelector,
1658
+ showPostalCode: response.data?.show_postal_code_field ??
1659
+ this.cardSessionFieldConfig.showPostalCode,
1660
+ detectedCountryCode: detectedCountryCode || this.cardSessionFieldConfig.detectedCountryCode,
1661
+ validCountries: response.data?.valid_countries ||
1662
+ this.cardSessionFieldConfig.validCountries,
1663
+ countryFieldOverrides: countryFieldOverrides ||
1664
+ this.cardSessionFieldConfig.countryFieldOverrides,
1665
+ };
1593
1666
  if (Object.keys(cardConfig).length > 0) {
1594
1667
  this.checkoutConfig.card = cardConfig;
1595
1668
  }
1669
+ this.cardCountryCode =
1670
+ this.cardSessionFieldConfig.detectedCountryCode || this.cardCountryCode;
1671
+ if (!this.isPostalCodeVisible()) {
1672
+ this.cardPostalCode = undefined;
1673
+ }
1596
1674
  }
1597
1675
  getPrimerCardConfig() {
1598
- const cardConfig = { ...(this.checkoutConfig.card || {}) };
1676
+ const cardConfig = {
1677
+ ...(this.checkoutConfig.card || {}),
1678
+ };
1599
1679
  delete cardConfig.emailAddress;
1600
1680
  return Object.keys(cardConfig).length
1601
1681
  ? cardConfig
@@ -1705,6 +1785,8 @@ class CheckoutInstance extends EventEmitter {
1705
1785
  onSubmit: this.handleSubmit,
1706
1786
  onInputChange: this.handleInputChange,
1707
1787
  onCardInputValueChange: this.handleCardInputValueChange,
1788
+ isCardholderNameRequired: () => this.isCardholderNameRequired(),
1789
+ isPostalCodeRequired: () => this.isPostalCodeVisible(),
1708
1790
  onMethodRender: this.handleMethodRender,
1709
1791
  onMethodsAvailable: this.handleMethodsAvailable,
1710
1792
  onMethodRenderError: this.handleMethodRenderError,
@@ -1863,12 +1945,58 @@ class CheckoutInstance extends EventEmitter {
1863
1945
  isProcessing() {
1864
1946
  return ['processing', 'action_required'].includes(this.state);
1865
1947
  }
1948
+ normalizeCountryCode(countryCode) {
1949
+ const normalized = countryCode?.trim().toUpperCase();
1950
+ return normalized || undefined;
1951
+ }
1952
+ normalizeCountryFieldOverrides(overrides) {
1953
+ if (!overrides) {
1954
+ return undefined;
1955
+ }
1956
+ return Object.entries(overrides).reduce((result, [countryCode, override]) => {
1957
+ const normalizedCountryCode = this.normalizeCountryCode(countryCode);
1958
+ if (normalizedCountryCode && override) {
1959
+ result[normalizedCountryCode] = override;
1960
+ }
1961
+ return result;
1962
+ }, {});
1963
+ }
1964
+ getSelectedCountryCode() {
1965
+ return (this.normalizeCountryCode(this.cardCountryCode) ||
1966
+ this.normalizeCountryCode(this.cardSessionFieldConfig.detectedCountryCode));
1967
+ }
1968
+ getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
1969
+ if (!countryCode) {
1970
+ return undefined;
1971
+ }
1972
+ return this.cardSessionFieldConfig.countryFieldOverrides?.[countryCode];
1973
+ }
1974
+ isCardholderNameRequired() {
1975
+ return !!this.checkoutConfig.card?.cardholderName?.required;
1976
+ }
1977
+ isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
1978
+ const defaultValue = !!this.cardSessionFieldConfig.showPostalCode;
1979
+ const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
1980
+ if (overrideValue === null || overrideValue === undefined) {
1981
+ return defaultValue;
1982
+ }
1983
+ return overrideValue;
1984
+ }
1985
+ getPaymentCountryCode() {
1986
+ return this.getSelectedCountryCode();
1987
+ }
1988
+ getPaymentPostalCode() {
1989
+ if (!this.isPostalCodeVisible()) {
1990
+ return undefined;
1991
+ }
1992
+ return this.cardPostalCode?.trim() || undefined;
1993
+ }
1866
1994
  // Creates containers to render hosted inputs with labels and error messages,
1867
1995
  // a card holder input with label and error, and a submit button.
1868
1996
  async getDefaultSkinCheckoutOptions() {
1869
1997
  const skinFactory = (await Promise.resolve().then(function () { return require('./chunk-index.cjs2.js'); }))
1870
1998
  .default;
1871
- const skin = await skinFactory(this.checkoutConfig);
1999
+ const skin = await skinFactory(this.checkoutConfig, this.cardSessionFieldConfig);
1872
2000
  this.on(EVENTS.INPUT_ERROR, skin.onInputError);
1873
2001
  this.on(EVENTS.STATUS_CHANGE, skin.onStatusChange);
1874
2002
  this.on(EVENTS.ERROR, (error) => skin.onError(error));
@@ -1884,7 +2012,7 @@ class CheckoutInstance extends EventEmitter {
1884
2012
  }
1885
2013
  async getCardDefaultSkinCheckoutOptions(node) {
1886
2014
  const CardSkin = (await Promise.resolve().then(function () { return require('./chunk-index.cjs3.js'); })).default;
1887
- const skin = new CardSkin(node, this.checkoutConfig);
2015
+ const skin = new CardSkin(node, this.checkoutConfig, this.cardSessionFieldConfig);
1888
2016
  skin.init();
1889
2017
  this.on(EVENTS.INPUT_ERROR, skin.onInputError);
1890
2018
  this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
@@ -1901,7 +2029,7 @@ class CheckoutInstance extends EventEmitter {
1901
2029
  async initMethod(method, element, callbacks) {
1902
2030
  this._ensureNotDestroyed();
1903
2031
  if (!this.isReady()) {
1904
- await this.createSession(method);
2032
+ await this.createSession();
1905
2033
  }
1906
2034
  if (callbacks.onRenderSuccess) {
1907
2035
  this.on(EVENTS.METHOD_RENDER, callbacks.onRenderSuccess);
@@ -1945,6 +2073,8 @@ class CheckoutInstance extends EventEmitter {
1945
2073
  onSubmit: this.handleSubmit,
1946
2074
  onInputChange: this.handleInputChange,
1947
2075
  onCardInputValueChange: this.handleCardInputValueChange,
2076
+ isCardholderNameRequired: () => this.isCardholderNameRequired(),
2077
+ isPostalCodeRequired: () => this.isPostalCodeVisible(),
1948
2078
  onMethodRender: this.handleMethodRender,
1949
2079
  onMethodRenderError: this.handleMethodRenderError,
1950
2080
  };
@@ -29,7 +29,7 @@ const paymentMethodTemplates = {
29
29
  [index.PaymentMethod.APPLE_PAY]: applePayTemplate,
30
30
  };
31
31
  class DefaultSkin {
32
- constructor(checkoutConfig) {
32
+ constructor(checkoutConfig, cardSessionFieldConfig) {
33
33
  this.onLoaderChange = (isLoading) => {
34
34
  document
35
35
  .querySelectorAll(`${this.containerSelector} .loader-container`)
@@ -118,6 +118,7 @@ class DefaultSkin {
118
118
  }
119
119
  this.containerEl = containerEl;
120
120
  this.checkoutConfig = checkoutConfig;
121
+ this.cardSessionFieldConfig = cardSessionFieldConfig;
121
122
  }
122
123
  initAccordion() {
123
124
  const paymentMethodCards = this.containerEl.querySelectorAll('.ff-payment-method-card');
@@ -166,7 +167,7 @@ class DefaultSkin {
166
167
  this.paymentMethodOrder.forEach(paymentMethod => {
167
168
  paymentMethodContainers.insertAdjacentHTML('beforeend', paymentMethodTemplates[paymentMethod]);
168
169
  });
169
- this.cardInstance = new index$1.default(document.querySelector('#cardForm'), this.checkoutConfig);
170
+ this.cardInstance = new index$1.default(document.querySelector('#cardForm'), this.checkoutConfig, this.cardSessionFieldConfig);
170
171
  this.cardInstance.init();
171
172
  this.wireCardInputs();
172
173
  }
@@ -197,8 +198,8 @@ class DefaultSkin {
197
198
  };
198
199
  }
199
200
  }
200
- const createDefaultSkin = async (checkoutConfig) => {
201
- const skin = new DefaultSkin(checkoutConfig);
201
+ const createDefaultSkin = async (checkoutConfig, cardSessionFieldConfig) => {
202
+ const skin = new DefaultSkin(checkoutConfig, cardSessionFieldConfig);
202
203
  await skin['init']();
203
204
  return skin;
204
205
  };
@@ -7,12 +7,12 @@
7
7
  */
8
8
  'use strict';
9
9
 
10
- 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";
10
+ 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";
11
11
 
12
- 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 }";
12
+ 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 }";
13
13
 
14
14
  class CardSkin {
15
- constructor(containerEl, checkoutConfig) {
15
+ constructor(containerEl, checkoutConfig, cardSessionFieldConfig) {
16
16
  this.onInputError = (event) => {
17
17
  const { name, error } = event;
18
18
  const cardInputElements = this.getCardInputElements();
@@ -22,15 +22,20 @@ class CardSkin {
22
22
  cvv: cardInputElements.cvv.parentElement,
23
23
  cardholderName: cardInputElements.cardholderName?.parentElement,
24
24
  emailAddress: cardInputElements.emailAddress?.parentElement,
25
+ postalCode: cardInputElements.postalCode?.parentElement,
25
26
  };
26
27
  const errorContainer = elementsMap[name]?.querySelector('.errorContainer');
27
28
  if (errorContainer) {
28
29
  errorContainer.textContent = error || '';
29
30
  }
30
- if (name === 'cardholderName' || name === 'emailAddress') {
31
+ if (name === 'cardholderName' ||
32
+ name === 'emailAddress' ||
33
+ name === 'postalCode') {
31
34
  const field = name === 'cardholderName'
32
35
  ? cardInputElements.cardholderName
33
- : cardInputElements.emailAddress;
36
+ : name === 'emailAddress'
37
+ ? cardInputElements.emailAddress
38
+ : cardInputElements.postalCode;
34
39
  if (error) {
35
40
  field?.classList?.add('error');
36
41
  }
@@ -52,21 +57,92 @@ class CardSkin {
52
57
  }
53
58
  this.containerEl = containerEl;
54
59
  this.checkoutConfig = checkoutConfig;
60
+ this.cardSessionFieldConfig = cardSessionFieldConfig;
55
61
  this.containerEl.style.display = 'none';
56
62
  }
63
+ normalizeCountryCode(countryCode) {
64
+ const normalized = countryCode?.trim().toUpperCase();
65
+ return normalized || undefined;
66
+ }
67
+ getSelectedCountryCode() {
68
+ const selector = this.containerEl.querySelector('#countrySelectorInput');
69
+ return (this.normalizeCountryCode(selector?.value) ||
70
+ this.normalizeCountryCode(this.cardSessionFieldConfig?.detectedCountryCode));
71
+ }
72
+ getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
73
+ if (!countryCode) {
74
+ return undefined;
75
+ }
76
+ return this.cardSessionFieldConfig?.countryFieldOverrides?.[countryCode];
77
+ }
78
+ isCountrySelectorVisible() {
79
+ return !!this.cardSessionFieldConfig?.showCountrySelector;
80
+ }
81
+ isCardholderNameVisible() {
82
+ return !!this.checkoutConfig.card?.cardholderName?.required;
83
+ }
84
+ isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
85
+ const defaultVisible = !!this.cardSessionFieldConfig?.showPostalCode;
86
+ const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
87
+ if (overrideValue === null || overrideValue === undefined) {
88
+ return defaultVisible;
89
+ }
90
+ return overrideValue;
91
+ }
92
+ setFieldVisibility(inputId, isVisible) {
93
+ const field = this.containerEl.querySelector(`#${inputId}`);
94
+ if (field?.parentElement) {
95
+ field.parentElement.style.display = isVisible ? '' : 'none';
96
+ }
97
+ }
98
+ setContainerVisibility(containerId, isVisible) {
99
+ const container = this.containerEl.querySelector(`#${containerId}`);
100
+ if (container) {
101
+ container.style.display = isVisible ? '' : 'none';
102
+ }
103
+ }
104
+ populateCountrySelector(selectEl) {
105
+ const validCountries = this.cardSessionFieldConfig?.validCountries || [];
106
+ const selectedCountryCode = this.getSelectedCountryCode();
107
+ selectEl.innerHTML = '';
108
+ selectEl.disabled = false;
109
+ if (!validCountries.length) {
110
+ const fallbackOption = document.createElement('option');
111
+ fallbackOption.value = selectedCountryCode || '';
112
+ fallbackOption.textContent = selectedCountryCode
113
+ ? `Detected country: ${selectedCountryCode}`
114
+ : 'Country unavailable';
115
+ selectEl.appendChild(fallbackOption);
116
+ selectEl.disabled = true;
117
+ return;
118
+ }
119
+ const placeholderOption = document.createElement('option');
120
+ placeholderOption.value = '';
121
+ placeholderOption.textContent = 'Select country';
122
+ selectEl.appendChild(placeholderOption);
123
+ validCountries.forEach(country => {
124
+ const option = document.createElement('option');
125
+ option.value = country.code;
126
+ option.textContent = country.name;
127
+ selectEl.appendChild(option);
128
+ });
129
+ if (selectedCountryCode) {
130
+ selectEl.value = selectedCountryCode;
131
+ }
132
+ }
133
+ updateDynamicFieldVisibility(countryCode = this.getSelectedCountryCode()) {
134
+ this.setFieldVisibility('cardHolderInput', this.isCardholderNameVisible());
135
+ this.setFieldVisibility('postalCodeInput', this.isPostalCodeVisible(countryCode));
136
+ const postalCodeInput = this.containerEl.querySelector('#postalCodeInput');
137
+ if (!this.isPostalCodeVisible(countryCode) && postalCodeInput) {
138
+ postalCodeInput.value = '';
139
+ }
140
+ }
57
141
  wireCardInputs() {
58
142
  const cardNumber = this.containerEl.querySelector('#cardNumberInput');
59
143
  const expiryDate = this.containerEl.querySelector('#expiryInput');
60
144
  const cvv = this.containerEl.querySelector('#cvvInput');
61
- const hasCardholderInput = !!this.checkoutConfig?.card?.cardholderName?.required;
62
- let cardholderName = undefined;
63
- if (hasCardholderInput) {
64
- cardholderName =
65
- this.containerEl.querySelector('#cardHolderInput');
66
- }
67
- else {
68
- this.containerEl.querySelector('#cardHolderInput').parentElement.style.display = 'none';
69
- }
145
+ const cardholderName = this.containerEl.querySelector('#cardHolderInput');
70
146
  const hasEmailInput = !!this.checkoutConfig?.card?.emailAddress?.visible;
71
147
  let emailAddress = undefined;
72
148
  if (hasEmailInput) {
@@ -79,11 +155,23 @@ class CardSkin {
79
155
  else {
80
156
  this.containerEl.querySelector('#emailAddressInput').parentElement.style.display = 'none';
81
157
  }
158
+ const countrySelector = this.containerEl.querySelector('#countrySelectorInput');
159
+ const postalCode = this.containerEl.querySelector('#postalCodeInput');
160
+ if (countrySelector) {
161
+ this.populateCountrySelector(countrySelector);
162
+ countrySelector.addEventListener('change', () => {
163
+ this.updateDynamicFieldVisibility(this.normalizeCountryCode(countrySelector.value));
164
+ });
165
+ }
166
+ this.setContainerVisibility('countrySelectorField', this.isCountrySelectorVisible());
167
+ this.updateDynamicFieldVisibility();
82
168
  if (!cardNumber ||
83
169
  !expiryDate ||
84
170
  !cvv ||
85
- (hasCardholderInput && !cardholderName) ||
86
- (hasEmailInput && !emailAddress)) {
171
+ !cardholderName ||
172
+ (hasEmailInput && !emailAddress) ||
173
+ !countrySelector ||
174
+ !postalCode) {
87
175
  throw new Error('One or more card input elements are missing in the default skin');
88
176
  }
89
177
  this.cardInputElements = {
@@ -92,6 +180,8 @@ class CardSkin {
92
180
  cvv,
93
181
  cardholderName,
94
182
  emailAddress,
183
+ countrySelector,
184
+ postalCode,
95
185
  };
96
186
  }
97
187
  async init() {
@@ -107,11 +197,6 @@ class CardSkin {
107
197
  getCheckoutOptions() {
108
198
  return {
109
199
  cardElements: this.getCardInputElements(),
110
- card: {
111
- cardholderName: {
112
- required: !!this.checkoutConfig?.card?.cardholderName?.required,
113
- },
114
- },
115
200
  };
116
201
  }
117
202
  }