@funnelfox/billing 0.6.4 → 0.6.5-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-index.cjs.js +145 -12
- package/dist/chunk-index.cjs2.js +5 -4
- package/dist/chunk-index.cjs3.js +93 -15
- package/dist/chunk-index.es.js +145 -12
- package/dist/chunk-index.es2.js +5 -4
- package/dist/chunk-index.es3.js +93 -15
- package/dist/funnelfox-billing.js +243 -31
- package/dist/funnelfox-billing.min.js +1 -1
- package/package.json +2 -2
- package/src/types.d.ts +24 -1
package/dist/chunk-index.cjs.js
CHANGED
|
@@ -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.
|
|
425
|
+
const SDK_VERSION = '0.6.5-beta.0';
|
|
426
426
|
const DEFAULTS = {
|
|
427
427
|
BASE_URL: 'https://billing.funnelfox.com',
|
|
428
428
|
REGION: 'default',
|
|
@@ -691,7 +691,7 @@ class PrimerWrapper {
|
|
|
691
691
|
throw new PrimerError('Failed to initialize Primer checkout', error);
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
|
-
async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, onMethodRenderError, onMethodRender, }) {
|
|
694
|
+
async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, isCardholderNameRequired, onMethodRenderError, onMethodRender, }) {
|
|
695
695
|
try {
|
|
696
696
|
if (!this.currentHeadless) {
|
|
697
697
|
throw new PrimerError('Headless checkout not found');
|
|
@@ -705,15 +705,18 @@ class PrimerWrapper {
|
|
|
705
705
|
const validateForm = async () => {
|
|
706
706
|
if (!pmManager)
|
|
707
707
|
return false;
|
|
708
|
-
const { valid
|
|
709
|
-
const
|
|
710
|
-
|
|
708
|
+
const { valid } = await pmManager.validate();
|
|
709
|
+
const cardholderName = elements.cardholderName?.value?.trim();
|
|
710
|
+
const cardHolderError = isCardholderNameRequired?.() && !cardholderName
|
|
711
|
+
? 'Please enter the cardholder name'
|
|
712
|
+
: null;
|
|
713
|
+
dispatchError('cardholderName', cardHolderError);
|
|
711
714
|
const emailAddress = elements.emailAddress?.value?.trim();
|
|
712
715
|
const emailError = emailAddress && !isValidEmail(emailAddress)
|
|
713
716
|
? 'Please enter a valid email address'
|
|
714
717
|
: null;
|
|
715
718
|
dispatchError('emailAddress', emailError);
|
|
716
|
-
return valid && !emailError;
|
|
719
|
+
return valid && !emailError && !cardHolderError;
|
|
717
720
|
};
|
|
718
721
|
const dispatchError = (inputName, error) => {
|
|
719
722
|
onInputChange(inputName, error);
|
|
@@ -736,8 +739,18 @@ class PrimerWrapper {
|
|
|
736
739
|
? 'Please enter a valid email address'
|
|
737
740
|
: null);
|
|
738
741
|
};
|
|
742
|
+
const countrySelectorOnChange = (e) => {
|
|
743
|
+
const countryCode = e.target.value.trim();
|
|
744
|
+
onCardInputValueChange?.('countryCode', countryCode);
|
|
745
|
+
};
|
|
746
|
+
const postalCodeOnChange = (e) => {
|
|
747
|
+
const postalCode = e.target.value.trim();
|
|
748
|
+
onCardInputValueChange?.('postalCode', postalCode);
|
|
749
|
+
};
|
|
739
750
|
elements.cardholderName?.addEventListener('input', cardHolderOnChange);
|
|
740
751
|
elements.emailAddress?.addEventListener('input', emailAddressOnChange);
|
|
752
|
+
elements.countrySelector?.addEventListener('change', countrySelectorOnChange);
|
|
753
|
+
elements.postalCode?.addEventListener('input', postalCodeOnChange);
|
|
741
754
|
cardNumberInput.addEventListener('change', onHostedInputChange('cardNumber'));
|
|
742
755
|
expiryInput.addEventListener('change', onHostedInputChange('expiryDate'));
|
|
743
756
|
cvvInput.addEventListener('change', onHostedInputChange('cvv'));
|
|
@@ -779,6 +792,8 @@ class PrimerWrapper {
|
|
|
779
792
|
pmManager.removeHostedInputs();
|
|
780
793
|
elements.cardholderName?.removeEventListener('input', cardHolderOnChange);
|
|
781
794
|
elements.emailAddress?.removeEventListener('input', emailAddressOnChange);
|
|
795
|
+
elements.countrySelector?.removeEventListener('change', countrySelectorOnChange);
|
|
796
|
+
elements.postalCode?.removeEventListener('input', postalCodeOnChange);
|
|
782
797
|
elements.button?.removeEventListener('click', onSubmitHandler);
|
|
783
798
|
};
|
|
784
799
|
this.destroyCallbacks.push(onDestroy);
|
|
@@ -797,6 +812,12 @@ class PrimerWrapper {
|
|
|
797
812
|
if (elements.emailAddress) {
|
|
798
813
|
elements.emailAddress.disabled = disabled;
|
|
799
814
|
}
|
|
815
|
+
if (elements.countrySelector) {
|
|
816
|
+
elements.countrySelector.disabled = disabled;
|
|
817
|
+
}
|
|
818
|
+
if (elements.postalCode) {
|
|
819
|
+
elements.postalCode.disabled = disabled;
|
|
820
|
+
}
|
|
800
821
|
},
|
|
801
822
|
submit: () => onSubmitHandler(),
|
|
802
823
|
destroy: () => {
|
|
@@ -819,7 +840,7 @@ class PrimerWrapper {
|
|
|
819
840
|
});
|
|
820
841
|
}
|
|
821
842
|
async renderCheckout(clientToken, checkoutOptions, checkoutRenderOptions) {
|
|
822
|
-
const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, } = checkoutRenderOptions;
|
|
843
|
+
const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, isCardholderNameRequired, } = checkoutRenderOptions;
|
|
823
844
|
await this.initializeHeadlessCheckout(clientToken, checkoutOptions);
|
|
824
845
|
onMethodsAvailable?.(this.availableMethods);
|
|
825
846
|
await Promise.all(this.availableMethods.map(method => {
|
|
@@ -832,6 +853,7 @@ class PrimerWrapper {
|
|
|
832
853
|
onMethodRender,
|
|
833
854
|
onMethodRenderError,
|
|
834
855
|
onCardInputValueChange,
|
|
856
|
+
isCardholderNameRequired,
|
|
835
857
|
});
|
|
836
858
|
}
|
|
837
859
|
else {
|
|
@@ -1046,6 +1068,12 @@ class APIClient {
|
|
|
1046
1068
|
if (params.email !== undefined) {
|
|
1047
1069
|
payload.email_address = params.email;
|
|
1048
1070
|
}
|
|
1071
|
+
if (params.countryCode !== undefined) {
|
|
1072
|
+
payload.country_code = params.countryCode;
|
|
1073
|
+
}
|
|
1074
|
+
if (params.postalCode !== undefined) {
|
|
1075
|
+
payload.postal_code = params.postalCode;
|
|
1076
|
+
}
|
|
1049
1077
|
return (await this.request(API_ENDPOINTS.CREATE_PAYMENT, {
|
|
1050
1078
|
method: 'POST',
|
|
1051
1079
|
body: JSON.stringify(payload),
|
|
@@ -1358,12 +1386,24 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1358
1386
|
super();
|
|
1359
1387
|
this.counter = 0;
|
|
1360
1388
|
this.radarSessionId = null;
|
|
1389
|
+
this.cardSessionFieldConfig = {};
|
|
1361
1390
|
this.handleInputChange = (inputName, error) => {
|
|
1362
1391
|
this.emit(EVENTS.INPUT_ERROR, { name: inputName, error });
|
|
1363
1392
|
};
|
|
1364
1393
|
this.handleCardInputValueChange = (inputName, value) => {
|
|
1365
1394
|
if (inputName === 'emailAddress') {
|
|
1366
1395
|
this.cardEmailAddress = value?.trim() || undefined;
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1398
|
+
if (inputName === 'countryCode') {
|
|
1399
|
+
this.cardCountryCode = this.normalizeCountryCode(value);
|
|
1400
|
+
if (!this.isPostalCodeVisible()) {
|
|
1401
|
+
this.cardPostalCode = undefined;
|
|
1402
|
+
}
|
|
1403
|
+
return;
|
|
1404
|
+
}
|
|
1405
|
+
if (inputName === 'postalCode') {
|
|
1406
|
+
this.cardPostalCode = value?.trim() || undefined;
|
|
1367
1407
|
}
|
|
1368
1408
|
};
|
|
1369
1409
|
this.handleMethodRender = (method) => {
|
|
@@ -1389,6 +1429,8 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1389
1429
|
orderId: this.orderId,
|
|
1390
1430
|
paymentMethodToken: paymentMethodTokenData.token,
|
|
1391
1431
|
email: this.getPaymentEmailAddress(),
|
|
1432
|
+
countryCode: this.getPaymentCountryCode(),
|
|
1433
|
+
postalCode: this.getPaymentPostalCode(),
|
|
1392
1434
|
clientMetadata: {
|
|
1393
1435
|
radarSessionId,
|
|
1394
1436
|
},
|
|
@@ -1461,6 +1503,8 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1461
1503
|
this.primerWrapper = new PrimerWrapper();
|
|
1462
1504
|
this.isDestroyed = false;
|
|
1463
1505
|
this.cardEmailAddress = this.checkoutConfig.customer.email;
|
|
1506
|
+
this.shouldApplySessionCardholderNameConfig =
|
|
1507
|
+
this.checkoutConfig.card?.cardholderName?.required === undefined;
|
|
1464
1508
|
this._setupCallbackBridges();
|
|
1465
1509
|
}
|
|
1466
1510
|
_setupCallbackBridges() {
|
|
@@ -1553,7 +1597,9 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1553
1597
|
this.clientToken = sessionData.clientToken;
|
|
1554
1598
|
}
|
|
1555
1599
|
applySessionCardFieldConfig(response) {
|
|
1556
|
-
const cardConfig =
|
|
1600
|
+
const cardConfig = {
|
|
1601
|
+
...(this.checkoutConfig.card || {}),
|
|
1602
|
+
};
|
|
1557
1603
|
if (cardConfig.emailAddress?.visible === undefined &&
|
|
1558
1604
|
response.data?.show_email_field !== undefined) {
|
|
1559
1605
|
cardConfig.emailAddress = {
|
|
@@ -1561,20 +1607,49 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1561
1607
|
visible: response.data.show_email_field,
|
|
1562
1608
|
};
|
|
1563
1609
|
}
|
|
1564
|
-
if (
|
|
1610
|
+
if (this.shouldApplySessionCardholderNameConfig &&
|
|
1565
1611
|
response.data?.show_cardholder_name_field !== undefined) {
|
|
1566
1612
|
cardConfig.cardholderName = {
|
|
1567
1613
|
...cardConfig.cardholderName,
|
|
1568
1614
|
required: response.data.show_cardholder_name_field,
|
|
1569
1615
|
};
|
|
1570
1616
|
}
|
|
1617
|
+
const countryFieldOverrides = this.normalizeCountryFieldOverrides(response.data?.country_field_overrides);
|
|
1618
|
+
const detectedCountryCode = this.normalizeCountryCode(response.data?.detected_country_code) ||
|
|
1619
|
+
this.cardCountryCode;
|
|
1620
|
+
this.cardSessionFieldConfig = {
|
|
1621
|
+
...this.cardSessionFieldConfig,
|
|
1622
|
+
showCountrySelector: response.data?.show_country_selector_field ??
|
|
1623
|
+
this.cardSessionFieldConfig.showCountrySelector,
|
|
1624
|
+
showPostalCode: response.data?.show_postal_code_field ??
|
|
1625
|
+
this.cardSessionFieldConfig.showPostalCode,
|
|
1626
|
+
detectedCountryCode: detectedCountryCode || this.cardSessionFieldConfig.detectedCountryCode,
|
|
1627
|
+
validCountries: response.data?.valid_countries ||
|
|
1628
|
+
this.cardSessionFieldConfig.validCountries,
|
|
1629
|
+
countryFieldOverrides: countryFieldOverrides ||
|
|
1630
|
+
this.cardSessionFieldConfig.countryFieldOverrides,
|
|
1631
|
+
applyCardholderNameOverrides: this.shouldApplySessionCardholderNameConfig,
|
|
1632
|
+
};
|
|
1571
1633
|
if (Object.keys(cardConfig).length > 0) {
|
|
1572
1634
|
this.checkoutConfig.card = cardConfig;
|
|
1573
1635
|
}
|
|
1636
|
+
this.cardCountryCode =
|
|
1637
|
+
this.cardSessionFieldConfig.detectedCountryCode || this.cardCountryCode;
|
|
1638
|
+
if (!this.isPostalCodeVisible()) {
|
|
1639
|
+
this.cardPostalCode = undefined;
|
|
1640
|
+
}
|
|
1574
1641
|
}
|
|
1575
1642
|
getPrimerCardConfig() {
|
|
1576
|
-
const cardConfig = {
|
|
1643
|
+
const cardConfig = {
|
|
1644
|
+
...(this.checkoutConfig.card || {}),
|
|
1645
|
+
};
|
|
1577
1646
|
delete cardConfig.emailAddress;
|
|
1647
|
+
if (cardConfig.cardholderName) {
|
|
1648
|
+
cardConfig.cardholderName = {
|
|
1649
|
+
...cardConfig.cardholderName,
|
|
1650
|
+
required: false,
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1578
1653
|
return Object.keys(cardConfig).length
|
|
1579
1654
|
? cardConfig
|
|
1580
1655
|
: undefined;
|
|
@@ -1694,6 +1769,7 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1694
1769
|
onSubmit: this.handleSubmit,
|
|
1695
1770
|
onInputChange: this.handleInputChange,
|
|
1696
1771
|
onCardInputValueChange: this.handleCardInputValueChange,
|
|
1772
|
+
isCardholderNameRequired: () => this.isCardholderNameRequired(),
|
|
1697
1773
|
onMethodRender: this.handleMethodRender,
|
|
1698
1774
|
onMethodsAvailable: this.handleMethodsAvailable,
|
|
1699
1775
|
onMethodRenderError: this.handleMethodRenderError,
|
|
@@ -1852,12 +1928,68 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1852
1928
|
isProcessing() {
|
|
1853
1929
|
return ['processing', 'action_required'].includes(this.state);
|
|
1854
1930
|
}
|
|
1931
|
+
normalizeCountryCode(countryCode) {
|
|
1932
|
+
const normalized = countryCode?.trim().toUpperCase();
|
|
1933
|
+
return normalized || undefined;
|
|
1934
|
+
}
|
|
1935
|
+
normalizeCountryFieldOverrides(overrides) {
|
|
1936
|
+
if (!overrides) {
|
|
1937
|
+
return undefined;
|
|
1938
|
+
}
|
|
1939
|
+
return Object.entries(overrides).reduce((result, [countryCode, override]) => {
|
|
1940
|
+
const normalizedCountryCode = this.normalizeCountryCode(countryCode);
|
|
1941
|
+
if (normalizedCountryCode && override) {
|
|
1942
|
+
result[normalizedCountryCode] = override;
|
|
1943
|
+
}
|
|
1944
|
+
return result;
|
|
1945
|
+
}, {});
|
|
1946
|
+
}
|
|
1947
|
+
getSelectedCountryCode() {
|
|
1948
|
+
return (this.normalizeCountryCode(this.cardCountryCode) ||
|
|
1949
|
+
this.normalizeCountryCode(this.cardSessionFieldConfig.detectedCountryCode));
|
|
1950
|
+
}
|
|
1951
|
+
getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
|
|
1952
|
+
if (!countryCode) {
|
|
1953
|
+
return undefined;
|
|
1954
|
+
}
|
|
1955
|
+
return this.cardSessionFieldConfig.countryFieldOverrides?.[countryCode];
|
|
1956
|
+
}
|
|
1957
|
+
isCardholderNameRequired(countryCode = this.getSelectedCountryCode()) {
|
|
1958
|
+
const defaultValue = !!this.checkoutConfig.card?.cardholderName?.required;
|
|
1959
|
+
const shouldApplyOverrides = this.cardSessionFieldConfig.applyCardholderNameOverrides &&
|
|
1960
|
+
this.shouldApplySessionCardholderNameConfig;
|
|
1961
|
+
if (!shouldApplyOverrides) {
|
|
1962
|
+
return defaultValue;
|
|
1963
|
+
}
|
|
1964
|
+
const overrideValue = this.getCountryFieldOverride(countryCode)?.show_cardholder_name;
|
|
1965
|
+
if (overrideValue === null || overrideValue === undefined) {
|
|
1966
|
+
return defaultValue;
|
|
1967
|
+
}
|
|
1968
|
+
return overrideValue;
|
|
1969
|
+
}
|
|
1970
|
+
isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
|
|
1971
|
+
const defaultValue = !!this.cardSessionFieldConfig.showPostalCode;
|
|
1972
|
+
const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
|
|
1973
|
+
if (overrideValue === null || overrideValue === undefined) {
|
|
1974
|
+
return defaultValue;
|
|
1975
|
+
}
|
|
1976
|
+
return overrideValue;
|
|
1977
|
+
}
|
|
1978
|
+
getPaymentCountryCode() {
|
|
1979
|
+
return this.getSelectedCountryCode();
|
|
1980
|
+
}
|
|
1981
|
+
getPaymentPostalCode() {
|
|
1982
|
+
if (!this.isPostalCodeVisible()) {
|
|
1983
|
+
return undefined;
|
|
1984
|
+
}
|
|
1985
|
+
return this.cardPostalCode?.trim() || undefined;
|
|
1986
|
+
}
|
|
1855
1987
|
// Creates containers to render hosted inputs with labels and error messages,
|
|
1856
1988
|
// a card holder input with label and error, and a submit button.
|
|
1857
1989
|
async getDefaultSkinCheckoutOptions() {
|
|
1858
1990
|
const skinFactory = (await Promise.resolve().then(function () { return require('./chunk-index.cjs2.js'); }))
|
|
1859
1991
|
.default;
|
|
1860
|
-
const skin = await skinFactory(this.checkoutConfig);
|
|
1992
|
+
const skin = await skinFactory(this.checkoutConfig, this.cardSessionFieldConfig);
|
|
1861
1993
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
1862
1994
|
this.on(EVENTS.STATUS_CHANGE, skin.onStatusChange);
|
|
1863
1995
|
this.on(EVENTS.ERROR, (error) => skin.onError(error));
|
|
@@ -1873,7 +2005,7 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1873
2005
|
}
|
|
1874
2006
|
async getCardDefaultSkinCheckoutOptions(node) {
|
|
1875
2007
|
const CardSkin = (await Promise.resolve().then(function () { return require('./chunk-index.cjs3.js'); })).default;
|
|
1876
|
-
const skin = new CardSkin(node, this.checkoutConfig);
|
|
2008
|
+
const skin = new CardSkin(node, this.checkoutConfig, this.cardSessionFieldConfig);
|
|
1877
2009
|
skin.init();
|
|
1878
2010
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
1879
2011
|
this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
|
|
@@ -1934,6 +2066,7 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1934
2066
|
onSubmit: this.handleSubmit,
|
|
1935
2067
|
onInputChange: this.handleInputChange,
|
|
1936
2068
|
onCardInputValueChange: this.handleCardInputValueChange,
|
|
2069
|
+
isCardholderNameRequired: () => this.isCardholderNameRequired(),
|
|
1937
2070
|
onMethodRender: this.handleMethodRender,
|
|
1938
2071
|
onMethodRenderError: this.handleMethodRenderError,
|
|
1939
2072
|
};
|
package/dist/chunk-index.cjs2.js
CHANGED
|
@@ -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
|
};
|
package/dist/chunk-index.cjs3.js
CHANGED
|
@@ -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=\"emailAddressInput\">Email</label>\n <input class=\"ff-card-form-text-input\" id=\"emailAddressInput\" placeholder=\"Email\" type=\"email\">\n <div class=\"errorContainer\"></div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"cardHolderInput\">Card holder</label>\n <input class=\"ff-card-form-text-input\" id=\"cardHolderInput\" placeholder=\"Card holder\">\n <div class=\"errorContainer\"></div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"countrySelectorInput\">Country</label>\n <div class=\"ff-select-wrap\">\n <select class=\"ff-card-form-text-input ff-card-form-select\" id=\"countrySelectorInput\"></select>\n <div class=\"ff-select-arrow\" aria-hidden=\"true\"></div>\n </div>\n</div>\n<div>\n <label class=\"ff-card-form-label\" for=\"postalCodeInput\">Postal code</label>\n <input class=\"ff-card-form-text-input\" id=\"postalCodeInput\" placeholder=\"Postal code\">\n</div>\n";
|
|
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-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();
|
|
@@ -52,21 +52,85 @@ class CardSkin {
|
|
|
52
52
|
}
|
|
53
53
|
this.containerEl = containerEl;
|
|
54
54
|
this.checkoutConfig = checkoutConfig;
|
|
55
|
+
this.cardSessionFieldConfig = cardSessionFieldConfig;
|
|
55
56
|
this.containerEl.style.display = 'none';
|
|
56
57
|
}
|
|
58
|
+
normalizeCountryCode(countryCode) {
|
|
59
|
+
const normalized = countryCode?.trim().toUpperCase();
|
|
60
|
+
return normalized || undefined;
|
|
61
|
+
}
|
|
62
|
+
getSelectedCountryCode() {
|
|
63
|
+
const selector = this.containerEl.querySelector('#countrySelectorInput');
|
|
64
|
+
return (this.normalizeCountryCode(selector?.value) ||
|
|
65
|
+
this.normalizeCountryCode(this.cardSessionFieldConfig?.detectedCountryCode));
|
|
66
|
+
}
|
|
67
|
+
getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
|
|
68
|
+
if (!countryCode) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
return this.cardSessionFieldConfig?.countryFieldOverrides?.[countryCode];
|
|
72
|
+
}
|
|
73
|
+
isCountrySelectorVisible() {
|
|
74
|
+
return !!(this.cardSessionFieldConfig?.showCountrySelector &&
|
|
75
|
+
this.cardSessionFieldConfig?.validCountries?.length);
|
|
76
|
+
}
|
|
77
|
+
isCardholderNameVisible(countryCode = this.getSelectedCountryCode()) {
|
|
78
|
+
const defaultVisible = !!this.checkoutConfig.card?.cardholderName?.required;
|
|
79
|
+
const shouldApplyOverrides = !!this.cardSessionFieldConfig?.applyCardholderNameOverrides;
|
|
80
|
+
if (!shouldApplyOverrides) {
|
|
81
|
+
return defaultVisible;
|
|
82
|
+
}
|
|
83
|
+
const overrideValue = this.getCountryFieldOverride(countryCode)?.show_cardholder_name;
|
|
84
|
+
if (overrideValue === null || overrideValue === undefined) {
|
|
85
|
+
return defaultVisible;
|
|
86
|
+
}
|
|
87
|
+
return overrideValue;
|
|
88
|
+
}
|
|
89
|
+
isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
|
|
90
|
+
const defaultVisible = !!this.cardSessionFieldConfig?.showPostalCode;
|
|
91
|
+
const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
|
|
92
|
+
if (overrideValue === null || overrideValue === undefined) {
|
|
93
|
+
return defaultVisible;
|
|
94
|
+
}
|
|
95
|
+
return overrideValue;
|
|
96
|
+
}
|
|
97
|
+
setFieldVisibility(inputId, isVisible) {
|
|
98
|
+
const field = this.containerEl.querySelector(`#${inputId}`);
|
|
99
|
+
if (field?.parentElement) {
|
|
100
|
+
field.parentElement.style.display = isVisible ? '' : 'none';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
populateCountrySelector(selectEl) {
|
|
104
|
+
const validCountries = this.cardSessionFieldConfig?.validCountries || [];
|
|
105
|
+
const selectedCountryCode = this.getSelectedCountryCode();
|
|
106
|
+
selectEl.innerHTML = '';
|
|
107
|
+
const placeholderOption = document.createElement('option');
|
|
108
|
+
placeholderOption.value = '';
|
|
109
|
+
placeholderOption.textContent = 'Select country';
|
|
110
|
+
selectEl.appendChild(placeholderOption);
|
|
111
|
+
validCountries.forEach(country => {
|
|
112
|
+
const option = document.createElement('option');
|
|
113
|
+
option.value = country.code;
|
|
114
|
+
option.textContent = country.name;
|
|
115
|
+
selectEl.appendChild(option);
|
|
116
|
+
});
|
|
117
|
+
if (selectedCountryCode) {
|
|
118
|
+
selectEl.value = selectedCountryCode;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
updateDynamicFieldVisibility(countryCode = this.getSelectedCountryCode()) {
|
|
122
|
+
this.setFieldVisibility('cardHolderInput', this.isCardholderNameVisible(countryCode));
|
|
123
|
+
this.setFieldVisibility('postalCodeInput', this.isPostalCodeVisible(countryCode));
|
|
124
|
+
const postalCodeInput = this.containerEl.querySelector('#postalCodeInput');
|
|
125
|
+
if (!this.isPostalCodeVisible(countryCode) && postalCodeInput) {
|
|
126
|
+
postalCodeInput.value = '';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
57
129
|
wireCardInputs() {
|
|
58
130
|
const cardNumber = this.containerEl.querySelector('#cardNumberInput');
|
|
59
131
|
const expiryDate = this.containerEl.querySelector('#expiryInput');
|
|
60
132
|
const cvv = this.containerEl.querySelector('#cvvInput');
|
|
61
|
-
const
|
|
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
|
-
}
|
|
133
|
+
const cardholderName = this.containerEl.querySelector('#cardHolderInput');
|
|
70
134
|
const hasEmailInput = !!this.checkoutConfig?.card?.emailAddress?.visible;
|
|
71
135
|
let emailAddress = undefined;
|
|
72
136
|
if (hasEmailInput) {
|
|
@@ -79,11 +143,23 @@ class CardSkin {
|
|
|
79
143
|
else {
|
|
80
144
|
this.containerEl.querySelector('#emailAddressInput').parentElement.style.display = 'none';
|
|
81
145
|
}
|
|
146
|
+
const countrySelector = this.containerEl.querySelector('#countrySelectorInput');
|
|
147
|
+
const postalCode = this.containerEl.querySelector('#postalCodeInput');
|
|
148
|
+
if (countrySelector) {
|
|
149
|
+
this.populateCountrySelector(countrySelector);
|
|
150
|
+
countrySelector.addEventListener('change', () => {
|
|
151
|
+
this.updateDynamicFieldVisibility(this.normalizeCountryCode(countrySelector.value));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
this.setFieldVisibility('countrySelectorInput', this.isCountrySelectorVisible());
|
|
155
|
+
this.updateDynamicFieldVisibility();
|
|
82
156
|
if (!cardNumber ||
|
|
83
157
|
!expiryDate ||
|
|
84
158
|
!cvv ||
|
|
85
|
-
|
|
86
|
-
(hasEmailInput && !emailAddress)
|
|
159
|
+
!cardholderName ||
|
|
160
|
+
(hasEmailInput && !emailAddress) ||
|
|
161
|
+
!countrySelector ||
|
|
162
|
+
!postalCode) {
|
|
87
163
|
throw new Error('One or more card input elements are missing in the default skin');
|
|
88
164
|
}
|
|
89
165
|
this.cardInputElements = {
|
|
@@ -92,6 +168,8 @@ class CardSkin {
|
|
|
92
168
|
cvv,
|
|
93
169
|
cardholderName,
|
|
94
170
|
emailAddress,
|
|
171
|
+
countrySelector,
|
|
172
|
+
postalCode,
|
|
95
173
|
};
|
|
96
174
|
}
|
|
97
175
|
async init() {
|
|
@@ -109,7 +187,7 @@ class CardSkin {
|
|
|
109
187
|
cardElements: this.getCardInputElements(),
|
|
110
188
|
card: {
|
|
111
189
|
cardholderName: {
|
|
112
|
-
required:
|
|
190
|
+
required: false,
|
|
113
191
|
},
|
|
114
192
|
},
|
|
115
193
|
};
|