@funnelfox/billing 0.6.7 → 0.7.1-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 +283 -43
- package/dist/chunk-index.cjs2.js +5 -4
- package/dist/chunk-index.cjs3.js +106 -21
- package/dist/chunk-index.es.js +283 -43
- package/dist/chunk-index.es2.js +5 -4
- package/dist/chunk-index.es3.js +106 -21
- package/dist/funnelfox-billing.js +394 -68
- package/dist/funnelfox-billing.min.js +1 -1
- package/package.json +2 -2
- package/src/types.d.ts +28 -2
|
@@ -154,46 +154,64 @@
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
|
-
* @fileoverview
|
|
158
|
-
* Loads Primer script and CSS from CDN independently of bundler
|
|
157
|
+
* @fileoverview Generic script and stylesheet loader utility to reduce bundle size
|
|
159
158
|
*/
|
|
160
|
-
const PRIMER_CDN_BASE = 'https://sdk.primer.io/web';
|
|
161
|
-
const DEFAULT_VERSION = '2.57.3';
|
|
162
|
-
// Integrity hashes for specific versions (for SRI security)
|
|
163
|
-
const INTEGRITY_HASHES = {
|
|
164
|
-
'2.57.3': {
|
|
165
|
-
js: 'sha384-xq2SWkYvTlKOMpuXQUXq1QI3eZN7JiqQ3Sc72U9wY1IE30MW3HkwQWg/1n6BTMz4',
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
let loadingPromise = null;
|
|
169
|
-
let isLoaded = false;
|
|
170
159
|
/**
|
|
171
|
-
*
|
|
160
|
+
* Dynamically loads an external script into the document.
|
|
161
|
+
* Checks if script already exists before loading to prevent duplicates.
|
|
162
|
+
*
|
|
163
|
+
* @param options - Script configuration options
|
|
164
|
+
* @returns Promise that resolves when script is loaded or rejects on error
|
|
172
165
|
*/
|
|
173
|
-
function
|
|
166
|
+
function loadScript$1(options) {
|
|
167
|
+
const { id, src, async = true, type = 'text/javascript', attributes = {}, integrity, crossOrigin, appendTo = 'body', } = options;
|
|
174
168
|
return new Promise((resolve, reject) => {
|
|
175
|
-
// Check if script already exists
|
|
176
|
-
|
|
169
|
+
// Check if script already exists (by ID or src)
|
|
170
|
+
let existingScript = null;
|
|
171
|
+
if (id) {
|
|
172
|
+
existingScript = document.getElementById(id);
|
|
173
|
+
}
|
|
174
|
+
if (!existingScript) {
|
|
175
|
+
existingScript = document.querySelector(`script[src="${src}"]`);
|
|
176
|
+
}
|
|
177
177
|
if (existingScript) {
|
|
178
178
|
resolve(existingScript);
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
const script = document.createElement('script');
|
|
182
|
+
if (id) {
|
|
183
|
+
script.id = id;
|
|
184
|
+
}
|
|
185
|
+
script.type = type;
|
|
182
186
|
script.src = src;
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
if (async) {
|
|
188
|
+
script.async = true;
|
|
189
|
+
}
|
|
185
190
|
if (integrity) {
|
|
186
191
|
script.integrity = integrity;
|
|
187
192
|
}
|
|
193
|
+
if (crossOrigin) {
|
|
194
|
+
script.crossOrigin = crossOrigin;
|
|
195
|
+
}
|
|
196
|
+
// Set additional attributes
|
|
197
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
198
|
+
script.setAttribute(key, value);
|
|
199
|
+
});
|
|
188
200
|
script.onload = () => resolve(script);
|
|
189
|
-
script.onerror = () => reject(new Error(`Failed to load
|
|
190
|
-
document.head.
|
|
201
|
+
script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
|
|
202
|
+
const target = appendTo === 'head' ? document.head : document.body;
|
|
203
|
+
target.appendChild(script);
|
|
191
204
|
});
|
|
192
205
|
}
|
|
193
206
|
/**
|
|
194
|
-
*
|
|
207
|
+
* Dynamically loads an external stylesheet into the document head.
|
|
208
|
+
* Checks if stylesheet already exists before loading to prevent duplicates.
|
|
209
|
+
*
|
|
210
|
+
* @param options - Stylesheet configuration options
|
|
211
|
+
* @returns Promise that resolves when stylesheet is loaded or rejects on error
|
|
195
212
|
*/
|
|
196
|
-
function
|
|
213
|
+
function loadStylesheet(options) {
|
|
214
|
+
const { href, integrity, crossOrigin } = options;
|
|
197
215
|
return new Promise((resolve, reject) => {
|
|
198
216
|
// Check if stylesheet already exists
|
|
199
217
|
const existingLink = document.querySelector(`link[href="${href}"]`);
|
|
@@ -204,15 +222,32 @@
|
|
|
204
222
|
const link = document.createElement('link');
|
|
205
223
|
link.rel = 'stylesheet';
|
|
206
224
|
link.href = href;
|
|
207
|
-
link.crossOrigin = 'anonymous';
|
|
208
225
|
if (integrity) {
|
|
209
226
|
link.integrity = integrity;
|
|
210
227
|
}
|
|
228
|
+
if (crossOrigin) {
|
|
229
|
+
link.crossOrigin = crossOrigin;
|
|
230
|
+
}
|
|
211
231
|
link.onload = () => resolve(link);
|
|
212
|
-
link.onerror = () => reject(new Error(`Failed to load
|
|
232
|
+
link.onerror = () => reject(new Error(`Failed to load stylesheet: ${href}`));
|
|
213
233
|
document.head.appendChild(link);
|
|
214
234
|
});
|
|
215
235
|
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @fileoverview Dynamic loader for Primer SDK
|
|
239
|
+
* Loads Primer script and CSS from CDN independently of bundler
|
|
240
|
+
*/
|
|
241
|
+
const PRIMER_CDN_BASE = 'https://sdk.primer.io/web';
|
|
242
|
+
const DEFAULT_VERSION = '2.57.3';
|
|
243
|
+
// Integrity hashes for specific versions (for SRI security)
|
|
244
|
+
const INTEGRITY_HASHES = {
|
|
245
|
+
'2.57.3': {
|
|
246
|
+
js: 'sha384-xq2SWkYvTlKOMpuXQUXq1QI3eZN7JiqQ3Sc72U9wY1IE30MW3HkwQWg/1n6BTMz4',
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
let loadingPromise = null;
|
|
250
|
+
let isLoaded = false;
|
|
216
251
|
/**
|
|
217
252
|
* Waits for window.Primer to be available
|
|
218
253
|
*/
|
|
@@ -264,8 +299,17 @@
|
|
|
264
299
|
try {
|
|
265
300
|
// Load CSS and JS in parallel
|
|
266
301
|
await Promise.all([
|
|
267
|
-
|
|
268
|
-
|
|
302
|
+
loadStylesheet({
|
|
303
|
+
href: cssUrl,
|
|
304
|
+
integrity: hashes?.css,
|
|
305
|
+
crossOrigin: 'anonymous',
|
|
306
|
+
}),
|
|
307
|
+
loadScript$1({
|
|
308
|
+
src: jsUrl,
|
|
309
|
+
integrity: hashes?.js,
|
|
310
|
+
crossOrigin: 'anonymous',
|
|
311
|
+
appendTo: 'head',
|
|
312
|
+
}),
|
|
269
313
|
]);
|
|
270
314
|
// Wait for Primer to be available on window
|
|
271
315
|
await waitForPrimer();
|
|
@@ -308,6 +352,28 @@
|
|
|
308
352
|
const random = Math.random().toString(36).substr(2, 5);
|
|
309
353
|
return `${prefix}${timestamp}_${random}`;
|
|
310
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Generates a UUID v4 compliant string (RFC 4122).
|
|
357
|
+
* Meets Airwallex requirements:
|
|
358
|
+
* - Maximum 128 characters (UUID is 36 chars)
|
|
359
|
+
* - Only contains: a-z, A-Z, 0-9, underscore, hyphen
|
|
360
|
+
* - No prefix + timestamp pattern
|
|
361
|
+
* - Not a short series of numbers
|
|
362
|
+
*
|
|
363
|
+
* @returns UUID v4 string (e.g., "a3bb189e-8bf9-3888-9912-ace4e6543002")
|
|
364
|
+
*/
|
|
365
|
+
function generateUUID() {
|
|
366
|
+
// Use crypto.randomUUID if available (modern browsers)
|
|
367
|
+
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
368
|
+
return crypto.randomUUID();
|
|
369
|
+
}
|
|
370
|
+
// Fallback: manual UUID v4 generation
|
|
371
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
372
|
+
const r = (Math.random() * 16) | 0;
|
|
373
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
374
|
+
return v.toString(16);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
311
377
|
function sleep(ms) {
|
|
312
378
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
313
379
|
}
|
|
@@ -426,7 +492,7 @@
|
|
|
426
492
|
/**
|
|
427
493
|
* @fileoverview Constants for Funnefox SDK
|
|
428
494
|
*/
|
|
429
|
-
const SDK_VERSION = '0.
|
|
495
|
+
const SDK_VERSION = '0.7.1-beta.0';
|
|
430
496
|
const DEFAULTS = {
|
|
431
497
|
BASE_URL: 'https://billing.funnelfox.com',
|
|
432
498
|
REGION: 'default',
|
|
@@ -677,6 +743,8 @@
|
|
|
677
743
|
onMethodRenderError: options.onMethodRenderError,
|
|
678
744
|
onMethodRender: options.onMethodRender,
|
|
679
745
|
onCardInputValueChange: options.onCardInputValueChange,
|
|
746
|
+
isCardholderNameRequired: options.isCardholderNameRequired,
|
|
747
|
+
isPostalCodeRequired: options.isPostalCodeRequired,
|
|
680
748
|
});
|
|
681
749
|
this.paymentMethodsInterfaces.push(cardInterface);
|
|
682
750
|
return cardInterface;
|
|
@@ -695,7 +763,7 @@
|
|
|
695
763
|
throw new PrimerError('Failed to initialize Primer checkout', error);
|
|
696
764
|
}
|
|
697
765
|
}
|
|
698
|
-
async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, onMethodRenderError, onMethodRender, }) {
|
|
766
|
+
async renderCardCheckoutWithElements(elements, { onSubmit, onInputChange, onCardInputValueChange, isCardholderNameRequired, isPostalCodeRequired, onMethodRenderError, onMethodRender, }) {
|
|
699
767
|
try {
|
|
700
768
|
if (!this.currentHeadless) {
|
|
701
769
|
throw new PrimerError('Headless checkout not found');
|
|
@@ -711,8 +779,10 @@
|
|
|
711
779
|
if (!pmManager)
|
|
712
780
|
return false;
|
|
713
781
|
const { valid, validationErrors } = await pmManager.validate();
|
|
714
|
-
const cardHolderError =
|
|
715
|
-
|
|
782
|
+
const cardHolderError = isCardholderNameRequired?.()
|
|
783
|
+
? validationErrors.find(v => v.name === 'cardholderName')?.message
|
|
784
|
+
: null;
|
|
785
|
+
dispatchError('cardholderName', cardHolderError);
|
|
716
786
|
let emailError = null;
|
|
717
787
|
if (hasEmail) {
|
|
718
788
|
const emailAddress = elements.emailAddress?.value?.trim();
|
|
@@ -721,11 +791,19 @@
|
|
|
721
791
|
: null;
|
|
722
792
|
dispatchError('emailAddress', emailError);
|
|
723
793
|
}
|
|
724
|
-
|
|
794
|
+
const postalCodeError = getPostalCodeError();
|
|
795
|
+
dispatchError('postalCode', postalCodeError);
|
|
796
|
+
return valid && !emailError && !cardHolderError && !postalCodeError;
|
|
725
797
|
};
|
|
726
798
|
const dispatchError = (inputName, error) => {
|
|
727
799
|
onInputChange(inputName, error);
|
|
728
800
|
};
|
|
801
|
+
const getPostalCodeError = () => {
|
|
802
|
+
const postalCode = elements.postalCode?.value?.trim();
|
|
803
|
+
return isPostalCodeRequired?.() && !postalCode
|
|
804
|
+
? 'Please enter a postal code'
|
|
805
|
+
: null;
|
|
806
|
+
};
|
|
729
807
|
const onHostedInputChange = (name) => (event) => {
|
|
730
808
|
const input = event;
|
|
731
809
|
if (input.submitted) {
|
|
@@ -748,7 +826,22 @@
|
|
|
748
826
|
};
|
|
749
827
|
elements.emailAddress.addEventListener('input', emailAddressOnChange);
|
|
750
828
|
}
|
|
829
|
+
const countrySelectorOnChange = (e) => {
|
|
830
|
+
const countryCode = e.target.value.trim();
|
|
831
|
+
onCardInputValueChange?.('countryCode', countryCode);
|
|
832
|
+
if (!isPostalCodeRequired?.()) {
|
|
833
|
+
dispatchError('postalCode', null);
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
const postalCodeOnChange = (e) => {
|
|
837
|
+
const postalCode = e.target.value.trim();
|
|
838
|
+
onCardInputValueChange?.('postalCode', postalCode);
|
|
839
|
+
dispatchError('postalCode', getPostalCodeError());
|
|
840
|
+
};
|
|
751
841
|
elements.cardholderName?.addEventListener('input', cardHolderOnChange);
|
|
842
|
+
elements.emailAddress?.addEventListener('input', emailAddressOnChange);
|
|
843
|
+
elements.countrySelector?.addEventListener('change', countrySelectorOnChange);
|
|
844
|
+
elements.postalCode?.addEventListener('input', postalCodeOnChange);
|
|
752
845
|
cardNumberInput.addEventListener('change', onHostedInputChange('cardNumber'));
|
|
753
846
|
expiryInput.addEventListener('change', onHostedInputChange('expiryDate'));
|
|
754
847
|
cvvInput.addEventListener('change', onHostedInputChange('cvv'));
|
|
@@ -791,6 +884,8 @@
|
|
|
791
884
|
pmManager.removeHostedInputs();
|
|
792
885
|
elements.cardholderName?.removeEventListener('input', cardHolderOnChange);
|
|
793
886
|
elements.emailAddress?.removeEventListener('input', emailAddressOnChange);
|
|
887
|
+
elements.countrySelector?.removeEventListener('change', countrySelectorOnChange);
|
|
888
|
+
elements.postalCode?.removeEventListener('input', postalCodeOnChange);
|
|
794
889
|
elements.button?.removeEventListener('click', onSubmitHandler);
|
|
795
890
|
};
|
|
796
891
|
this.destroyCallbacks.push(onDestroy);
|
|
@@ -809,6 +904,12 @@
|
|
|
809
904
|
if (elements.emailAddress) {
|
|
810
905
|
elements.emailAddress.disabled = disabled;
|
|
811
906
|
}
|
|
907
|
+
if (elements.countrySelector) {
|
|
908
|
+
elements.countrySelector.disabled = disabled;
|
|
909
|
+
}
|
|
910
|
+
if (elements.postalCode) {
|
|
911
|
+
elements.postalCode.disabled = disabled;
|
|
912
|
+
}
|
|
812
913
|
},
|
|
813
914
|
submit: () => onSubmitHandler(),
|
|
814
915
|
destroy: () => {
|
|
@@ -831,7 +932,7 @@
|
|
|
831
932
|
}, method);
|
|
832
933
|
}
|
|
833
934
|
async renderCheckout(clientToken, checkoutOptions, checkoutRenderOptions) {
|
|
834
|
-
const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, } = checkoutRenderOptions;
|
|
935
|
+
const { cardElements, paymentButtonElements, container, onSubmit, onInputChange, onMethodRender, onMethodRenderError, onMethodsAvailable, onCardInputValueChange, isCardholderNameRequired, isPostalCodeRequired, } = checkoutRenderOptions;
|
|
835
936
|
await this.initializeHeadlessCheckout(clientToken, checkoutOptions);
|
|
836
937
|
onMethodsAvailable?.(this.availableMethods);
|
|
837
938
|
await Promise.all(this.availableMethods.map(method => {
|
|
@@ -844,6 +945,8 @@
|
|
|
844
945
|
onMethodRender,
|
|
845
946
|
onMethodRenderError,
|
|
846
947
|
onCardInputValueChange,
|
|
948
|
+
isCardholderNameRequired,
|
|
949
|
+
isPostalCodeRequired,
|
|
847
950
|
});
|
|
848
951
|
}
|
|
849
952
|
else {
|
|
@@ -1058,6 +1161,12 @@
|
|
|
1058
1161
|
if (params.email !== undefined) {
|
|
1059
1162
|
payload.email_address = params.email;
|
|
1060
1163
|
}
|
|
1164
|
+
if (params.countryCode !== undefined) {
|
|
1165
|
+
payload.country_code = params.countryCode;
|
|
1166
|
+
}
|
|
1167
|
+
if (params.postalCode !== undefined) {
|
|
1168
|
+
payload.postal_code = params.postalCode;
|
|
1169
|
+
}
|
|
1061
1170
|
return (await this.request(API_ENDPOINTS.CREATE_PAYMENT, {
|
|
1062
1171
|
method: 'POST',
|
|
1063
1172
|
body: JSON.stringify(payload),
|
|
@@ -1362,6 +1471,34 @@
|
|
|
1362
1471
|
}
|
|
1363
1472
|
};
|
|
1364
1473
|
|
|
1474
|
+
/**
|
|
1475
|
+
* @fileoverview Airwallex device fingerprinting script loader
|
|
1476
|
+
*/
|
|
1477
|
+
/**
|
|
1478
|
+
* Loads Airwallex device fingerprinting script for fraud prevention.
|
|
1479
|
+
* The script collects browser, screen, device, and interaction data.
|
|
1480
|
+
*
|
|
1481
|
+
* @param sessionId - Unique order session ID (UUID v4 format, max 128 chars)
|
|
1482
|
+
* @param isDemoMode - If true, uses demo environment URL for testing
|
|
1483
|
+
* @returns Promise that resolves when script is loaded
|
|
1484
|
+
*
|
|
1485
|
+
* @see https://www.airwallex.com/docs/payments/online-payments/native-api/device-fingerprinting
|
|
1486
|
+
*/
|
|
1487
|
+
async function loadAirwallexDeviceFingerprint(sessionId, isLivemode = true) {
|
|
1488
|
+
const scriptId = 'airwallex-fraud-api';
|
|
1489
|
+
const src = isLivemode
|
|
1490
|
+
? 'https://static.airwallex.com/webapp/fraud/device-fingerprint/index.js'
|
|
1491
|
+
: 'https://static-demo.airwallex.com/webapp/fraud/device-fingerprint/index.js';
|
|
1492
|
+
await loadScript$1({
|
|
1493
|
+
id: scriptId,
|
|
1494
|
+
src,
|
|
1495
|
+
async: true,
|
|
1496
|
+
attributes: {
|
|
1497
|
+
'data-order-session-id': sessionId,
|
|
1498
|
+
},
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1365
1502
|
/**
|
|
1366
1503
|
* @fileoverview Checkout instance manager for Funnefox SDK
|
|
1367
1504
|
*/
|
|
@@ -1370,6 +1507,8 @@
|
|
|
1370
1507
|
super();
|
|
1371
1508
|
this.counter = 0;
|
|
1372
1509
|
this.radarSessionId = null;
|
|
1510
|
+
this.airwallexDeviceId = null;
|
|
1511
|
+
this.cardSessionFieldConfig = {};
|
|
1373
1512
|
this.handleInputChange = (inputName, error) => {
|
|
1374
1513
|
this.emit(EVENTS.INPUT_ERROR, { name: inputName, error });
|
|
1375
1514
|
};
|
|
@@ -1387,6 +1526,17 @@
|
|
|
1387
1526
|
this.handleCardInputValueChange = (inputName, value) => {
|
|
1388
1527
|
if (inputName === 'emailAddress') {
|
|
1389
1528
|
this.cardEmailAddress = value?.trim() || undefined;
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
if (inputName === 'countryCode') {
|
|
1532
|
+
this.cardCountryCode = this.normalizeCountryCode(value);
|
|
1533
|
+
if (!this.isPostalCodeVisible()) {
|
|
1534
|
+
this.cardPostalCode = undefined;
|
|
1535
|
+
}
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
if (inputName === 'postalCode') {
|
|
1539
|
+
this.cardPostalCode = value?.trim() || undefined;
|
|
1390
1540
|
}
|
|
1391
1541
|
};
|
|
1392
1542
|
this.handleMethodRender = (method) => {
|
|
@@ -1407,13 +1557,19 @@
|
|
|
1407
1557
|
try {
|
|
1408
1558
|
this.onLoaderChangeWithRace(true);
|
|
1409
1559
|
this._setState('processing');
|
|
1410
|
-
const radarSessionId = await
|
|
1560
|
+
const [radarSessionId, airwallexDeviceId] = await Promise.all([
|
|
1561
|
+
this.radarSessionId,
|
|
1562
|
+
this.airwallexDeviceId,
|
|
1563
|
+
]);
|
|
1411
1564
|
const paymentResponse = await this.apiClient.createPayment({
|
|
1412
1565
|
orderId: this.orderId,
|
|
1413
1566
|
paymentMethodToken: paymentMethodTokenData.token,
|
|
1414
1567
|
email: this.getPaymentEmailAddress(),
|
|
1568
|
+
countryCode: this.getPaymentCountryCode(),
|
|
1569
|
+
postalCode: this.getPaymentPostalCode(),
|
|
1415
1570
|
clientMetadata: {
|
|
1416
1571
|
radarSessionId,
|
|
1572
|
+
airwallexDeviceId,
|
|
1417
1573
|
},
|
|
1418
1574
|
});
|
|
1419
1575
|
const result = this.apiClient.processPaymentResponse(paymentResponse);
|
|
@@ -1484,6 +1640,8 @@
|
|
|
1484
1640
|
this.primerWrapper = new PrimerWrapper();
|
|
1485
1641
|
this.isDestroyed = false;
|
|
1486
1642
|
this.cardEmailAddress = this.checkoutConfig.customer.email;
|
|
1643
|
+
this.shouldApplySessionCardholderNameConfig =
|
|
1644
|
+
this.checkoutConfig.card?.cardholderName?.required === undefined;
|
|
1487
1645
|
this._setupCallbackBridges();
|
|
1488
1646
|
}
|
|
1489
1647
|
_setupCallbackBridges() {
|
|
@@ -1523,7 +1681,7 @@
|
|
|
1523
1681
|
this.hideInitializingLoader();
|
|
1524
1682
|
}
|
|
1525
1683
|
}
|
|
1526
|
-
async createSession(
|
|
1684
|
+
async createSession() {
|
|
1527
1685
|
this.apiClient = new APIClient({
|
|
1528
1686
|
baseUrl: this.baseUrl || DEFAULTS.BASE_URL,
|
|
1529
1687
|
orgId: this.orgId,
|
|
@@ -1538,14 +1696,11 @@
|
|
|
1538
1696
|
clientMetadata: this.checkoutConfig.clientMetadata,
|
|
1539
1697
|
countryCode: this.checkoutConfig.customer.countryCode,
|
|
1540
1698
|
};
|
|
1541
|
-
this.sessionMethod = method;
|
|
1542
1699
|
const cacheKey = [
|
|
1543
|
-
//this.id,
|
|
1544
1700
|
this.orgId,
|
|
1545
1701
|
this.checkoutConfig.priceId,
|
|
1546
1702
|
this.checkoutConfig.customer.externalId,
|
|
1547
1703
|
this.checkoutConfig.customer.email,
|
|
1548
|
-
//method || 'default',
|
|
1549
1704
|
].join('-');
|
|
1550
1705
|
let sessionResponse;
|
|
1551
1706
|
// Return cached response if payload hasn't changed
|
|
@@ -1565,6 +1720,17 @@
|
|
|
1565
1720
|
.catch(() => '');
|
|
1566
1721
|
});
|
|
1567
1722
|
}
|
|
1723
|
+
// Initialize Airwallex device fingerprinting if enabled by backend
|
|
1724
|
+
if (response.data?.airwallex_risk_enabled) {
|
|
1725
|
+
const isLivemode = response.data?.is_livemode;
|
|
1726
|
+
const deviceId = generateUUID();
|
|
1727
|
+
this.airwallexDeviceId = loadAirwallexDeviceFingerprint(deviceId, isLivemode)
|
|
1728
|
+
.then(() => deviceId)
|
|
1729
|
+
.catch(() => {
|
|
1730
|
+
// Silently fail - return deviceId anyway
|
|
1731
|
+
return deviceId;
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1568
1734
|
this.isCollectingApplePayEmail =
|
|
1569
1735
|
!!response.data?.collect_apple_pay_email;
|
|
1570
1736
|
this.applySessionCardFieldConfig(response);
|
|
@@ -1579,7 +1745,9 @@
|
|
|
1579
1745
|
this.clientToken = sessionData.clientToken;
|
|
1580
1746
|
}
|
|
1581
1747
|
applySessionCardFieldConfig(response) {
|
|
1582
|
-
const cardConfig =
|
|
1748
|
+
const cardConfig = {
|
|
1749
|
+
...(this.checkoutConfig.card || {}),
|
|
1750
|
+
};
|
|
1583
1751
|
if (cardConfig.emailAddress?.visible === undefined &&
|
|
1584
1752
|
response.data?.show_email_field !== undefined) {
|
|
1585
1753
|
cardConfig.emailAddress = {
|
|
@@ -1587,19 +1755,41 @@
|
|
|
1587
1755
|
visible: response.data.show_email_field,
|
|
1588
1756
|
};
|
|
1589
1757
|
}
|
|
1590
|
-
if (
|
|
1758
|
+
if (this.shouldApplySessionCardholderNameConfig &&
|
|
1591
1759
|
response.data?.show_cardholder_name_field !== undefined) {
|
|
1592
1760
|
cardConfig.cardholderName = {
|
|
1593
1761
|
...cardConfig.cardholderName,
|
|
1594
1762
|
required: response.data.show_cardholder_name_field,
|
|
1595
1763
|
};
|
|
1596
1764
|
}
|
|
1765
|
+
const countryFieldOverrides = this.normalizeCountryFieldOverrides(response.data?.country_field_overrides);
|
|
1766
|
+
const detectedCountryCode = this.normalizeCountryCode(response.data?.detected_country_code) ||
|
|
1767
|
+
this.cardCountryCode;
|
|
1768
|
+
this.cardSessionFieldConfig = {
|
|
1769
|
+
...this.cardSessionFieldConfig,
|
|
1770
|
+
showCountrySelector: response.data?.show_country_selector_field ??
|
|
1771
|
+
this.cardSessionFieldConfig.showCountrySelector,
|
|
1772
|
+
showPostalCode: response.data?.show_postal_code_field ??
|
|
1773
|
+
this.cardSessionFieldConfig.showPostalCode,
|
|
1774
|
+
detectedCountryCode: detectedCountryCode || this.cardSessionFieldConfig.detectedCountryCode,
|
|
1775
|
+
validCountries: response.data?.valid_countries ||
|
|
1776
|
+
this.cardSessionFieldConfig.validCountries,
|
|
1777
|
+
countryFieldOverrides: countryFieldOverrides ||
|
|
1778
|
+
this.cardSessionFieldConfig.countryFieldOverrides,
|
|
1779
|
+
};
|
|
1597
1780
|
if (Object.keys(cardConfig).length > 0) {
|
|
1598
1781
|
this.checkoutConfig.card = cardConfig;
|
|
1599
1782
|
}
|
|
1783
|
+
this.cardCountryCode =
|
|
1784
|
+
this.cardSessionFieldConfig.detectedCountryCode || this.cardCountryCode;
|
|
1785
|
+
if (!this.isPostalCodeVisible()) {
|
|
1786
|
+
this.cardPostalCode = undefined;
|
|
1787
|
+
}
|
|
1600
1788
|
}
|
|
1601
1789
|
getPrimerCardConfig() {
|
|
1602
|
-
const cardConfig = {
|
|
1790
|
+
const cardConfig = {
|
|
1791
|
+
...(this.checkoutConfig.card || {}),
|
|
1792
|
+
};
|
|
1603
1793
|
delete cardConfig.emailAddress;
|
|
1604
1794
|
return Object.keys(cardConfig).length
|
|
1605
1795
|
? cardConfig
|
|
@@ -1709,6 +1899,8 @@
|
|
|
1709
1899
|
onSubmit: this.handleSubmit,
|
|
1710
1900
|
onInputChange: this.handleInputChange,
|
|
1711
1901
|
onCardInputValueChange: this.handleCardInputValueChange,
|
|
1902
|
+
isCardholderNameRequired: () => this.isCardholderNameRequired(),
|
|
1903
|
+
isPostalCodeRequired: () => this.isPostalCodeVisible(),
|
|
1712
1904
|
onMethodRender: this.handleMethodRender,
|
|
1713
1905
|
onMethodsAvailable: this.handleMethodsAvailable,
|
|
1714
1906
|
onMethodRenderError: this.handleMethodRenderError,
|
|
@@ -1867,12 +2059,58 @@
|
|
|
1867
2059
|
isProcessing() {
|
|
1868
2060
|
return ['processing', 'action_required'].includes(this.state);
|
|
1869
2061
|
}
|
|
2062
|
+
normalizeCountryCode(countryCode) {
|
|
2063
|
+
const normalized = countryCode?.trim().toUpperCase();
|
|
2064
|
+
return normalized || undefined;
|
|
2065
|
+
}
|
|
2066
|
+
normalizeCountryFieldOverrides(overrides) {
|
|
2067
|
+
if (!overrides) {
|
|
2068
|
+
return undefined;
|
|
2069
|
+
}
|
|
2070
|
+
return Object.entries(overrides).reduce((result, [countryCode, override]) => {
|
|
2071
|
+
const normalizedCountryCode = this.normalizeCountryCode(countryCode);
|
|
2072
|
+
if (normalizedCountryCode && override) {
|
|
2073
|
+
result[normalizedCountryCode] = override;
|
|
2074
|
+
}
|
|
2075
|
+
return result;
|
|
2076
|
+
}, {});
|
|
2077
|
+
}
|
|
2078
|
+
getSelectedCountryCode() {
|
|
2079
|
+
return (this.normalizeCountryCode(this.cardCountryCode) ||
|
|
2080
|
+
this.normalizeCountryCode(this.cardSessionFieldConfig.detectedCountryCode));
|
|
2081
|
+
}
|
|
2082
|
+
getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
|
|
2083
|
+
if (!countryCode) {
|
|
2084
|
+
return undefined;
|
|
2085
|
+
}
|
|
2086
|
+
return this.cardSessionFieldConfig.countryFieldOverrides?.[countryCode];
|
|
2087
|
+
}
|
|
2088
|
+
isCardholderNameRequired() {
|
|
2089
|
+
return !!this.checkoutConfig.card?.cardholderName?.required;
|
|
2090
|
+
}
|
|
2091
|
+
isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
|
|
2092
|
+
const defaultValue = !!this.cardSessionFieldConfig.showPostalCode;
|
|
2093
|
+
const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
|
|
2094
|
+
if (overrideValue === null || overrideValue === undefined) {
|
|
2095
|
+
return defaultValue;
|
|
2096
|
+
}
|
|
2097
|
+
return overrideValue;
|
|
2098
|
+
}
|
|
2099
|
+
getPaymentCountryCode() {
|
|
2100
|
+
return this.getSelectedCountryCode();
|
|
2101
|
+
}
|
|
2102
|
+
getPaymentPostalCode() {
|
|
2103
|
+
if (!this.isPostalCodeVisible()) {
|
|
2104
|
+
return undefined;
|
|
2105
|
+
}
|
|
2106
|
+
return this.cardPostalCode?.trim() || undefined;
|
|
2107
|
+
}
|
|
1870
2108
|
// Creates containers to render hosted inputs with labels and error messages,
|
|
1871
2109
|
// a card holder input with label and error, and a submit button.
|
|
1872
2110
|
async getDefaultSkinCheckoutOptions() {
|
|
1873
2111
|
const skinFactory = (await Promise.resolve().then(function () { return index; }))
|
|
1874
2112
|
.default;
|
|
1875
|
-
const skin = await skinFactory(this.checkoutConfig);
|
|
2113
|
+
const skin = await skinFactory(this.checkoutConfig, this.cardSessionFieldConfig);
|
|
1876
2114
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
1877
2115
|
this.on(EVENTS.STATUS_CHANGE, skin.onStatusChange);
|
|
1878
2116
|
this.on(EVENTS.ERROR, (error) => skin.onError(error));
|
|
@@ -1888,7 +2126,7 @@
|
|
|
1888
2126
|
}
|
|
1889
2127
|
async getCardDefaultSkinCheckoutOptions(node) {
|
|
1890
2128
|
const CardSkin = (await Promise.resolve().then(function () { return index$1; })).default;
|
|
1891
|
-
const skin = new CardSkin(node, this.checkoutConfig);
|
|
2129
|
+
const skin = new CardSkin(node, this.checkoutConfig, this.cardSessionFieldConfig);
|
|
1892
2130
|
skin.init();
|
|
1893
2131
|
this.on(EVENTS.INPUT_ERROR, skin.onInputError);
|
|
1894
2132
|
this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
|
|
@@ -1905,7 +2143,7 @@
|
|
|
1905
2143
|
async initMethod(method, element, callbacks) {
|
|
1906
2144
|
this._ensureNotDestroyed();
|
|
1907
2145
|
if (!this.isReady()) {
|
|
1908
|
-
await this.createSession(
|
|
2146
|
+
await this.createSession();
|
|
1909
2147
|
}
|
|
1910
2148
|
if (callbacks.onRenderSuccess) {
|
|
1911
2149
|
this.on(EVENTS.METHOD_RENDER, callbacks.onRenderSuccess);
|
|
@@ -1949,6 +2187,8 @@
|
|
|
1949
2187
|
onSubmit: this.handleSubmit,
|
|
1950
2188
|
onInputChange: this.handleInputChange,
|
|
1951
2189
|
onCardInputValueChange: this.handleCardInputValueChange,
|
|
2190
|
+
isCardholderNameRequired: () => this.isCardholderNameRequired(),
|
|
2191
|
+
isPostalCodeRequired: () => this.isPostalCodeVisible(),
|
|
1952
2192
|
onMethodRender: this.handleMethodRender,
|
|
1953
2193
|
onMethodRenderError: this.handleMethodRenderError,
|
|
1954
2194
|
};
|
|
@@ -2196,12 +2436,12 @@
|
|
|
2196
2436
|
|
|
2197
2437
|
if(typeof document!=="undefined")document.head.appendChild(document.createElement("style")).textContent="/* Main container */\n.ff-skin-default {\n display: flex;\n flex-direction: column;\n text-align: left;\n gap: 8px;\n width: 100%;\n max-width: 400px;\n margin: 0 auto;\n color: #000000;\n}\n\n/* Payment method cards */\n.ff-payment-method-card {\n display: none;\n border: 1px solid #e0e0e0;\n border-radius: 8px;\n background-color: #ffffff;\n padding: 20px;\n transition: border-color 0.2s ease;\n height: auto;\n box-shadow: 0px 0px 10px 0px #eee;\n}\n\n.ff-payment-method-card.visible {\n display: block;\n}\n\n.payment-errors-container {\n background-color: #d1000033;\n color: #d10000;\n font-size: 14px;\n padding: 16px 12px;\n border-radius: 8px;\n}\n.payment-errors-container:empty {\n display: none;\n}\n\n/* Label wrapper */\n.ff-payment-method-label {\n display: flex;\n align-items: flex-start;\n gap: 16px;\n cursor: pointer;\n width: 100%;\n}\n\n.ff-google-pay-header {\n align-items: center;\n}\n\n/* Custom radio button styling */\n.ff-payment-method-radio {\n appearance: none;\n -webkit-appearance: none;\n -moz-appearance: none;\n width: 24px;\n height: 24px;\n min-width: 24px;\n min-height: 24px;\n border: 1px solid #9e9e9e;\n border-radius: 50%;\n background-color: #ffffff;\n cursor: pointer;\n position: relative;\n margin: 0;\n flex-shrink: 0;\n transition: border-color 0.2s ease;\n}\n\n.ff-card-form-submit-button {\n display: block;\n cursor: pointer;\n width: 100%;\n padding: 16px 0;\n border-radius: 16px;\n background-color: #000000;\n color: #ffffff;\n border: none;\n font-size: 16px;\n margin: 12px 0 16px;\n}\n\n.ff-payment-method-radio:checked {\n border-color: #e32f41;\n background-color: #ffffff;\n}\n\n.ff-payment-method-radio:checked::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 16px;\n height: 16px;\n border-radius: 50%;\n background-color: #e32f41;\n}\n\n/* Payment method content */\n.ff-payment-method-content {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 16px;\n max-height: 0;\n height: 0;\n overflow: hidden;\n opacity: 0;\n transition:\n opacity 0.3s ease,\n margin-top 0.3s ease;\n margin-top: 0;\n}\n\n.ff-payment-method-card.expanded .ff-payment-method-content {\n max-height: 2000px;\n height: auto;\n opacity: 1;\n margin-top: 16px;\n}\n.ff-payment-method-card.expanded .ff-payment-method-label {\n margin-bottom: 16px;\n}\n\n/* Payment method header */\n.ff-payment-method-header {\n display: flex;\n align-items: center;\n}\n\n/* Google Pay Logo */\n.ff-google-pay-logo {\n display: flex;\n align-items: center;\n gap: 4px;\n font-weight: 500;\n font-size: 18px;\n}\n.ff-google-pay-logo img {\n height: 38px;\n}\n\n/* Payment features list */\n.ff-payment-features {\n list-style: none;\n padding: 0;\n margin: 0;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.ff-payment-feature {\n display: flex;\n align-items: baseline;\n text-align: left;\n gap: 8px;\n}\n\n.ff-checkmark-icon {\n width: 20px;\n height: 20px;\n min-width: 20px;\n color: #e32f41;\n flex-shrink: 0;\n margin-top: 2px;\n}\n\n.ff-payment-feature span {\n color: #333333;\n font-size: 14px;\n line-height: 1.5;\n}\n\n/* Google Pay button container */\n.ff-google-pay-button-container {\n display: flex;\n justify-content: center;\n}\n\n/* Security message */\n.ff-security-message {\n text-align: center;\n color: #999999;\n font-size: 14px;\n padding: 0;\n margin: 0\n}\n\n/* Card logos container */\n.ff-card-logos {\n display: flex;\n align-items: center;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n/* Card form container */\n.ff-card-form-container {\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.loader-container {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: rgba(255, 255, 255);\n z-index: 2;\n}\n\n.payment-button-loader {\n position: relative;\n height: 50px;\n}\n\n.loader {\n width: 24px;\n height: 24px;\n border: 4px solid #e32f41;\n border-top: 4px solid transparent;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n}\n\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n/* Responsive adjustments */\n@media (max-width: 768px) {\n .ff-payment-method-card {\n padding: 16px;\n }\n\n .ff-payment-method-label {\n gap: 12px;\n }\n\n .ff-card-logos {\n gap: 8px;\n }\n}\n\n.ff-payment-container {\n position: relative;\n}\n\n.success {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 16px;\n}\n";
|
|
2198
2438
|
|
|
2199
|
-
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";
|
|
2439
|
+
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";
|
|
2200
2440
|
|
|
2201
|
-
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 }";
|
|
2441
|
+
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 }";
|
|
2202
2442
|
|
|
2203
2443
|
class CardSkin {
|
|
2204
|
-
constructor(containerEl, checkoutConfig) {
|
|
2444
|
+
constructor(containerEl, checkoutConfig, cardSessionFieldConfig) {
|
|
2205
2445
|
this.onInputError = (event) => {
|
|
2206
2446
|
const { name, error } = event;
|
|
2207
2447
|
const cardInputElements = this.getCardInputElements();
|
|
@@ -2211,15 +2451,20 @@
|
|
|
2211
2451
|
cvv: cardInputElements.cvv.parentElement,
|
|
2212
2452
|
cardholderName: cardInputElements.cardholderName?.parentElement,
|
|
2213
2453
|
emailAddress: cardInputElements.emailAddress?.parentElement,
|
|
2454
|
+
postalCode: cardInputElements.postalCode?.parentElement,
|
|
2214
2455
|
};
|
|
2215
2456
|
const errorContainer = elementsMap[name]?.querySelector('.errorContainer');
|
|
2216
2457
|
if (errorContainer) {
|
|
2217
2458
|
errorContainer.textContent = error || '';
|
|
2218
2459
|
}
|
|
2219
|
-
if (name === 'cardholderName' ||
|
|
2460
|
+
if (name === 'cardholderName' ||
|
|
2461
|
+
name === 'emailAddress' ||
|
|
2462
|
+
name === 'postalCode') {
|
|
2220
2463
|
const field = name === 'cardholderName'
|
|
2221
2464
|
? cardInputElements.cardholderName
|
|
2222
|
-
:
|
|
2465
|
+
: name === 'emailAddress'
|
|
2466
|
+
? cardInputElements.emailAddress
|
|
2467
|
+
: cardInputElements.postalCode;
|
|
2223
2468
|
if (error) {
|
|
2224
2469
|
field?.classList?.add('error');
|
|
2225
2470
|
}
|
|
@@ -2241,21 +2486,92 @@
|
|
|
2241
2486
|
}
|
|
2242
2487
|
this.containerEl = containerEl;
|
|
2243
2488
|
this.checkoutConfig = checkoutConfig;
|
|
2489
|
+
this.cardSessionFieldConfig = cardSessionFieldConfig;
|
|
2244
2490
|
this.containerEl.style.display = 'none';
|
|
2245
2491
|
}
|
|
2492
|
+
normalizeCountryCode(countryCode) {
|
|
2493
|
+
const normalized = countryCode?.trim().toUpperCase();
|
|
2494
|
+
return normalized || undefined;
|
|
2495
|
+
}
|
|
2496
|
+
getSelectedCountryCode() {
|
|
2497
|
+
const selector = this.containerEl.querySelector('#countrySelectorInput');
|
|
2498
|
+
return (this.normalizeCountryCode(selector?.value) ||
|
|
2499
|
+
this.normalizeCountryCode(this.cardSessionFieldConfig?.detectedCountryCode));
|
|
2500
|
+
}
|
|
2501
|
+
getCountryFieldOverride(countryCode = this.getSelectedCountryCode()) {
|
|
2502
|
+
if (!countryCode) {
|
|
2503
|
+
return undefined;
|
|
2504
|
+
}
|
|
2505
|
+
return this.cardSessionFieldConfig?.countryFieldOverrides?.[countryCode];
|
|
2506
|
+
}
|
|
2507
|
+
isCountrySelectorVisible() {
|
|
2508
|
+
return !!this.cardSessionFieldConfig?.showCountrySelector;
|
|
2509
|
+
}
|
|
2510
|
+
isCardholderNameVisible() {
|
|
2511
|
+
return !!this.checkoutConfig.card?.cardholderName?.required;
|
|
2512
|
+
}
|
|
2513
|
+
isPostalCodeVisible(countryCode = this.getSelectedCountryCode()) {
|
|
2514
|
+
const defaultVisible = !!this.cardSessionFieldConfig?.showPostalCode;
|
|
2515
|
+
const overrideValue = this.getCountryFieldOverride(countryCode)?.show_postal_code;
|
|
2516
|
+
if (overrideValue === null || overrideValue === undefined) {
|
|
2517
|
+
return defaultVisible;
|
|
2518
|
+
}
|
|
2519
|
+
return overrideValue;
|
|
2520
|
+
}
|
|
2521
|
+
setFieldVisibility(inputId, isVisible) {
|
|
2522
|
+
const field = this.containerEl.querySelector(`#${inputId}`);
|
|
2523
|
+
if (field?.parentElement) {
|
|
2524
|
+
field.parentElement.style.display = isVisible ? '' : 'none';
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
setContainerVisibility(containerId, isVisible) {
|
|
2528
|
+
const container = this.containerEl.querySelector(`#${containerId}`);
|
|
2529
|
+
if (container) {
|
|
2530
|
+
container.style.display = isVisible ? '' : 'none';
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
populateCountrySelector(selectEl) {
|
|
2534
|
+
const validCountries = this.cardSessionFieldConfig?.validCountries || [];
|
|
2535
|
+
const selectedCountryCode = this.getSelectedCountryCode();
|
|
2536
|
+
selectEl.innerHTML = '';
|
|
2537
|
+
selectEl.disabled = false;
|
|
2538
|
+
if (!validCountries.length) {
|
|
2539
|
+
const fallbackOption = document.createElement('option');
|
|
2540
|
+
fallbackOption.value = selectedCountryCode || '';
|
|
2541
|
+
fallbackOption.textContent = selectedCountryCode
|
|
2542
|
+
? `Detected country: ${selectedCountryCode}`
|
|
2543
|
+
: 'Country unavailable';
|
|
2544
|
+
selectEl.appendChild(fallbackOption);
|
|
2545
|
+
selectEl.disabled = true;
|
|
2546
|
+
return;
|
|
2547
|
+
}
|
|
2548
|
+
const placeholderOption = document.createElement('option');
|
|
2549
|
+
placeholderOption.value = '';
|
|
2550
|
+
placeholderOption.textContent = 'Select country';
|
|
2551
|
+
selectEl.appendChild(placeholderOption);
|
|
2552
|
+
validCountries.forEach(country => {
|
|
2553
|
+
const option = document.createElement('option');
|
|
2554
|
+
option.value = country.code;
|
|
2555
|
+
option.textContent = country.name;
|
|
2556
|
+
selectEl.appendChild(option);
|
|
2557
|
+
});
|
|
2558
|
+
if (selectedCountryCode) {
|
|
2559
|
+
selectEl.value = selectedCountryCode;
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
updateDynamicFieldVisibility(countryCode = this.getSelectedCountryCode()) {
|
|
2563
|
+
this.setFieldVisibility('cardHolderInput', this.isCardholderNameVisible());
|
|
2564
|
+
this.setFieldVisibility('postalCodeInput', this.isPostalCodeVisible(countryCode));
|
|
2565
|
+
const postalCodeInput = this.containerEl.querySelector('#postalCodeInput');
|
|
2566
|
+
if (!this.isPostalCodeVisible(countryCode) && postalCodeInput) {
|
|
2567
|
+
postalCodeInput.value = '';
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2246
2570
|
wireCardInputs() {
|
|
2247
2571
|
const cardNumber = this.containerEl.querySelector('#cardNumberInput');
|
|
2248
2572
|
const expiryDate = this.containerEl.querySelector('#expiryInput');
|
|
2249
2573
|
const cvv = this.containerEl.querySelector('#cvvInput');
|
|
2250
|
-
const
|
|
2251
|
-
let cardholderName = undefined;
|
|
2252
|
-
if (hasCardholderInput) {
|
|
2253
|
-
cardholderName =
|
|
2254
|
-
this.containerEl.querySelector('#cardHolderInput');
|
|
2255
|
-
}
|
|
2256
|
-
else {
|
|
2257
|
-
this.containerEl.querySelector('#cardHolderInput').parentElement.style.display = 'none';
|
|
2258
|
-
}
|
|
2574
|
+
const cardholderName = this.containerEl.querySelector('#cardHolderInput');
|
|
2259
2575
|
const hasEmailInput = !!this.checkoutConfig?.card?.emailAddress?.visible;
|
|
2260
2576
|
let emailAddress = undefined;
|
|
2261
2577
|
if (hasEmailInput) {
|
|
@@ -2268,11 +2584,23 @@
|
|
|
2268
2584
|
else {
|
|
2269
2585
|
this.containerEl.querySelector('#emailAddressInput').parentElement.style.display = 'none';
|
|
2270
2586
|
}
|
|
2587
|
+
const countrySelector = this.containerEl.querySelector('#countrySelectorInput');
|
|
2588
|
+
const postalCode = this.containerEl.querySelector('#postalCodeInput');
|
|
2589
|
+
if (countrySelector) {
|
|
2590
|
+
this.populateCountrySelector(countrySelector);
|
|
2591
|
+
countrySelector.addEventListener('change', () => {
|
|
2592
|
+
this.updateDynamicFieldVisibility(this.normalizeCountryCode(countrySelector.value));
|
|
2593
|
+
});
|
|
2594
|
+
}
|
|
2595
|
+
this.setContainerVisibility('countrySelectorField', this.isCountrySelectorVisible());
|
|
2596
|
+
this.updateDynamicFieldVisibility();
|
|
2271
2597
|
if (!cardNumber ||
|
|
2272
2598
|
!expiryDate ||
|
|
2273
2599
|
!cvv ||
|
|
2274
|
-
|
|
2275
|
-
(hasEmailInput && !emailAddress)
|
|
2600
|
+
!cardholderName ||
|
|
2601
|
+
(hasEmailInput && !emailAddress) ||
|
|
2602
|
+
!countrySelector ||
|
|
2603
|
+
!postalCode) {
|
|
2276
2604
|
throw new Error('One or more card input elements are missing in the default skin');
|
|
2277
2605
|
}
|
|
2278
2606
|
this.cardInputElements = {
|
|
@@ -2281,6 +2609,8 @@
|
|
|
2281
2609
|
cvv,
|
|
2282
2610
|
cardholderName,
|
|
2283
2611
|
emailAddress,
|
|
2612
|
+
countrySelector,
|
|
2613
|
+
postalCode,
|
|
2284
2614
|
};
|
|
2285
2615
|
}
|
|
2286
2616
|
async init() {
|
|
@@ -2296,11 +2626,6 @@
|
|
|
2296
2626
|
getCheckoutOptions() {
|
|
2297
2627
|
return {
|
|
2298
2628
|
cardElements: this.getCardInputElements(),
|
|
2299
|
-
card: {
|
|
2300
|
-
cardholderName: {
|
|
2301
|
-
required: !!this.checkoutConfig?.card?.cardholderName?.required,
|
|
2302
|
-
},
|
|
2303
|
-
},
|
|
2304
2629
|
};
|
|
2305
2630
|
}
|
|
2306
2631
|
}
|
|
@@ -2317,7 +2642,7 @@
|
|
|
2317
2642
|
[exports.PaymentMethod.APPLE_PAY]: applePayTemplate,
|
|
2318
2643
|
};
|
|
2319
2644
|
class DefaultSkin {
|
|
2320
|
-
constructor(checkoutConfig) {
|
|
2645
|
+
constructor(checkoutConfig, cardSessionFieldConfig) {
|
|
2321
2646
|
this.onLoaderChange = (isLoading) => {
|
|
2322
2647
|
document
|
|
2323
2648
|
.querySelectorAll(`${this.containerSelector} .loader-container`)
|
|
@@ -2406,6 +2731,7 @@
|
|
|
2406
2731
|
}
|
|
2407
2732
|
this.containerEl = containerEl;
|
|
2408
2733
|
this.checkoutConfig = checkoutConfig;
|
|
2734
|
+
this.cardSessionFieldConfig = cardSessionFieldConfig;
|
|
2409
2735
|
}
|
|
2410
2736
|
initAccordion() {
|
|
2411
2737
|
const paymentMethodCards = this.containerEl.querySelectorAll('.ff-payment-method-card');
|
|
@@ -2454,7 +2780,7 @@
|
|
|
2454
2780
|
this.paymentMethodOrder.forEach(paymentMethod => {
|
|
2455
2781
|
paymentMethodContainers.insertAdjacentHTML('beforeend', paymentMethodTemplates[paymentMethod]);
|
|
2456
2782
|
});
|
|
2457
|
-
this.cardInstance = new CardSkin(document.querySelector('#cardForm'), this.checkoutConfig);
|
|
2783
|
+
this.cardInstance = new CardSkin(document.querySelector('#cardForm'), this.checkoutConfig, this.cardSessionFieldConfig);
|
|
2458
2784
|
this.cardInstance.init();
|
|
2459
2785
|
this.wireCardInputs();
|
|
2460
2786
|
}
|
|
@@ -2485,8 +2811,8 @@
|
|
|
2485
2811
|
};
|
|
2486
2812
|
}
|
|
2487
2813
|
}
|
|
2488
|
-
const createDefaultSkin = async (checkoutConfig) => {
|
|
2489
|
-
const skin = new DefaultSkin(checkoutConfig);
|
|
2814
|
+
const createDefaultSkin = async (checkoutConfig, cardSessionFieldConfig) => {
|
|
2815
|
+
const skin = new DefaultSkin(checkoutConfig, cardSessionFieldConfig);
|
|
2490
2816
|
await skin['init']();
|
|
2491
2817
|
return skin;
|
|
2492
2818
|
};
|