@funnelfox/billing 0.5.0-beta.4 → 0.5.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
CHANGED
|
@@ -94,6 +94,7 @@ class DefaultSkin {
|
|
|
94
94
|
this.onMethodsAvailable = (methods) => {
|
|
95
95
|
this.availableMethods = methods;
|
|
96
96
|
this.initAccordion();
|
|
97
|
+
methods.forEach(this.onMethodRender);
|
|
97
98
|
};
|
|
98
99
|
this.onStartPurchase = (paymentMethod) => {
|
|
99
100
|
this.currentPurchaseMethod = paymentMethod;
|
package/dist/chunk-index.es.js
CHANGED
|
@@ -92,6 +92,7 @@ class DefaultSkin {
|
|
|
92
92
|
this.onMethodsAvailable = (methods) => {
|
|
93
93
|
this.availableMethods = methods;
|
|
94
94
|
this.initAccordion();
|
|
95
|
+
methods.forEach(this.onMethodRender);
|
|
95
96
|
};
|
|
96
97
|
this.onStartPurchase = (paymentMethod) => {
|
|
97
98
|
this.currentPurchaseMethod = paymentMethod;
|
|
@@ -206,6 +206,132 @@ function withTimeout(promise, timeoutMs, message = 'Operation timed out') {
|
|
|
206
206
|
return Promise.race([promise, timeoutPromise]);
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
/**
|
|
210
|
+
* @fileoverview Dynamic loader for Primer SDK
|
|
211
|
+
* Loads Primer script and CSS from CDN independently of bundler
|
|
212
|
+
*/
|
|
213
|
+
const PRIMER_CDN_BASE = 'https://sdk.primer.io/web';
|
|
214
|
+
const DEFAULT_VERSION = '2.57.3';
|
|
215
|
+
// Integrity hashes for specific versions (for SRI security)
|
|
216
|
+
const INTEGRITY_HASHES = {
|
|
217
|
+
'2.57.3': {
|
|
218
|
+
js: 'sha384-xq2SWkYvTlKOMpuXQUXq1QI3eZN7JiqQ3Sc72U9wY1IE30MW3HkwQWg/1n6BTMz4',
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
let loadingPromise = null;
|
|
222
|
+
let isLoaded = false;
|
|
223
|
+
/**
|
|
224
|
+
* Injects a script tag into the document head
|
|
225
|
+
*/
|
|
226
|
+
function injectScript(src, integrity) {
|
|
227
|
+
return new Promise((resolve, reject) => {
|
|
228
|
+
// Check if script already exists
|
|
229
|
+
const existingScript = document.querySelector(`script[src="${src}"]`);
|
|
230
|
+
if (existingScript) {
|
|
231
|
+
resolve(existingScript);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const script = document.createElement('script');
|
|
235
|
+
script.src = src;
|
|
236
|
+
script.async = true;
|
|
237
|
+
script.crossOrigin = 'anonymous';
|
|
238
|
+
if (integrity) {
|
|
239
|
+
script.integrity = integrity;
|
|
240
|
+
}
|
|
241
|
+
script.onload = () => resolve(script);
|
|
242
|
+
script.onerror = () => reject(new Error(`Failed to load Primer SDK script from ${src}`));
|
|
243
|
+
document.head.appendChild(script);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Injects a CSS link tag into the document head
|
|
248
|
+
*/
|
|
249
|
+
function injectCSS(href, integrity) {
|
|
250
|
+
return new Promise((resolve, reject) => {
|
|
251
|
+
// Check if stylesheet already exists
|
|
252
|
+
const existingLink = document.querySelector(`link[href="${href}"]`);
|
|
253
|
+
if (existingLink) {
|
|
254
|
+
resolve(existingLink);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const link = document.createElement('link');
|
|
258
|
+
link.rel = 'stylesheet';
|
|
259
|
+
link.href = href;
|
|
260
|
+
link.crossOrigin = 'anonymous';
|
|
261
|
+
if (integrity) {
|
|
262
|
+
link.integrity = integrity;
|
|
263
|
+
}
|
|
264
|
+
link.onload = () => resolve(link);
|
|
265
|
+
link.onerror = () => reject(new Error(`Failed to load Primer SDK CSS from ${href}`));
|
|
266
|
+
document.head.appendChild(link);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Waits for window.Primer to be available
|
|
271
|
+
*/
|
|
272
|
+
function waitForPrimer(timeout = 10000) {
|
|
273
|
+
return new Promise((resolve, reject) => {
|
|
274
|
+
const startTime = Date.now();
|
|
275
|
+
const check = () => {
|
|
276
|
+
if (typeof window !== 'undefined' &&
|
|
277
|
+
window.Primer &&
|
|
278
|
+
typeof window.Primer.createHeadless === 'function') {
|
|
279
|
+
resolve();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (Date.now() - startTime > timeout) {
|
|
283
|
+
reject(new Error('Timeout waiting for Primer SDK to initialize on window'));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
setTimeout(check, 50);
|
|
287
|
+
};
|
|
288
|
+
check();
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Loads the Primer SDK script and CSS from CDN
|
|
293
|
+
* @param version - The version of Primer SDK to load (default: 2.57.3)
|
|
294
|
+
* @returns Promise that resolves when SDK is loaded and ready
|
|
295
|
+
*/
|
|
296
|
+
async function loadPrimerSDK(version) {
|
|
297
|
+
// Already loaded
|
|
298
|
+
if (isLoaded) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
// Already loading - return existing promise
|
|
302
|
+
if (loadingPromise) {
|
|
303
|
+
return loadingPromise;
|
|
304
|
+
}
|
|
305
|
+
// Check if Primer is already available (user may have loaded it manually)
|
|
306
|
+
if (typeof window !== 'undefined' &&
|
|
307
|
+
window.Primer &&
|
|
308
|
+
typeof window.Primer.createHeadless === 'function') {
|
|
309
|
+
isLoaded = true;
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const ver = version || DEFAULT_VERSION;
|
|
313
|
+
const jsUrl = `${PRIMER_CDN_BASE}/v${ver}/Primer.min.js`;
|
|
314
|
+
const cssUrl = `${PRIMER_CDN_BASE}/v${ver}/Checkout.css`;
|
|
315
|
+
const hashes = INTEGRITY_HASHES[ver];
|
|
316
|
+
loadingPromise = (async () => {
|
|
317
|
+
try {
|
|
318
|
+
// Load CSS and JS in parallel
|
|
319
|
+
await Promise.all([
|
|
320
|
+
injectCSS(cssUrl, hashes?.css),
|
|
321
|
+
injectScript(jsUrl, hashes?.js),
|
|
322
|
+
]);
|
|
323
|
+
// Wait for Primer to be available on window
|
|
324
|
+
await waitForPrimer();
|
|
325
|
+
isLoaded = true;
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
loadingPromise = null;
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
331
|
+
})();
|
|
332
|
+
return loadingPromise;
|
|
333
|
+
}
|
|
334
|
+
|
|
209
335
|
exports.PaymentMethod = void 0;
|
|
210
336
|
(function (PaymentMethod) {
|
|
211
337
|
PaymentMethod["GOOGLE_PAY"] = "GOOGLE_PAY";
|
|
@@ -217,7 +343,7 @@ exports.PaymentMethod = void 0;
|
|
|
217
343
|
/**
|
|
218
344
|
* @fileoverview Constants for Funnefox SDK
|
|
219
345
|
*/
|
|
220
|
-
const SDK_VERSION = '0.5.0
|
|
346
|
+
const SDK_VERSION = '0.5.0';
|
|
221
347
|
const DEFAULTS = {
|
|
222
348
|
BASE_URL: 'https://billing.funnelfox.com',
|
|
223
349
|
REGION: 'default',
|
|
@@ -319,6 +445,21 @@ class PrimerWrapper {
|
|
|
319
445
|
window.Primer &&
|
|
320
446
|
typeof window.Primer?.createHeadless === 'function');
|
|
321
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* Loads Primer SDK if not already available
|
|
450
|
+
* @param version - Optional version to load (uses default if not specified)
|
|
451
|
+
*/
|
|
452
|
+
async ensurePrimerLoaded(version) {
|
|
453
|
+
if (this.isPrimerAvailable()) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
try {
|
|
457
|
+
await loadPrimerSDK(version);
|
|
458
|
+
}
|
|
459
|
+
catch (error) {
|
|
460
|
+
throw new PrimerError('Failed to load Primer SDK', error);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
322
463
|
ensurePrimerAvailable() {
|
|
323
464
|
if (!this.isPrimerAvailable()) {
|
|
324
465
|
throw new PrimerError('Primer SDK not found. Please include the Primer SDK script before initializing FunnefoxSDK.');
|
|
@@ -328,7 +469,8 @@ class PrimerWrapper {
|
|
|
328
469
|
if (this.headless) {
|
|
329
470
|
return this.headless;
|
|
330
471
|
}
|
|
331
|
-
|
|
472
|
+
// Load Primer SDK if not already available
|
|
473
|
+
await this.ensurePrimerLoaded();
|
|
332
474
|
const primerOptions = merge({
|
|
333
475
|
paymentHandling: 'MANUAL',
|
|
334
476
|
apiVersion: '2.4',
|
|
@@ -381,7 +523,8 @@ class PrimerWrapper {
|
|
|
381
523
|
}
|
|
382
524
|
async renderButton(allowedPaymentMethod, { htmlNode, onMethodRenderError, onMethodRender, }) {
|
|
383
525
|
let button;
|
|
384
|
-
|
|
526
|
+
// Ensure Primer SDK is loaded
|
|
527
|
+
await this.ensurePrimerLoaded();
|
|
385
528
|
if (!this.headless) {
|
|
386
529
|
throw new PrimerError('Headless checkout not found');
|
|
387
530
|
}
|
|
@@ -1273,12 +1416,12 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1273
1416
|
this.on(EVENTS.ERROR, (error) => skin.onError(error));
|
|
1274
1417
|
this.on(EVENTS.LOADER_CHANGE, skin.onLoaderChange);
|
|
1275
1418
|
this.on(EVENTS.DESTROY, skin.onDestroy);
|
|
1276
|
-
this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
|
|
1277
1419
|
this.on(EVENTS.SUCCESS, skin.onSuccess);
|
|
1278
1420
|
this.on(EVENTS.START_PURCHASE, skin.onStartPurchase);
|
|
1279
1421
|
this.on(EVENTS.PURCHASE_FAILURE, skin.onPurchaseFailure);
|
|
1280
1422
|
this.on(EVENTS.PURCHASE_COMPLETED, skin.onPurchaseCompleted);
|
|
1281
1423
|
this.on(EVENTS.METHODS_AVAILABLE, skin.onMethodsAvailable);
|
|
1424
|
+
this.on(EVENTS.METHODS_AVAILABLE, this.hideInitializingLoader);
|
|
1282
1425
|
return skin.getCheckoutOptions();
|
|
1283
1426
|
}
|
|
1284
1427
|
async getCardDefaultSkinCheckoutOptions(node) {
|
|
@@ -1322,8 +1465,9 @@ function resolveConfig(options, functionName) {
|
|
|
1322
1465
|
}
|
|
1323
1466
|
async function createCheckout(options) {
|
|
1324
1467
|
const { ...checkoutConfig } = options;
|
|
1468
|
+
// Ensure Primer SDK is loaded before creating checkout
|
|
1325
1469
|
const primerWrapper = new PrimerWrapper();
|
|
1326
|
-
primerWrapper.
|
|
1470
|
+
await primerWrapper.ensurePrimerLoaded();
|
|
1327
1471
|
const config = resolveConfig(options, 'createCheckout');
|
|
1328
1472
|
const checkout = new CheckoutInstance({
|
|
1329
1473
|
...config,
|
|
@@ -1376,6 +1520,9 @@ async function silentPurchase(options) {
|
|
|
1376
1520
|
return true;
|
|
1377
1521
|
}
|
|
1378
1522
|
async function initMethod(method, element, options) {
|
|
1523
|
+
// Ensure Primer SDK is loaded before initializing payment method
|
|
1524
|
+
const primerWrapper = new PrimerWrapper();
|
|
1525
|
+
await primerWrapper.ensurePrimerLoaded();
|
|
1379
1526
|
const checkoutInstance = new CheckoutInstance({
|
|
1380
1527
|
orgId: options.orgId,
|
|
1381
1528
|
baseUrl: options.baseUrl,
|
|
@@ -202,6 +202,132 @@ function withTimeout(promise, timeoutMs, message = 'Operation timed out') {
|
|
|
202
202
|
return Promise.race([promise, timeoutPromise]);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
* @fileoverview Dynamic loader for Primer SDK
|
|
207
|
+
* Loads Primer script and CSS from CDN independently of bundler
|
|
208
|
+
*/
|
|
209
|
+
const PRIMER_CDN_BASE = 'https://sdk.primer.io/web';
|
|
210
|
+
const DEFAULT_VERSION = '2.57.3';
|
|
211
|
+
// Integrity hashes for specific versions (for SRI security)
|
|
212
|
+
const INTEGRITY_HASHES = {
|
|
213
|
+
'2.57.3': {
|
|
214
|
+
js: 'sha384-xq2SWkYvTlKOMpuXQUXq1QI3eZN7JiqQ3Sc72U9wY1IE30MW3HkwQWg/1n6BTMz4',
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
let loadingPromise = null;
|
|
218
|
+
let isLoaded = false;
|
|
219
|
+
/**
|
|
220
|
+
* Injects a script tag into the document head
|
|
221
|
+
*/
|
|
222
|
+
function injectScript(src, integrity) {
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
224
|
+
// Check if script already exists
|
|
225
|
+
const existingScript = document.querySelector(`script[src="${src}"]`);
|
|
226
|
+
if (existingScript) {
|
|
227
|
+
resolve(existingScript);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const script = document.createElement('script');
|
|
231
|
+
script.src = src;
|
|
232
|
+
script.async = true;
|
|
233
|
+
script.crossOrigin = 'anonymous';
|
|
234
|
+
if (integrity) {
|
|
235
|
+
script.integrity = integrity;
|
|
236
|
+
}
|
|
237
|
+
script.onload = () => resolve(script);
|
|
238
|
+
script.onerror = () => reject(new Error(`Failed to load Primer SDK script from ${src}`));
|
|
239
|
+
document.head.appendChild(script);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Injects a CSS link tag into the document head
|
|
244
|
+
*/
|
|
245
|
+
function injectCSS(href, integrity) {
|
|
246
|
+
return new Promise((resolve, reject) => {
|
|
247
|
+
// Check if stylesheet already exists
|
|
248
|
+
const existingLink = document.querySelector(`link[href="${href}"]`);
|
|
249
|
+
if (existingLink) {
|
|
250
|
+
resolve(existingLink);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const link = document.createElement('link');
|
|
254
|
+
link.rel = 'stylesheet';
|
|
255
|
+
link.href = href;
|
|
256
|
+
link.crossOrigin = 'anonymous';
|
|
257
|
+
if (integrity) {
|
|
258
|
+
link.integrity = integrity;
|
|
259
|
+
}
|
|
260
|
+
link.onload = () => resolve(link);
|
|
261
|
+
link.onerror = () => reject(new Error(`Failed to load Primer SDK CSS from ${href}`));
|
|
262
|
+
document.head.appendChild(link);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Waits for window.Primer to be available
|
|
267
|
+
*/
|
|
268
|
+
function waitForPrimer(timeout = 10000) {
|
|
269
|
+
return new Promise((resolve, reject) => {
|
|
270
|
+
const startTime = Date.now();
|
|
271
|
+
const check = () => {
|
|
272
|
+
if (typeof window !== 'undefined' &&
|
|
273
|
+
window.Primer &&
|
|
274
|
+
typeof window.Primer.createHeadless === 'function') {
|
|
275
|
+
resolve();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (Date.now() - startTime > timeout) {
|
|
279
|
+
reject(new Error('Timeout waiting for Primer SDK to initialize on window'));
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
setTimeout(check, 50);
|
|
283
|
+
};
|
|
284
|
+
check();
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Loads the Primer SDK script and CSS from CDN
|
|
289
|
+
* @param version - The version of Primer SDK to load (default: 2.57.3)
|
|
290
|
+
* @returns Promise that resolves when SDK is loaded and ready
|
|
291
|
+
*/
|
|
292
|
+
async function loadPrimerSDK(version) {
|
|
293
|
+
// Already loaded
|
|
294
|
+
if (isLoaded) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
// Already loading - return existing promise
|
|
298
|
+
if (loadingPromise) {
|
|
299
|
+
return loadingPromise;
|
|
300
|
+
}
|
|
301
|
+
// Check if Primer is already available (user may have loaded it manually)
|
|
302
|
+
if (typeof window !== 'undefined' &&
|
|
303
|
+
window.Primer &&
|
|
304
|
+
typeof window.Primer.createHeadless === 'function') {
|
|
305
|
+
isLoaded = true;
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const ver = version || DEFAULT_VERSION;
|
|
309
|
+
const jsUrl = `${PRIMER_CDN_BASE}/v${ver}/Primer.min.js`;
|
|
310
|
+
const cssUrl = `${PRIMER_CDN_BASE}/v${ver}/Checkout.css`;
|
|
311
|
+
const hashes = INTEGRITY_HASHES[ver];
|
|
312
|
+
loadingPromise = (async () => {
|
|
313
|
+
try {
|
|
314
|
+
// Load CSS and JS in parallel
|
|
315
|
+
await Promise.all([
|
|
316
|
+
injectCSS(cssUrl, hashes?.css),
|
|
317
|
+
injectScript(jsUrl, hashes?.js),
|
|
318
|
+
]);
|
|
319
|
+
// Wait for Primer to be available on window
|
|
320
|
+
await waitForPrimer();
|
|
321
|
+
isLoaded = true;
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
loadingPromise = null;
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
})();
|
|
328
|
+
return loadingPromise;
|
|
329
|
+
}
|
|
330
|
+
|
|
205
331
|
var PaymentMethod;
|
|
206
332
|
(function (PaymentMethod) {
|
|
207
333
|
PaymentMethod["GOOGLE_PAY"] = "GOOGLE_PAY";
|
|
@@ -213,7 +339,7 @@ var PaymentMethod;
|
|
|
213
339
|
/**
|
|
214
340
|
* @fileoverview Constants for Funnefox SDK
|
|
215
341
|
*/
|
|
216
|
-
const SDK_VERSION = '0.5.0
|
|
342
|
+
const SDK_VERSION = '0.5.0';
|
|
217
343
|
const DEFAULTS = {
|
|
218
344
|
BASE_URL: 'https://billing.funnelfox.com',
|
|
219
345
|
REGION: 'default',
|
|
@@ -315,6 +441,21 @@ class PrimerWrapper {
|
|
|
315
441
|
window.Primer &&
|
|
316
442
|
typeof window.Primer?.createHeadless === 'function');
|
|
317
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* Loads Primer SDK if not already available
|
|
446
|
+
* @param version - Optional version to load (uses default if not specified)
|
|
447
|
+
*/
|
|
448
|
+
async ensurePrimerLoaded(version) {
|
|
449
|
+
if (this.isPrimerAvailable()) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
try {
|
|
453
|
+
await loadPrimerSDK(version);
|
|
454
|
+
}
|
|
455
|
+
catch (error) {
|
|
456
|
+
throw new PrimerError('Failed to load Primer SDK', error);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
318
459
|
ensurePrimerAvailable() {
|
|
319
460
|
if (!this.isPrimerAvailable()) {
|
|
320
461
|
throw new PrimerError('Primer SDK not found. Please include the Primer SDK script before initializing FunnefoxSDK.');
|
|
@@ -324,7 +465,8 @@ class PrimerWrapper {
|
|
|
324
465
|
if (this.headless) {
|
|
325
466
|
return this.headless;
|
|
326
467
|
}
|
|
327
|
-
|
|
468
|
+
// Load Primer SDK if not already available
|
|
469
|
+
await this.ensurePrimerLoaded();
|
|
328
470
|
const primerOptions = merge({
|
|
329
471
|
paymentHandling: 'MANUAL',
|
|
330
472
|
apiVersion: '2.4',
|
|
@@ -377,7 +519,8 @@ class PrimerWrapper {
|
|
|
377
519
|
}
|
|
378
520
|
async renderButton(allowedPaymentMethod, { htmlNode, onMethodRenderError, onMethodRender, }) {
|
|
379
521
|
let button;
|
|
380
|
-
|
|
522
|
+
// Ensure Primer SDK is loaded
|
|
523
|
+
await this.ensurePrimerLoaded();
|
|
381
524
|
if (!this.headless) {
|
|
382
525
|
throw new PrimerError('Headless checkout not found');
|
|
383
526
|
}
|
|
@@ -1269,12 +1412,12 @@ class CheckoutInstance extends EventEmitter {
|
|
|
1269
1412
|
this.on(EVENTS.ERROR, (error) => skin.onError(error));
|
|
1270
1413
|
this.on(EVENTS.LOADER_CHANGE, skin.onLoaderChange);
|
|
1271
1414
|
this.on(EVENTS.DESTROY, skin.onDestroy);
|
|
1272
|
-
this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
|
|
1273
1415
|
this.on(EVENTS.SUCCESS, skin.onSuccess);
|
|
1274
1416
|
this.on(EVENTS.START_PURCHASE, skin.onStartPurchase);
|
|
1275
1417
|
this.on(EVENTS.PURCHASE_FAILURE, skin.onPurchaseFailure);
|
|
1276
1418
|
this.on(EVENTS.PURCHASE_COMPLETED, skin.onPurchaseCompleted);
|
|
1277
1419
|
this.on(EVENTS.METHODS_AVAILABLE, skin.onMethodsAvailable);
|
|
1420
|
+
this.on(EVENTS.METHODS_AVAILABLE, this.hideInitializingLoader);
|
|
1278
1421
|
return skin.getCheckoutOptions();
|
|
1279
1422
|
}
|
|
1280
1423
|
async getCardDefaultSkinCheckoutOptions(node) {
|
|
@@ -1318,8 +1461,9 @@ function resolveConfig(options, functionName) {
|
|
|
1318
1461
|
}
|
|
1319
1462
|
async function createCheckout(options) {
|
|
1320
1463
|
const { ...checkoutConfig } = options;
|
|
1464
|
+
// Ensure Primer SDK is loaded before creating checkout
|
|
1321
1465
|
const primerWrapper = new PrimerWrapper();
|
|
1322
|
-
primerWrapper.
|
|
1466
|
+
await primerWrapper.ensurePrimerLoaded();
|
|
1323
1467
|
const config = resolveConfig(options, 'createCheckout');
|
|
1324
1468
|
const checkout = new CheckoutInstance({
|
|
1325
1469
|
...config,
|
|
@@ -1372,6 +1516,9 @@ async function silentPurchase(options) {
|
|
|
1372
1516
|
return true;
|
|
1373
1517
|
}
|
|
1374
1518
|
async function initMethod(method, element, options) {
|
|
1519
|
+
// Ensure Primer SDK is loaded before initializing payment method
|
|
1520
|
+
const primerWrapper = new PrimerWrapper();
|
|
1521
|
+
await primerWrapper.ensurePrimerLoaded();
|
|
1375
1522
|
const checkoutInstance = new CheckoutInstance({
|
|
1376
1523
|
orgId: options.orgId,
|
|
1377
1524
|
baseUrl: options.baseUrl,
|
|
@@ -208,6 +208,132 @@
|
|
|
208
208
|
return Promise.race([promise, timeoutPromise]);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* @fileoverview Dynamic loader for Primer SDK
|
|
213
|
+
* Loads Primer script and CSS from CDN independently of bundler
|
|
214
|
+
*/
|
|
215
|
+
const PRIMER_CDN_BASE = 'https://sdk.primer.io/web';
|
|
216
|
+
const DEFAULT_VERSION = '2.57.3';
|
|
217
|
+
// Integrity hashes for specific versions (for SRI security)
|
|
218
|
+
const INTEGRITY_HASHES = {
|
|
219
|
+
'2.57.3': {
|
|
220
|
+
js: 'sha384-xq2SWkYvTlKOMpuXQUXq1QI3eZN7JiqQ3Sc72U9wY1IE30MW3HkwQWg/1n6BTMz4',
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
let loadingPromise = null;
|
|
224
|
+
let isLoaded = false;
|
|
225
|
+
/**
|
|
226
|
+
* Injects a script tag into the document head
|
|
227
|
+
*/
|
|
228
|
+
function injectScript(src, integrity) {
|
|
229
|
+
return new Promise((resolve, reject) => {
|
|
230
|
+
// Check if script already exists
|
|
231
|
+
const existingScript = document.querySelector(`script[src="${src}"]`);
|
|
232
|
+
if (existingScript) {
|
|
233
|
+
resolve(existingScript);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const script = document.createElement('script');
|
|
237
|
+
script.src = src;
|
|
238
|
+
script.async = true;
|
|
239
|
+
script.crossOrigin = 'anonymous';
|
|
240
|
+
if (integrity) {
|
|
241
|
+
script.integrity = integrity;
|
|
242
|
+
}
|
|
243
|
+
script.onload = () => resolve(script);
|
|
244
|
+
script.onerror = () => reject(new Error(`Failed to load Primer SDK script from ${src}`));
|
|
245
|
+
document.head.appendChild(script);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Injects a CSS link tag into the document head
|
|
250
|
+
*/
|
|
251
|
+
function injectCSS(href, integrity) {
|
|
252
|
+
return new Promise((resolve, reject) => {
|
|
253
|
+
// Check if stylesheet already exists
|
|
254
|
+
const existingLink = document.querySelector(`link[href="${href}"]`);
|
|
255
|
+
if (existingLink) {
|
|
256
|
+
resolve(existingLink);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const link = document.createElement('link');
|
|
260
|
+
link.rel = 'stylesheet';
|
|
261
|
+
link.href = href;
|
|
262
|
+
link.crossOrigin = 'anonymous';
|
|
263
|
+
if (integrity) {
|
|
264
|
+
link.integrity = integrity;
|
|
265
|
+
}
|
|
266
|
+
link.onload = () => resolve(link);
|
|
267
|
+
link.onerror = () => reject(new Error(`Failed to load Primer SDK CSS from ${href}`));
|
|
268
|
+
document.head.appendChild(link);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Waits for window.Primer to be available
|
|
273
|
+
*/
|
|
274
|
+
function waitForPrimer(timeout = 10000) {
|
|
275
|
+
return new Promise((resolve, reject) => {
|
|
276
|
+
const startTime = Date.now();
|
|
277
|
+
const check = () => {
|
|
278
|
+
if (typeof window !== 'undefined' &&
|
|
279
|
+
window.Primer &&
|
|
280
|
+
typeof window.Primer.createHeadless === 'function') {
|
|
281
|
+
resolve();
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (Date.now() - startTime > timeout) {
|
|
285
|
+
reject(new Error('Timeout waiting for Primer SDK to initialize on window'));
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
setTimeout(check, 50);
|
|
289
|
+
};
|
|
290
|
+
check();
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Loads the Primer SDK script and CSS from CDN
|
|
295
|
+
* @param version - The version of Primer SDK to load (default: 2.57.3)
|
|
296
|
+
* @returns Promise that resolves when SDK is loaded and ready
|
|
297
|
+
*/
|
|
298
|
+
async function loadPrimerSDK(version) {
|
|
299
|
+
// Already loaded
|
|
300
|
+
if (isLoaded) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
// Already loading - return existing promise
|
|
304
|
+
if (loadingPromise) {
|
|
305
|
+
return loadingPromise;
|
|
306
|
+
}
|
|
307
|
+
// Check if Primer is already available (user may have loaded it manually)
|
|
308
|
+
if (typeof window !== 'undefined' &&
|
|
309
|
+
window.Primer &&
|
|
310
|
+
typeof window.Primer.createHeadless === 'function') {
|
|
311
|
+
isLoaded = true;
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const ver = version || DEFAULT_VERSION;
|
|
315
|
+
const jsUrl = `${PRIMER_CDN_BASE}/v${ver}/Primer.min.js`;
|
|
316
|
+
const cssUrl = `${PRIMER_CDN_BASE}/v${ver}/Checkout.css`;
|
|
317
|
+
const hashes = INTEGRITY_HASHES[ver];
|
|
318
|
+
loadingPromise = (async () => {
|
|
319
|
+
try {
|
|
320
|
+
// Load CSS and JS in parallel
|
|
321
|
+
await Promise.all([
|
|
322
|
+
injectCSS(cssUrl, hashes?.css),
|
|
323
|
+
injectScript(jsUrl, hashes?.js),
|
|
324
|
+
]);
|
|
325
|
+
// Wait for Primer to be available on window
|
|
326
|
+
await waitForPrimer();
|
|
327
|
+
isLoaded = true;
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
loadingPromise = null;
|
|
331
|
+
throw error;
|
|
332
|
+
}
|
|
333
|
+
})();
|
|
334
|
+
return loadingPromise;
|
|
335
|
+
}
|
|
336
|
+
|
|
211
337
|
exports.PaymentMethod = void 0;
|
|
212
338
|
(function (PaymentMethod) {
|
|
213
339
|
PaymentMethod["GOOGLE_PAY"] = "GOOGLE_PAY";
|
|
@@ -219,7 +345,7 @@
|
|
|
219
345
|
/**
|
|
220
346
|
* @fileoverview Constants for Funnefox SDK
|
|
221
347
|
*/
|
|
222
|
-
const SDK_VERSION = '0.5.0
|
|
348
|
+
const SDK_VERSION = '0.5.0';
|
|
223
349
|
const DEFAULTS = {
|
|
224
350
|
BASE_URL: 'https://billing.funnelfox.com',
|
|
225
351
|
REGION: 'default',
|
|
@@ -321,6 +447,21 @@
|
|
|
321
447
|
window.Primer &&
|
|
322
448
|
typeof window.Primer?.createHeadless === 'function');
|
|
323
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* Loads Primer SDK if not already available
|
|
452
|
+
* @param version - Optional version to load (uses default if not specified)
|
|
453
|
+
*/
|
|
454
|
+
async ensurePrimerLoaded(version) {
|
|
455
|
+
if (this.isPrimerAvailable()) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
try {
|
|
459
|
+
await loadPrimerSDK(version);
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
throw new PrimerError('Failed to load Primer SDK', error);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
324
465
|
ensurePrimerAvailable() {
|
|
325
466
|
if (!this.isPrimerAvailable()) {
|
|
326
467
|
throw new PrimerError('Primer SDK not found. Please include the Primer SDK script before initializing FunnefoxSDK.');
|
|
@@ -330,7 +471,8 @@
|
|
|
330
471
|
if (this.headless) {
|
|
331
472
|
return this.headless;
|
|
332
473
|
}
|
|
333
|
-
|
|
474
|
+
// Load Primer SDK if not already available
|
|
475
|
+
await this.ensurePrimerLoaded();
|
|
334
476
|
const primerOptions = merge({
|
|
335
477
|
paymentHandling: 'MANUAL',
|
|
336
478
|
apiVersion: '2.4',
|
|
@@ -383,7 +525,8 @@
|
|
|
383
525
|
}
|
|
384
526
|
async renderButton(allowedPaymentMethod, { htmlNode, onMethodRenderError, onMethodRender, }) {
|
|
385
527
|
let button;
|
|
386
|
-
|
|
528
|
+
// Ensure Primer SDK is loaded
|
|
529
|
+
await this.ensurePrimerLoaded();
|
|
387
530
|
if (!this.headless) {
|
|
388
531
|
throw new PrimerError('Headless checkout not found');
|
|
389
532
|
}
|
|
@@ -1275,12 +1418,12 @@
|
|
|
1275
1418
|
this.on(EVENTS.ERROR, (error) => skin.onError(error));
|
|
1276
1419
|
this.on(EVENTS.LOADER_CHANGE, skin.onLoaderChange);
|
|
1277
1420
|
this.on(EVENTS.DESTROY, skin.onDestroy);
|
|
1278
|
-
this.on(EVENTS.METHOD_RENDER, skin.onMethodRender);
|
|
1279
1421
|
this.on(EVENTS.SUCCESS, skin.onSuccess);
|
|
1280
1422
|
this.on(EVENTS.START_PURCHASE, skin.onStartPurchase);
|
|
1281
1423
|
this.on(EVENTS.PURCHASE_FAILURE, skin.onPurchaseFailure);
|
|
1282
1424
|
this.on(EVENTS.PURCHASE_COMPLETED, skin.onPurchaseCompleted);
|
|
1283
1425
|
this.on(EVENTS.METHODS_AVAILABLE, skin.onMethodsAvailable);
|
|
1426
|
+
this.on(EVENTS.METHODS_AVAILABLE, this.hideInitializingLoader);
|
|
1284
1427
|
return skin.getCheckoutOptions();
|
|
1285
1428
|
}
|
|
1286
1429
|
async getCardDefaultSkinCheckoutOptions(node) {
|
|
@@ -1324,8 +1467,9 @@
|
|
|
1324
1467
|
}
|
|
1325
1468
|
async function createCheckout(options) {
|
|
1326
1469
|
const { ...checkoutConfig } = options;
|
|
1470
|
+
// Ensure Primer SDK is loaded before creating checkout
|
|
1327
1471
|
const primerWrapper = new PrimerWrapper();
|
|
1328
|
-
primerWrapper.
|
|
1472
|
+
await primerWrapper.ensurePrimerLoaded();
|
|
1329
1473
|
const config = resolveConfig(options, 'createCheckout');
|
|
1330
1474
|
const checkout = new CheckoutInstance({
|
|
1331
1475
|
...config,
|
|
@@ -1378,6 +1522,9 @@
|
|
|
1378
1522
|
return true;
|
|
1379
1523
|
}
|
|
1380
1524
|
async function initMethod(method, element, options) {
|
|
1525
|
+
// Ensure Primer SDK is loaded before initializing payment method
|
|
1526
|
+
const primerWrapper = new PrimerWrapper();
|
|
1527
|
+
await primerWrapper.ensurePrimerLoaded();
|
|
1381
1528
|
const checkoutInstance = new CheckoutInstance({
|
|
1382
1529
|
orgId: options.orgId,
|
|
1383
1530
|
baseUrl: options.baseUrl,
|
|
@@ -1629,6 +1776,7 @@
|
|
|
1629
1776
|
this.onMethodsAvailable = (methods) => {
|
|
1630
1777
|
this.availableMethods = methods;
|
|
1631
1778
|
this.initAccordion();
|
|
1779
|
+
methods.forEach(this.onMethodRender);
|
|
1632
1780
|
};
|
|
1633
1781
|
this.onStartPurchase = (paymentMethod) => {
|
|
1634
1782
|
this.currentPurchaseMethod = paymentMethod;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FunnelfoxSDK={})}(this,function(e){"use strict";class t{constructor(){this._events=new Map}on(e,t){if("function"!=typeof t)throw new Error("Event handler must be a function");return this._events.has(e)||this._events.set(e,[]),this._events.get(e).push(t),this}once(e,t){if("function"!=typeof t)throw new Error("Event handler must be a function");const n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}off(e,t=null){if(!this._events.has(e))return this;if(null===t)return this._events.delete(e),this;const n=this._events.get(e),r=n.indexOf(t);return-1!==r&&(n.splice(r,1),0===n.length&&this._events.delete(e)),this}emit(e,...t){if(!this._events.has(e))return!1;const n=this._events.get(e).slice();for(const r of n)try{r.apply(this,t)}catch(t){console.warn(`Error in event handler for "${String(e)}":`,t)}return!0}listenerCount(e){return this._events.has(e)?this._events.get(e).length:0}eventNames(){return Array.from(this._events.keys())}removeAllListeners(){return this._events.clear(),this}listeners(e){return this._events.has(e)?this._events.get(e).slice():[]}}class n extends Error{constructor(e,t=y.SDK_ERROR,r=null){super(e),this.name="FunnefoxSDKError",this.code=t,this.details=r,Error.captureStackTrace&&Error.captureStackTrace(this,n)}}class r extends n{constructor(e,t,n=null){super(`Invalid ${e}: ${t}`,y.VALIDATION_ERROR),this.name="ValidationError",this.field=e,this.value=n}}class o extends n{constructor(e,t=null,n={}){super(e,n.errorCode||y.API_ERROR),this.name="APIError",this.statusCode=t,this.errorCode=n.errorCode||null,this.errorType=n.errorType||null,this.requestId=n.requestId||null,this.response=n.response||null}}class a extends n{constructor(e,t=null){super(e,y.PRIMER_ERROR),this.name="PrimerError",this.primerError=t}}class i extends n{constructor(e,t=null){super(e,y.CHECKOUT_ERROR),this.name="CheckoutError",this.phase=t}}class s extends n{constructor(e,t=null){super(e,y.NETWORK_ERROR),this.name="NetworkError",this.originalError=t}}function d(...e){const t={};for(const n of e)if(n&&"object"==typeof n)for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&("object"!=typeof n[e]||Array.isArray(n[e])||null===n[e]?t[e]=n[e]:t[e]=d(t[e]||{},n[e]));return t}function c(e){return new Promise(t=>setTimeout(t,e))}var l;e.PaymentMethod=void 0,(l=e.PaymentMethod||(e.PaymentMethod={})).GOOGLE_PAY="GOOGLE_PAY",l.APPLE_PAY="APPLE_PAY",l.PAYPAL="PAYPAL",l.PAYMENT_CARD="PAYMENT_CARD";const h={BASE_URL:"https://billing.funnelfox.com",REGION:"default",SANDBOX:!1,REQUEST_TIMEOUT:3e4,RETRY_ATTEMPTS:3,RETRY_BASE_DELAY:1e3},u={SUCCESS:"success",ERROR:"error",STATUS_CHANGE:"status-change",DESTROY:"destroy",INPUT_ERROR:"input-error",LOADER_CHANGE:"loader-change",METHOD_RENDER:"method-render",METHOD_RENDER_ERROR:"method-render-error",START_PURCHASE:"start-purchase",PURCHASE_FAILURE:"purchase-failure",PURCHASE_COMPLETED:"purchase-completed",PURCHASE_CANCELLED:"purchase-cancelled",METHODS_AVAILABLE:"methods-available"},p="/v1/checkout/create_client_session",C="/v1/checkout/update_client_session",m="/v1/checkout/create_payment",f="/v1/checkout/resume_payment",y={SDK_ERROR:"SDK_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",API_ERROR:"API_ERROR",PRIMER_ERROR:"PRIMER_ERROR",CHECKOUT_ERROR:"CHECKOUT_ERROR",CONFIGURATION_ERROR:"CONFIGURATION_ERROR",NETWORK_ERROR:"NETWORK_ERROR"},g=[...[e.PaymentMethod.GOOGLE_PAY,e.PaymentMethod.APPLE_PAY,e.PaymentMethod.PAYPAL],...[e.PaymentMethod.PAYMENT_CARD]],E={input:{error:{borderColor:"rgb(227, 47, 65)"},base:{borderWidth:"1px",borderStyle:"solid",borderColor:"rgb(0 0 0 / 10%)",height:"36px",paddingHorizontal:10,borderRadius:"6px"}}};E.input.base.paddingHorizontal,E.input.base.paddingHorizontal;const M=[e.PaymentMethod.APPLE_PAY,e.PaymentMethod.GOOGLE_PAY,e.PaymentMethod.PAYPAL,e.PaymentMethod.PAYMENT_CARD];class w{constructor(){this.isInitialized=!1,this.destroyCallbacks=[],this.headless=null,this.availableMethods=[],this.paymentMethodsInterfaces=[]}isPrimerAvailable(){return"undefined"!=typeof window&&window.Primer&&"function"==typeof window.Primer?.createHeadless}ensurePrimerAvailable(){if(!this.isPrimerAvailable())throw new a("Primer SDK not found. Please include the Primer SDK script before initializing FunnefoxSDK.")}async createHeadlessCheckout(e,t){if(this.headless)return this.headless;this.ensurePrimerAvailable();const n=d({paymentHandling:"MANUAL",apiVersion:"2.4"},t);try{const t=await window.Primer.createHeadless(e,n);await t.start(),this.headless=t}catch(e){throw new a("Failed to create Primer headless checkout",e)}}disableButtons(e){if(this.paymentMethodsInterfaces)for(const t of this.paymentMethodsInterfaces)t.setDisabled(e)}waitForPayPalReady(){return new Promise((t,n)=>{let r=0;const o=async()=>{await new Promise(e=>{setTimeout(()=>{e()},1e3)});const i=!!window?.paypalPrimer?.Buttons?.instances?.[0];++r<20&&!i?setTimeout(o,0):i?t():n(new a("PayPal paypal_js_sdk_v5_unhandled_exception was detected",e.PaymentMethod.PAYPAL))};o()})}async renderButton(t,{htmlNode:n,onMethodRenderError:r,onMethodRender:o}){let i;if(this.ensurePrimerAvailable(),!this.headless)throw new a("Headless checkout not found");try{const r=await this.headless.createPaymentMethodManager(t);if(!r)throw new Error("Payment method manager is not available");return i=r.createButton(),await i.render(n,{}),t===e.PaymentMethod.PAYPAL&&await this.waitForPayPalReady(),this.destroyCallbacks.push(()=>i.clean()),o(t),{setDisabled:e=>{i.setDisabled(e)},destroy:()=>i.clean()}}catch(e){throw r(t),new a("Failed to initialize Primer checkout",e)}}async initMethod(t,n,r){if(t===e.PaymentMethod.PAYMENT_CARD){if(!r.cardElements||!r.onSubmit||!r.onInputChange)throw new a("Card elements, onSubmit, and onInputChange are required for PAYMENT_CARD method");const e=await this.renderCardCheckoutWithElements(r.cardElements,{onSubmit:r.onSubmit,onInputChange:r.onInputChange,onMethodRenderError:r.onMethodRenderError,onMethodRender:r.onMethodRender});return this.paymentMethodsInterfaces.push(e),e}try{const e=await this.renderButton(t,{htmlNode:n,onMethodRenderError:r.onMethodRenderError,onMethodRender:r.onMethodRender});return this.paymentMethodsInterfaces.push(e),e}catch(e){throw new a("Failed to initialize Primer checkout",e)}}async renderCardCheckoutWithElements(t,{onSubmit:n,onInputChange:r,onMethodRenderError:o,onMethodRender:i}){try{const o=await this.headless.createPaymentMethodManager("PAYMENT_CARD");if(!o)throw new Error("Payment method manager is not available");const{cardNumberInput:s,expiryInput:d,cvvInput:c}=o.createHostedInputs(),l=async()=>{if(!o)return!1;const{valid:e,validationErrors:t}=await o.validate(),n=t.find(e=>"cardholderName"===e.name);return h("cardholderName",n?.message||null),e},h=(e,t)=>{r(e,t)},u=e=>t=>{const n=t;n.submitted&&h(e,n.error)},p=async e=>{o.setCardholderName(e.target.value),h("cardholderName",null)};t.cardholderName?.addEventListener("input",p),s.addEventListener("change",u("cardNumber")),d.addEventListener("change",u("expiryDate")),c.addEventListener("change",u("cvv"));const C=async()=>{if(await l())try{n(!0),await o.submit()}catch(e){throw new a("Failed to submit payment",e)}finally{n(!1)}};t.button?.addEventListener("click",C),await Promise.all([s.render(t.cardNumber,{placeholder:"1234 1234 1234 1234",ariaLabel:"Card number",style:E}),d.render(t.expiryDate,{placeholder:"MM/YY",ariaLabel:"Expiry date",style:E}),c.render(t.cvv,{placeholder:"123",ariaLabel:"CVV",style:E})]);const m=()=>{o.removeHostedInputs(),t.cardholderName?.removeEventListener("change",p),t.button?.removeEventListener("click",C)};return this.destroyCallbacks.push(m),i(e.PaymentMethod.PAYMENT_CARD),{setDisabled:e=>{s.setDisabled(e),d.setDisabled(e),c.setDisabled(e),t.button&&(t.button.disabled=e),t.cardholderName&&(t.cardholderName.disabled=e)},submit:()=>C(),destroy:()=>{this.destroyCallbacks=this.destroyCallbacks.filter(e=>e!==m),m()}}}catch(t){throw o(e.PaymentMethod.PAYMENT_CARD),new a("Failed to initialize Primer checkout",t)}}async initializeHeadlessCheckout(t,n){await this.createHeadlessCheckout(t,{...n,onTokenizeSuccess:this.wrapTokenizeHandler(n.onTokenizeSuccess),onResumeSuccess:this.wrapResumeHandler(n.onResumeSuccess),onAvailablePaymentMethodsLoad:t=>{let n=!1;if(this.availableMethods=g.filter(r=>t.some(t=>(t.type===e.PaymentMethod.APPLE_PAY&&(n=!0),t.type===r))),n&&(this.availableMethods=this.availableMethods.filter(t=>t!==e.PaymentMethod.GOOGLE_PAY)),0===this.availableMethods.length)throw new a("No allowed payment methods found")}})}async renderCheckout(t,n,r){const{cardElements:o,paymentButtonElements:a,container:i,onSubmit:s,onInputChange:d,onMethodRender:c,onMethodRenderError:l,onMethodsAvailable:h}=r;await this.initializeHeadlessCheckout(t,n),h?.(this.availableMethods),await Promise.all(this.availableMethods.map(t=>{if(t===e.PaymentMethod.PAYMENT_CARD)return this.initMethod(t,i,{cardElements:o,onSubmit:s,onInputChange:d,onMethodRender:c,onMethodRenderError:l});{const n={[e.PaymentMethod.PAYPAL]:a.paypal,[e.PaymentMethod.GOOGLE_PAY]:a.googlePay,[e.PaymentMethod.APPLE_PAY]:a.applePay}[t];return this.initMethod(t,n,{onMethodRender:c,onMethodRenderError:l})}})),this.isInitialized=!0}wrapTokenizeHandler(e){return async(t,n)=>{try{await e(t,n)}catch(e){console.error("Error in tokenize handler:",e),n.handleFailure("Payment processing failed. Please try again.")}}}wrapResumeHandler(e){return async(t,n)=>{try{await e(t,n)}catch(e){console.error("Error in resume handler:",e),n.handleFailure("Payment processing failed. Please try again.")}}}async destroy(){if(this.destroyCallbacks)try{Promise.all(this.destroyCallbacks.map(e=>e()))}catch(e){console.warn("Error destroying Primer checkout:",e)}this.destroyCallbacks=[],this.isInitialized=!1}createHandlers(e){return{handleSuccess:()=>{e.onSuccess&&e.onSuccess()},handleFailure:t=>{e.onError&&e.onError(new Error(t))},continueWithNewClientToken:t=>{e.onActionRequired&&e.onActionRequired(t)}}}getCurrentCheckout(){return this.destroyCallbacks}isActive(){return this.isInitialized&&this.destroyCallbacks.length>0}validateContainer(e){const t=document.querySelector(e);if(!t)throw new a(`Checkout container not found: ${e}`);return"none"===window.getComputedStyle(t).display&&console.warn("Checkout container is hidden, this may cause display issues"),t}}class I{constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,""),this.orgId=e.orgId,this.timeout=e.timeout||3e4,this.retryAttempts=e.retryAttempts||3}async request(e,t={}){const n=`${this.baseUrl}/${this.orgId}${e}`,r={method:"GET",headers:{"Content-Type":"application/json",...t.headers||{}},...t};try{return await async function(e,t=3,n=1e3){let r;for(let o=1;o<=t;o++)try{return await e()}catch(e){if(r=e,o===t)throw r;const a=n*Math.pow(2,o-1);await c(a)}throw r}(async()=>await function(e,t,n="Operation timed out"){const r=new Promise((e,r)=>{setTimeout(()=>r(new Error(n)),t)});return Promise.race([e,r])}(this._makeRequest(n,r),this.timeout,"Request timed out"),this.retryAttempts)}catch(e){if(e instanceof Error&&"APIError"===e.name)throw e;throw new s("Network request failed",e)}}async _makeRequest(e,t){let n,r;try{n=await fetch(e,t)}catch(e){if(e instanceof Error&&"NetworkError"===e.name)throw e;throw new s("Network request failed",e)}try{r=await n.json()}catch{throw new o("Invalid JSON response",n.status,{})}if(!n.ok){const e=r,t=e.error?.[0]?.msg||"Failed to create payment";throw new o(t,n.status,{response:r})}return r}async createClientSession(e){const t={region:e.region||"default",integration_type:"primer",pp_ident:e.priceId,external_id:e.externalId,email_address:e.email,client_metadata:e.clientMetadata||{}};return void 0!==e.countryCode&&(t.country_code=e.countryCode),await this.request(p,{method:"POST",body:JSON.stringify(t)})}async updateClientSession(e){const t={order_id:e.orderId,client_token:e.clientToken,pp_ident:e.priceId};return await this.request(C,{method:"POST",body:JSON.stringify(t)})}async createPayment(e){const t={order_id:e.orderId,payment_method_token:e.paymentMethodToken};return await this.request(m,{method:"POST",body:JSON.stringify(t)})}async resumePayment(e){const t={order_id:e.orderId,resume_token:e.resumeToken};return await this.request(f,{method:"POST",body:JSON.stringify(t)})}processSessionResponse(e){if("error"===e.status){const t=e.error?.[0];throw new o(t?.msg||"Session creation failed",null,{errorCode:t?.code,errorType:t?.type,requestId:e.req_id,response:e})}const t=e.data;return{type:"session_created",orderId:t.order_id,clientToken:t.client_token}}processPaymentResponse(e){if("error"===e.status){const t=e.error?.[0];throw new o(t?.msg||"Payment request failed",null,{errorCode:t?.code,errorType:t?.type,response:e})}const t=e.data;if(t.action_required_token)return{type:"action_required",orderId:t.order_id,clientToken:t.action_required_token};if(t.checkout_status)switch(t.checkout_status){case"succeeded":return{type:"success",orderId:t.order_id,status:"succeeded"};case"failed":throw new o(t.failed_message_for_user||"Payment failed",null,{response:e});case"cancelled":throw new o("Payment was cancelled by user",null,{response:e});case"processing":return{type:"processing",orderId:t.order_id,status:"processing"};default:throw new o(`Unhandled checkout status: ${t.checkout_status}`,null,{response:e})}throw new o("Invalid payment response format",null,{response:e})}async oneClick(e){return await this.request(`/billing/${this.orgId}/v1/checkout/one_click`,{method:"POST",body:JSON.stringify(e)})}}"undefined"!=typeof document&&(document.head.appendChild(document.createElement("style")).textContent=".ff-sdk-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.ff-sdk-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 }");const R='<div class="ff-sdk-loader-container">\n <div class="ff-sdk-loader"></div>\n</div>\n',S={loaderContainer:".ff-sdk-loader-container"};class b extends t{constructor(e){super(),this.counter=0,this.handleInputChange=(e,t)=>{this.emit(u.INPUT_ERROR,{name:e,error:t})},this.handleMethodRender=e=>{this.emit(u.METHOD_RENDER,e)},this.handleMethodRenderError=e=>{this.emit(u.METHOD_RENDER_ERROR,e)},this.handleSubmit=e=>{this.onLoaderChangeWithRace(e),this._setState(e?"processing":"ready")},this.handleTokenizeSuccess=async(e,t)=>{try{this.onLoaderChangeWithRace(!0),this._setState("processing");const n=await this.apiClient.createPayment({orderId:this.orderId,paymentMethodToken:e.token}),r=this.apiClient.processPaymentResponse(n);await this._processPaymentResult(r,t)}catch(e){this._setState("error"),this.emit(u.PURCHASE_FAILURE,new Error(e.message||"Payment processing failed")),t.handleFailure(e.message||"Payment processing failed")}finally{this.onLoaderChangeWithRace(!1),this._setState("ready")}},this.handleResumeSuccess=async(e,t)=>{try{this.onLoaderChangeWithRace(!0),this._setState("processing");const n=await this.apiClient.resumePayment({orderId:this.orderId,resumeToken:e.resumeToken}),r=this.apiClient.processPaymentResponse(n);await this._processPaymentResult(r,t)}catch(e){this._setState("error"),this.emit(u.PURCHASE_FAILURE,new Error(e.message||"Payment processing failed")),t.handleFailure(e.message||"Payment processing failed")}finally{this.emit(u.PURCHASE_COMPLETED),this.onLoaderChangeWithRace(!1),this._setState("ready")}},this.handleMethodsAvailable=e=>{this.emit(u.METHODS_AVAILABLE,e)},this.onLoaderChangeWithRace=e=>{const t=!!(e?++this.counter:--this.counter);this.primerWrapper.disableButtons(t),this.emit(u.LOADER_CHANGE,t)},this.id=function(e=""){return`${e}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,5)}`}("checkout_"),this.orgId=e.orgId,this.baseUrl=e.baseUrl,this.region=e.region,this.checkoutConfig={...e.checkoutConfig},this.callbacks={onSuccess:this.checkoutConfig.onSuccess,onError:this.checkoutConfig.onError,onStatusChange:this.checkoutConfig.onStatusChange,onDestroy:this.checkoutConfig.onDestroy},delete this.checkoutConfig?.onSuccess,delete this.checkoutConfig?.onError,delete this.checkoutConfig?.onStatusChange,delete this.checkoutConfig?.onDestroy,this.state="initializing",this.orderId=null,this.clientToken=null,this.primerWrapper=new w,this.isDestroyed=!1,this._setupCallbackBridges()}_setupCallbackBridges(){this.callbacks.onSuccess&&this.on(u.SUCCESS,this.callbacks.onSuccess),this.callbacks.onError&&this.on(u.ERROR,this.callbacks.onError),this.callbacks.onStatusChange&&this.on(u.STATUS_CHANGE,this.callbacks.onStatusChange),this.callbacks.onDestroy&&this.on(u.DESTROY,this.callbacks.onDestroy)}removeAllListeners(){return super.removeAllListeners()}async initialize(){try{return this.showInitializingLoader(),this._setState("initializing"),await this.createSession(),await this._initializePrimerCheckout(),this._setState("ready"),this.checkoutConfig?.onInitialized?.(),this}catch(e){throw this._setState("error"),this.emit(u.ERROR,e),e}finally{this.hideInitializingLoader()}}async createSession(){this.apiClient=new I({baseUrl:this.baseUrl||h.BASE_URL,orgId:this.orgId,timeout:h.REQUEST_TIMEOUT,retryAttempts:h.RETRY_ATTEMPTS});const e={priceId:this.checkoutConfig.priceId,externalId:this.checkoutConfig.customer.externalId,email:this.checkoutConfig.customer.email,region:this.region||h.REGION,clientMetadata:this.checkoutConfig.clientMetadata,countryCode:this.checkoutConfig.customer.countryCode},t=[this.orgId,this.checkoutConfig.priceId,this.checkoutConfig.customer.externalId,this.checkoutConfig.customer.email].join("-");let n;const r=await b.sessionCache.get(t);if(r)n=r;else{const r=this.apiClient.createClientSession(e);b.sessionCache.set(t,r),n=await r}const o=this.apiClient.processSessionResponse(n);this.orderId=o.orderId,this.clientToken=o.clientToken}convertCardSelectorsToElements(e,t){const n=t.querySelector(e.cardNumber),r=t.querySelector(e.expiryDate),o=t.querySelector(e.cvv),a=t.querySelector(e.cardholderName),s=t.querySelector(e.button);if(!(n&&r&&o&&s))throw new i("Required card input elements not found in container");return{cardNumber:n,expiryDate:r,cvv:o,cardholderName:a,button:s}}convertPaymentButtonSelectorsToElements(e){const t=document.querySelector(e.paypal),n=document.querySelector(e.googlePay),r=document.querySelector(e.applePay);if(!t||!n||!r)throw new i("Required payment button elements not found in container");return{paypal:t,googlePay:n,applePay:r}}async _initializePrimerCheckout(){const e=this.getContainer();if(!e)throw new i(`Checkout container not found: ${this.checkoutConfig.container}`);let t,n,r;if(this.checkoutConfig.cardSelectors&&this.checkoutConfig.paymentButtonSelectors)this.checkoutConfig.paymentMethodOrder&&console.warn("paymentMethodOrder is using only for default skin and will be ignored if you are using custom checkout"),t=this.convertCardSelectorsToElements(this.checkoutConfig.cardSelectors,e),n=this.convertPaymentButtonSelectorsToElements(this.checkoutConfig.paymentButtonSelectors),r=this.getCheckoutOptions({});else{this.checkoutConfig.paymentMethodOrder=this.checkoutConfig.paymentMethodOrder||M;const e=await this.getDefaultSkinCheckoutOptions();if(!e.cardElements||!e.paymentButtonElements)throw new i("Default skin must provide cardSelectors and paymentButtonSelectors");t=e.cardElements,n=e.paymentButtonElements,r=this.getCheckoutOptions(e)}await this.primerWrapper.renderCheckout(this.clientToken,r,{container:e,cardElements:t,paymentButtonElements:n,onSubmit:this.handleSubmit,onInputChange:this.handleInputChange,onMethodRender:this.handleMethodRender,onMethodsAvailable:this.handleMethodsAvailable,onMethodRenderError:this.handleMethodRenderError})}async _processPaymentResult(e,t){switch(e.orderId&&(this.orderId=e.orderId),e.type){case"success":this._setState("completed"),this.emit(u.SUCCESS,{orderId:e.orderId,status:e.status}),t.handleSuccess();break;case"action_required":this._setState("action_required"),this.clientToken=e.clientToken,t.continueWithNewClientToken(e.clientToken);break;case"processing":this._setState("processing"),setTimeout(()=>{t.handleFailure("Payment is still processing. Please check back later.")},3e4);break;default:throw new i(`Unknown payment result type: ${e.type}`)}}getCheckoutOptions(e){let t=!1;return{...this.checkoutConfig,...e,onTokenizeSuccess:this.handleTokenizeSuccess,onResumeSuccess:this.handleResumeSuccess,onResumeError:e=>{e.stack?.includes("PROCESSOR_3DS")&&"RESUME_ERROR"===e.code&&e.message?.includes("fetch resume key")||this.emit(u.PURCHASE_FAILURE,e)},onCheckoutFail:e=>{this.emit(u.PURCHASE_FAILURE,e)},onTokenizeError:e=>{this.emit(u.PURCHASE_FAILURE,e)},onTokenizeShouldStart:e=>(this.emit(u.ERROR,void 0),this.emit(u.START_PURCHASE,e.paymentMethodType),!0),onPaymentMethodAction:e=>{switch(e){case"PAYMENT_METHOD_SELECTED":this.emit(u.ERROR,void 0);break;case"PAYMENT_METHOD_UNSELECTED":t||this.emit(u.PURCHASE_CANCELLED),t=!1}}}}async updatePrice(e){if(this._ensureNotDestroyed(),function(e,t){var n;if(0===(n=e,n?.trim()||"").length)throw new r(t,"must be a non-empty string",e)}(e,"priceId"),"processing"===this.state)throw new i("Cannot update price while payment is processing");try{this._setState("updating"),b.sessionCache.clear(),await this.apiClient.updateClientSession({orderId:this.orderId,clientToken:this.clientToken,priceId:e}),this.checkoutConfig.priceId=e,this._setState("ready")}catch(e){throw this._setState("error"),this.emit(u.ERROR,e),e}}getStatus(){return{id:this.id,state:this.state,orderId:this.orderId,priceId:this.checkoutConfig.priceId,isDestroyed:this.isDestroyed}}async destroy(){if(!this.isDestroyed)try{await this.primerWrapper.destroy(),this._setState("destroyed"),this.orderId=null,this.clientToken=null,this.isDestroyed=!0,this.emit(u.DESTROY),this.removeAllListeners()}catch(e){console.warn("Error during checkout cleanup:",e)}}_setState(e){if(this.state!==e){const t=this.state;this.state=e,this.emit(u.STATUS_CHANGE,e,t)}}_ensureNotDestroyed(){if(this.isDestroyed)throw new i("Checkout instance has been destroyed")}getContainer(){return document.querySelector(this.checkoutConfig.container)}isInState(e){return this.state===e}isReady(){return"ready"===this.state&&!this.isDestroyed}isProcessing(){return["processing","action_required"].includes(this.state)}async getDefaultSkinCheckoutOptions(){const e=(await Promise.resolve().then(function(){return O})).default,t=await e(this.checkoutConfig);return this.on(u.INPUT_ERROR,t.onInputError),this.on(u.STATUS_CHANGE,t.onStatusChange),this.on(u.ERROR,e=>t.onError(e)),this.on(u.LOADER_CHANGE,t.onLoaderChange),this.on(u.DESTROY,t.onDestroy),this.on(u.METHOD_RENDER,t.onMethodRender),this.on(u.SUCCESS,t.onSuccess),this.on(u.START_PURCHASE,t.onStartPurchase),this.on(u.PURCHASE_FAILURE,t.onPurchaseFailure),this.on(u.PURCHASE_COMPLETED,t.onPurchaseCompleted),this.on(u.METHODS_AVAILABLE,t.onMethodsAvailable),t.getCheckoutOptions()}async getCardDefaultSkinCheckoutOptions(e){const t=new(0,(await Promise.resolve().then(function(){return T})).default)(e,this.checkoutConfig);return t.init(),this.on(u.INPUT_ERROR,t.onInputError),this.on(u.METHOD_RENDER,t.onMethodRender),this.on(u.SUCCESS,t.onDestroy),t.getCheckoutOptions()}showInitializingLoader(){(e=>{const t=document.querySelector(e);t&&(t.innerHTML=R)})(this.checkoutConfig.container)}hideInitializingLoader(){(()=>{const e=document.querySelector(S.loaderContainer);e&&e.remove()})()}}b.sessionCache=new Map;let k=null;function v(e){k=e}function L(e,t){const{orgId:n,apiConfig:r}=e||{},o=n||k?.orgId;if(!o)throw new Error(`orgId is required. Pass it to ${t}() or call configure() first.`);return{orgId:o,baseUrl:r?.baseUrl||k?.baseUrl||h.BASE_URL,region:r?.region||k?.region||h.REGION}}async function A(e){const{...t}=e;(new w).ensurePrimerAvailable();const n=L(e,"createCheckout"),r=new b({...n,checkoutConfig:{...t}});return await r.initialize(),r}async function P(e){const{priceId:t,externalId:n,email:r,clientMetadata:o,countryCode:a}=e,i=L(e,"createClientSession"),s=new I({baseUrl:i.baseUrl,orgId:i.orgId,timeout:h.REQUEST_TIMEOUT,retryAttempts:h.RETRY_ATTEMPTS}),d=await s.createClientSession({priceId:t,externalId:n,email:r,region:i.region,clientMetadata:o,countryCode:a});return s.processSessionResponse(d)}const D={configure:v,createCheckout:A,createClientSession:P,initMethod:async function(t,n,r){const o=new b({orgId:r.orgId,baseUrl:r.baseUrl,checkoutConfig:{priceId:r.priceId,customer:{externalId:r.externalId,email:r.email},container:"",clientMetadata:r.meta,card:r.card,style:r.style,applePay:r.applePay,paypal:r.paypal,googlePay:r.googlePay}});if(o._ensureNotDestroyed(),o.isReady()||await o.createSession(),o.on(u.METHOD_RENDER,r.onRenderSuccess),o.on(u.METHOD_RENDER_ERROR,r.onRenderError),o.on(u.LOADER_CHANGE,r.onLoaderChange),o.on(u.SUCCESS,r.onPaymentSuccess),o.on(u.PURCHASE_FAILURE,r.onPaymentFail),o.on(u.PURCHASE_CANCELLED,r.onPaymentCancel),o.on(u.ERROR,r.onErrorMessageChange),t===e.PaymentMethod.PAYMENT_CARD){const e=await o.getCardDefaultSkinCheckoutOptions(n),r=o.getCheckoutOptions({...e});return await o.primerWrapper.initializeHeadlessCheckout(o.clientToken,r),o.primerWrapper.initMethod(t,n,{cardElements:e.cardElements,onSubmit:o.handleSubmit,onInputChange:o.handleInputChange,onMethodRender:o.handleMethodRender,onMethodRenderError:o.handleMethodRenderError})}return await o.primerWrapper.initializeHeadlessCheckout(o.clientToken,o.getCheckoutOptions({})),o.primerWrapper.initMethod(t,n,{onMethodRender:o.handleMethodRender,onMethodRenderError:o.handleMethodRenderError})},silentPurchase:async function(e){const{priceId:t,externalId:n,clientMetadata:r,orgId:a,baseUrl:i}=e,s=new I({baseUrl:i,orgId:a,timeout:h.REQUEST_TIMEOUT,retryAttempts:h.RETRY_ATTEMPTS}),d=await s.oneClick({pp_ident:t,external_id:n,client_metadata:r});if("success"!==d.status&&d.error.some(({code:e})=>"double_purchase"===e))throw new o("This product was already purchased");return"success"===d.status}};"undefined"!=typeof window&&(window.Billing=D);"undefined"!=typeof document&&(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}\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/* 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\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/* hack for FFB-169 */\n.ff-google-pay-button-container button, .ff-apple-pay-button-container button {\n height: 54px !important;\n border-radius: 28px !important;\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");"undefined"!=typeof document&&(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-cardholder-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-cardholder-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 }");class x{constructor(e,t){if(this.onInputError=e=>{const{name:t,error:n}=e,r=this.getCardInputElements(),o={cardNumber:r.cardNumber.parentElement,expiryDate:r.expiryDate.parentElement,cvv:r.cvv.parentElement,cardholderName:r.cardholderName?.parentElement},a=o[t]?.querySelector(".errorContainer");a&&(a.textContent=n||""),"cardholderName"===t&&(n?r.cardholderName?.classList?.add("error"):r.cardholderName?.classList?.remove("error"))},this.onMethodRender=()=>{this.containerEl.style.display="block"},this.onDestroy=()=>{this.containerEl.remove()},!e)throw new Error("Container element not found");this.containerEl=e,this.checkoutConfig=t,this.containerEl.style.display="none"}wireCardInputs(){const e=this.containerEl.querySelector("#cardNumberInput"),t=this.containerEl.querySelector("#expiryInput"),n=this.containerEl.querySelector("#cvvInput"),r=!!this.checkoutConfig?.card?.cardholderName;let o;if(r?o=this.containerEl.querySelector("#cardHolderInput"):this.containerEl.querySelector("#cardHolderInput").parentElement.style.display="none",!e||!t||!n||r&&!o)throw new Error("One or more card input elements are missing in the default skin");this.cardInputElements={cardNumber:e,expiryDate:t,cvv:n,cardholderName:o}}async init(){this.containerEl.insertAdjacentHTML("afterbegin",'<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">Card holder</label>\n <input class="ff-card-form-cardholder-input" id="cardHolderInput" placeholder="Card holder">\n <div class="errorContainer"></div>\n</div>\n'),this.wireCardInputs()}renderCardForm(){}getCardInputSelectors(){return{cardNumber:"#cardNumberInput",expiryDate:"#expiryInput",cvv:"#cvvInput",cardholderName:"#cardHolderInput",button:"#submitButton"}}getCardInputElements(){return this.cardInputElements}getCheckoutOptions(){return{cardElements:this.getCardInputElements(),card:{cardholderName:{required:!!this.checkoutConfig?.card?.cardholderName}}}}}var T=Object.freeze({__proto__:null,default:x});const _={[e.PaymentMethod.PAYMENT_CARD]:'\x3c!-- Card Payments Section --\x3e\n<div class="ff-payment-method-card ff-payment-method-payment-card">\n <label class="ff-payment-method-label">\n <input type="radio" name="payment-method" value="PAYMENT_CARD" class="ff-payment-method-radio">\n <div class="ff-payment-method-header">\n <div class="ff-card-logos">\n <img class="payment-method-icon" style="max-height: 30px" src="https://assets.fnlfx.com/common/checkout/cards.webp" alt="visa, mastercard">\n </div>\n </div>\n </label>\n <div class="ff-payment-method-content">\n <div class="ff-card-form-container ff-payment-container" id="cardForm">\n <div class="loader-container">\n <div class="loader"></div>\n </div>\n <div class="payment-errors-container"></div>\n <button class="ff-card-form-submit-button" id="submitButton">\n Continue\n </button>\n <p class="ff-security-message">\n Your payment information is secure with SSL/TLS encryption\n </p>\n </div>\n </div>\n</div>\n',[e.PaymentMethod.PAYPAL]:'<div class="ff-payment-method-card ff-payment-method-paypal">\n <label class="ff-payment-method-label">\n <input type="radio" name="payment-method" value="PAYPAL" class="ff-payment-method-radio">\n <div class="ff-payment-method-header">\n <div class="ff-payment-logo ff-paypal-logo">\n <img class="payment-method-icon" style="max-height: 22px" src="https://assets.fnlfx.com/common/checkout/paypal.webp" alt="PayPal logo">\n </div>\n </div>\n </label>\n <div class="ff-payment-method-content">\n <ul class="ff-payment-features">\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span> Fast, convenient payment option </span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span> Keeps your financial info safe with end-to-end encryption </span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span> Backed by PayPal’s industry-leading fraud protection </span>\n </li>\n </ul>\n <div class="ff-paypal-button-container ff-payment-container" id="paypalButton"></div>\n <div class="loader-container payment-button-loader">\n <div class="loader"></div>\n </div>\n <div class="payment-errors-container"></div>\n <p class="ff-security-message">\n Your payment information is secure with SSL/TLS encryption\n </p>\n </div>\n</div>\n',[e.PaymentMethod.GOOGLE_PAY]:'\x3c!-- Google Pay Section --\x3e\n<div class="ff-payment-method-card ff-payment-method-google-pay">\n <label class="ff-payment-method-label">\n <input type="radio" name="payment-method" value="GOOGLE_PAY" class="ff-payment-method-radio" checked="checked">\n <div class="ff-payment-method-header">\n <div class="ff-payment-logo ff-google-pay-logo">\n <svg class="payment-method-icon" height="26" viewBox="0 0 59 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M27.3601 11.6862V18.4674H25.208V1.72177H30.9132C32.3591 1.72177 33.592 2.20374 34.6008 3.16768C35.632 4.13162 36.1476 5.30852 36.1476 6.69838C36.1476 8.12187 35.632 9.29877 34.6008 10.2515C33.6032 11.2042 32.3703 11.675 30.9132 11.675H27.3601V11.6862ZM27.3601 3.78415V9.62382H30.958C31.8099 9.62382 32.5272 9.3324 33.0876 8.76076C33.6593 8.18912 33.9507 7.49419 33.9507 6.70959C33.9507 5.9362 33.6593 5.25248 33.0876 4.68084C32.5272 4.08678 31.8211 3.79536 30.958 3.79536H27.3601V3.78415Z" fill="currentColor"/>\n <path d="M41.7742 6.63107C43.3658 6.63107 44.6212 7.057 45.5403 7.90885C46.4594 8.7607 46.9189 9.9264 46.9189 11.4059V18.4673H44.8677V16.8757H44.7781C43.8926 18.1871 42.7045 18.8372 41.225 18.8372C39.9584 18.8372 38.9048 18.4673 38.0529 17.7164C37.2011 16.9654 36.7751 16.0351 36.7751 14.9142C36.7751 13.7261 37.2235 12.7846 38.1202 12.0896C39.0169 11.3835 40.2162 11.036 41.7069 11.036C42.9847 11.036 44.0383 11.2714 44.8565 11.7422V11.249C44.8565 10.498 44.5651 9.87035 43.9711 9.34355C43.377 8.81674 42.6821 8.55895 41.8863 8.55895C40.6869 8.55895 39.7342 9.06333 39.0393 10.0833L37.145 8.8952C38.1874 7.38205 39.7342 6.63107 41.7742 6.63107ZM38.9944 14.9478C38.9944 15.5083 39.2298 15.979 39.7118 16.3489C40.1826 16.7188 40.743 16.9093 41.3819 16.9093C42.2898 16.9093 43.0968 16.5731 43.8029 15.9006C44.5091 15.228 44.8677 14.4435 44.8677 13.5356C44.1952 13.0088 43.2649 12.7397 42.0656 12.7397C41.1913 12.7397 40.4628 12.9527 39.8799 13.3674C39.2859 13.8046 38.9944 14.3314 38.9944 14.9478Z" fill="currentColor"/>\n <path d="M58.6207 7.00095L51.4472 23.5H49.2279L51.8955 17.7276L47.1655 7.00095H49.5081L52.9155 15.228H52.9604L56.2781 7.00095H58.6207Z" fill="currentColor"/>\n <path d="M18.8001 10.3187C18.8001 9.61709 18.7373 8.94569 18.6208 8.30008H9.6001V11.9989L14.7953 12C14.5846 13.2307 13.9064 14.2799 12.8674 14.9793V17.379H15.9598C17.7655 15.7078 18.8001 13.2375 18.8001 10.3187Z" fill="#4285F4"/>\n <path d="M12.8685 14.9793C12.0076 15.5599 10.8991 15.8995 9.60228 15.8995C7.09717 15.8995 4.97202 14.2115 4.21096 11.9361H1.021V14.411C2.60141 17.5472 5.84965 19.6992 9.60228 19.6992C12.1959 19.6992 14.3749 18.8462 15.9609 17.3779L12.8685 14.9793Z" fill="#34A853"/>\n <path d="M3.91043 10.1002C3.91043 9.46129 4.01691 8.8437 4.21082 8.26309V5.78824H1.02086C0.367396 7.08507 -0.000244141 8.54891 -0.000244141 10.1002C-0.000244141 11.6514 0.368516 13.1153 1.02086 14.4121L4.21082 11.9373C4.01691 11.3567 3.91043 10.7391 3.91043 10.1002Z" fill="#FABB05"/>\n <path d="M9.60228 4.29974C11.0179 4.29974 12.2856 4.78731 13.2865 5.74004L16.027 3.00179C14.3626 1.45164 12.1926 0.500031 9.60228 0.500031C5.85077 0.500031 2.60141 2.65208 1.021 5.78824L4.21096 8.26309C4.97202 5.98775 7.09717 4.29974 9.60228 4.29974Z" fill="#E94235"/>\n </svg>\n </div>\n </div>\n </label>\n <div class="ff-payment-method-content">\n <ul class="ff-payment-features">\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Easy and private payments with Face/Touch ID</span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Keeps your financial info safe with end-to-end encryption</span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Protected by Google Pay\'s unique Device Account Number</span>\n </li>\n </ul>\n <div class="ff-google-pay-button-container ff-payment-container" id="googlePayButton"></div>\n <div class="loader-container payment-button-loader">\n <div class="loader"></div>\n </div>\n <div class="payment-errors-container"></div>\n <p class="ff-security-message">\n Your payment information is secure with SSL/TLS encryption\n </p>\n </div>\n</div>\n',[e.PaymentMethod.APPLE_PAY]:'\x3c!-- Apple Pay Section --\x3e\n<div class="ff-payment-method-card ff-payment-method-apple-pay">\n <label class="ff-payment-method-label">\n <input type="radio" name="payment-method" value="APPLE_PAY" class="ff-payment-method-radio">\n <div class="ff-payment-method-header">\n <div class="ff-payment-logo ff-apple-pay-logo">\n <svg class="payment-method-icon" height="26" viewBox="0 0 63 26" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M8.41022 4.82398C9.5916 4.92293 10.773 4.23026 11.5113 3.35205C12.2374 2.4491 12.7173 1.23692 12.5943 0C11.5483 0.0494767 10.2561 0.692674 9.51777 1.59562C8.84093 2.37488 8.26255 3.63654 8.41022 4.82398ZM22.4638 20.7555V1.47193H29.6628C33.3793 1.47193 35.9758 4.04471 35.9758 7.80494C35.9758 11.5652 33.33 14.1627 29.5644 14.1627H25.4418V20.7555H22.4638ZM12.5819 5.05898C11.5411 4.99877 10.5914 5.37358 9.82438 5.67633C9.33075 5.87116 8.91274 6.03614 8.59472 6.03614C8.23784 6.03614 7.80257 5.86234 7.31387 5.66719C6.6735 5.4115 5.94138 5.11916 5.17364 5.13319C3.41387 5.15793 1.77716 6.15983 0.878819 7.75545C-0.967091 10.9467 0.398882 15.6717 2.18326 18.2693C3.05699 19.5556 4.10301 20.9657 5.48129 20.9163C6.08765 20.8933 6.52383 20.7072 6.97524 20.5147C7.49492 20.293 8.0348 20.0628 8.87776 20.0628C9.69151 20.0628 10.2078 20.287 10.7033 20.5023C11.1746 20.707 11.6271 20.9036 12.2989 20.8915C13.7264 20.8668 14.6247 19.6051 15.4984 18.3187C16.4413 16.9381 16.8557 15.5906 16.9186 15.3861C16.9222 15.3745 16.9246 15.3665 16.9259 15.3625C16.9244 15.361 16.9128 15.3556 16.8922 15.3462C16.577 15.2011 14.1679 14.0926 14.1448 11.1199C14.1216 8.62473 16.0556 7.36054 16.3601 7.16153C16.3786 7.14944 16.3911 7.14125 16.3968 7.137C15.1662 5.30636 13.2464 5.10845 12.5819 5.05898ZM41.4153 20.9039C43.2858 20.9039 45.0209 19.9515 45.8085 18.4424H45.8701V20.7555H48.6266V11.157C48.6266 8.37393 46.4115 6.5804 43.0027 6.5804C39.8401 6.5804 37.5019 8.39866 37.4158 10.8972H40.0985C40.32 9.70979 41.4153 8.93054 42.9166 8.93054C44.7379 8.93054 45.7593 9.78401 45.7593 11.3549V12.4186L42.0429 12.6413C38.5849 12.8516 36.7143 14.274 36.7143 16.7479C36.7143 19.2464 38.6464 20.9039 41.4153 20.9039ZM42.215 18.6156C40.6275 18.6156 39.6184 17.8487 39.6184 16.6736C39.6184 15.4615 40.5906 14.7564 42.4488 14.6451L45.7591 14.4348V15.5233C45.7591 17.3292 44.2332 18.6156 42.215 18.6156ZM57.7699 21.51C56.5762 24.8868 55.2103 26 52.306 26C52.0845 26 51.3461 25.9753 51.1739 25.9258V23.6127C51.3585 23.6375 51.8138 23.6622 52.0476 23.6622C53.3643 23.6622 54.1027 23.1056 54.558 21.6584L54.8288 20.8049L49.7833 6.76594H52.8967L56.4039 18.1579H56.4655L59.9727 6.76594H63L57.7699 21.51ZM25.4416 3.99524H28.875C31.4592 3.99524 32.936 5.38059 32.936 7.81731C32.936 10.254 31.4592 11.6518 28.8627 11.6518H25.4416V3.99524Z" fill="currentColor"/>\n </svg>\n </div>\n </div>\n </label>\n <div class="ff-payment-method-content">\n <ul class="ff-payment-features">\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Easy and private payments with Face/Touch ID</span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Keeps your financial info safe with end-to-end encryption</span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Protected by Apple Pay’s unique Device Account Numbe</span>\n </li>\n </ul>\n <div class="ff-apple-pay-button-container ff-payment-container" id="applePayButton"></div>\n <div class="loader-container payment-button-loader">\n <div class="loader"></div>\n </div>\n <div class="payment-errors-container"></div>\n <p class="ff-security-message">\n Your payment information is secure with Apple Pay encryption\n </p>\n </div>\n</div>\n'};class N{constructor(t){this.onLoaderChange=e=>{document.querySelectorAll(`${this.containerSelector} .loader-container`)?.forEach(t=>{t.style.display=e?"flex":"none"})},this.onError=(e,t)=>{if(!e)return void this.containerEl.querySelectorAll(".payment-errors-container")?.forEach(e=>{e.innerHTML=""});let n=null;if(t){const e=t.replace("_","-").toLowerCase();n=this.containerEl.querySelector(`.ff-payment-method-${e} .payment-errors-container`)}n&&(n.textContent=e?.message||"")},this.onStatusChange=(e,t)=>{["initializing"].includes(e)||"initializing"!==t||this.onLoaderChange(!1),"updating"===e&&this.onLoaderChange(!0),"ready"===e&&"updating"===t&&this.onLoaderChange(!1)},this.onSuccess=()=>{const e=document.querySelector("#success-screen")?.innerHTML;document.querySelectorAll(".ff-payment-container").forEach(t=>{t.innerHTML=e}),this.onLoaderChange(!1)},this.onDestroy=()=>{this.containerEl.remove()},this.onInputError=e=>{this.cardInstance.onInputError(e)},this.onMethodRender=t=>{const n=t.replace("_","-").toLowerCase(),r=this.containerEl.querySelector(`.ff-payment-method-${n}`);t===e.PaymentMethod.PAYMENT_CARD&&this.cardInstance.onMethodRender(),r&&r.classList.add("visible")},this.onMethodsAvailable=e=>{this.availableMethods=e,this.initAccordion()},this.onStartPurchase=e=>{this.currentPurchaseMethod=e},this.onPurchaseFailure=e=>{this.currentPurchaseMethod&&this.onError(e,this.currentPurchaseMethod),this.currentPurchaseMethod=null},this.onPurchaseCompleted=()=>{this.currentPurchaseMethod=null},this.containerSelector=t.container,this.paymentMethodOrder=t.paymentMethodOrder;const n=document.querySelector(this.containerSelector);if(!n)throw new Error(`Container element not found for selector: ${this.containerSelector}`);this.containerEl=n,this.checkoutConfig=t}initAccordion(){const e=this.containerEl.querySelectorAll(".ff-payment-method-card"),t=this.containerEl.querySelectorAll(".ff-payment-method-radio"),n=t=>{e.forEach(e=>{const n=e.querySelector(".ff-payment-method-radio");n===t&&n?.checked?e.classList.add("expanded"):e.classList.remove("expanded")})},r=Array.from(t).find(e=>this.availableMethods.includes(e.value));if(!r)throw new Error("Default skin accordion initialization error: No radio button found");setTimeout(()=>{r.checked=!0,n(r)},0),t.forEach(e=>{e.addEventListener("change",()=>{e.checked&&n(e)})})}wireCardInputs(){this.cardInstance.wireCardInputs();const e=this.containerEl.querySelector("#submitButton");if(!e)throw new Error("One or more card input elements are missing in the default skin");this.cardInputElements={...this.cardInstance.getCardInputElements(),button:e}}async init(){this.containerEl.insertAdjacentHTML("beforeend",'<div class="ff-skin-default" id="ff-payment-method-containers">\n <div id="success-screen" style="display: none">\n <div class="success">\n <img alt="Loading" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIHZpZXdCb3g9IjAgMCA1MCA1MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTI1IDAuMTExMzI4QzIwLjA3NzQgMC4xMTEzMjggMTUuMjY1NCAxLjU3MTA0IDExLjE3MjUgNC4zMDU4NkM3LjA3OTUyIDcuMDQwNjkgMy44ODk0NSAxMC45Mjc4IDIuMDA1NjYgMTUuNDc1N0MwLjEyMTg4MyAyMC4wMjM1IC0wLjM3MSAyNS4wMjc4IDAuNTg5MzQzIDI5Ljg1NThDMS41NDk2OSAzNC42ODM4IDMuOTIwMTIgMzkuMTE4NSA3LjQwMDkgNDIuNTk5M0MxMC44ODE3IDQ2LjA4MDEgMTUuMzE2NCA0OC40NTA1IDIwLjE0NDQgNDkuNDEwOUMyNC45NzI0IDUwLjM3MTIgMjkuOTc2NyA0OS44NzgzIDM0LjUyNDYgNDcuOTk0NkMzOS4wNzI0IDQ2LjExMDggNDIuOTU5NSA0Mi45MjA3IDQ1LjY5NDQgMzguODI3N0M0OC40MjkyIDM0LjczNDggNDkuODg4OSAyOS45MjI4IDQ5Ljg4ODkgMjUuMDAwMkM0OS44ODg5IDE4LjM5OTMgNDcuMjY2NyAxMi4wNjg3IDQyLjU5OTEgNy40MDExMkMzNy45MzE1IDIuNzMzNTQgMzEuNjAwOSAwLjExMTMyOCAyNSAwLjExMTMyOFpNNDEuMjU1NiAxNi42NDY5TDIwLjgxNTYgMzcuMDcxM0w4Ljc0NDQ0IDI1LjAwMDJDOC4zMzE4OCAyNC41ODc3IDguMTAwMTEgMjQuMDI4MSA4LjEwMDExIDIzLjQ0NDdDOC4xMDAxMSAyMi44NjEyIDguMzMxODggMjIuMzAxNyA4Ljc0NDQ0IDIxLjg4OTFDOS4xNTcgMjEuNDc2NSA5LjcxNjU1IDIxLjI0NDggMTAuMyAyMS4yNDQ4QzEwLjg4MzQgMjEuMjQ0OCAxMS40NDMgMjEuNDc2NSAxMS44NTU2IDIxLjg4OTFMMjAuODQ2NyAzMC44ODAyTDM4LjE3NTYgMTMuNTY2OUMzOC4zNzk4IDEzLjM2MjYgMzguNjIyMyAxMy4yMDA2IDM4Ljg4OTIgMTMuMDlDMzkuMTU2MiAxMi45Nzk1IDM5LjQ0MjIgMTIuOTIyNiAzOS43MzExIDEyLjkyMjZDNDAuMDIgMTIuOTIyNiA0MC4zMDYxIDEyLjk3OTUgNDAuNTczIDEzLjA5QzQwLjgzOTkgMTMuMjAwNiA0MS4wODI0IDEzLjM2MjYgNDEuMjg2NyAxMy41NjY5QzQxLjQ5MDkgMTMuNzcxMiA0MS42NTMgMTQuMDEzNyA0MS43NjM1IDE0LjI4MDZDNDEuODc0MSAxNC41NDc1IDQxLjkzMSAxNC44MzM1IDQxLjkzMSAxNS4xMjI0QzQxLjkzMSAxNS40MTEzIDQxLjg3NDEgMTUuNjk3NCA0MS43NjM1IDE1Ljk2NDNDNDEuNjUzIDE2LjIzMTIgNDEuNDkwOSAxNi40NzM3IDQxLjI4NjcgMTYuNjc4TDQxLjI1NTYgMTYuNjQ2OVoiIGZpbGw9IiM4RURGQzIiLz4KPC9zdmc+Cg==">\n <div>Payment completed successfully</div>\n </div>\n </div>\n</div>\n');const e=this.containerEl.querySelector("#ff-payment-method-containers");this.paymentMethodOrder.forEach(t=>{e.insertAdjacentHTML("beforeend",_[t])}),this.cardInstance=new x(document.querySelector("#cardForm"),this.checkoutConfig),this.cardInstance.init(),this.wireCardInputs()}renderCardForm(){}getCardInputSelectors(){return{...this.cardInstance.getCardInputSelectors(),button:"#submitButton"}}getCardInputElements(){return{...this.cardInstance.getCardInputElements(),button:this.cardInputElements.button}}getPaymentButtonElements(){return{paypal:this.containerEl.querySelector("#paypalButton"),googlePay:this.containerEl.querySelector("#googlePayButton"),applePay:this.containerEl.querySelector("#applePayButton")}}getCheckoutOptions(){return{...this.cardInstance.getCheckoutOptions(),cardElements:this.getCardInputElements(),paymentButtonElements:this.getPaymentButtonElements(),applePay:{buttonStyle:"black"},paypal:{buttonColor:"gold",buttonShape:"pill",buttonLabel:"pay",buttonSize:"large",buttonHeight:54},googlePay:{buttonColor:"black",buttonSizeMode:"fill",buttonType:"pay"}}}}var O=Object.freeze({__proto__:null,default:async e=>{const t=new N(e);return await t.init(),t}});e.APIError=o,e.Billing=D,e.CHECKOUT_STATES={INITIALIZING:"initializing",READY:"ready",PROCESSING:"processing",ACTION_REQUIRED:"action_required",UPDATING:"updating",COMPLETED:"completed",ERROR:"error",DESTROYED:"destroyed"},e.CheckoutError=i,e.ConfigurationError=class extends n{constructor(e){super(e,y.CONFIGURATION_ERROR),this.name="ConfigurationError"}},e.DEFAULTS=h,e.ERROR_CODES=y,e.EVENTS=u,e.FunnefoxSDKError=n,e.NetworkError=s,e.PrimerError=a,e.SDK_VERSION="0.5.0-beta.4",e.ValidationError=r,e.configure=v,e.createCheckout=A,e.createClientSession=P,e.default=D,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FunnelfoxSDK={})}(this,function(e){"use strict";class t{constructor(){this._events=new Map}on(e,t){if("function"!=typeof t)throw new Error("Event handler must be a function");return this._events.has(e)||this._events.set(e,[]),this._events.get(e).push(t),this}once(e,t){if("function"!=typeof t)throw new Error("Event handler must be a function");const n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}off(e,t=null){if(!this._events.has(e))return this;if(null===t)return this._events.delete(e),this;const n=this._events.get(e),r=n.indexOf(t);return-1!==r&&(n.splice(r,1),0===n.length&&this._events.delete(e)),this}emit(e,...t){if(!this._events.has(e))return!1;const n=this._events.get(e).slice();for(const r of n)try{r.apply(this,t)}catch(t){console.warn(`Error in event handler for "${String(e)}":`,t)}return!0}listenerCount(e){return this._events.has(e)?this._events.get(e).length:0}eventNames(){return Array.from(this._events.keys())}removeAllListeners(){return this._events.clear(),this}listeners(e){return this._events.has(e)?this._events.get(e).slice():[]}}class n extends Error{constructor(e,t=I.SDK_ERROR,r=null){super(e),this.name="FunnefoxSDKError",this.code=t,this.details=r,Error.captureStackTrace&&Error.captureStackTrace(this,n)}}class r extends n{constructor(e,t,n=null){super(`Invalid ${e}: ${t}`,I.VALIDATION_ERROR),this.name="ValidationError",this.field=e,this.value=n}}class o extends n{constructor(e,t=null,n={}){super(e,n.errorCode||I.API_ERROR),this.name="APIError",this.statusCode=t,this.errorCode=n.errorCode||null,this.errorType=n.errorType||null,this.requestId=n.requestId||null,this.response=n.response||null}}class i extends n{constructor(e,t=null){super(e,I.PRIMER_ERROR),this.name="PrimerError",this.primerError=t}}class a extends n{constructor(e,t=null){super(e,I.CHECKOUT_ERROR),this.name="CheckoutError",this.phase=t}}class s extends n{constructor(e,t=null){super(e,I.NETWORK_ERROR),this.name="NetworkError",this.originalError=t}}function d(...e){const t={};for(const n of e)if(n&&"object"==typeof n)for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&("object"!=typeof n[e]||Array.isArray(n[e])||null===n[e]?t[e]=n[e]:t[e]=d(t[e]||{},n[e]));return t}function c(e){return new Promise(t=>setTimeout(t,e))}const l="https://sdk.primer.io/web",h={"2.57.3":{js:"sha384-xq2SWkYvTlKOMpuXQUXq1QI3eZN7JiqQ3Sc72U9wY1IE30MW3HkwQWg/1n6BTMz4"}};let u=null,p=!1;function m(e,t){return new Promise((n,r)=>{const o=document.querySelector(`script[src="${e}"]`);if(o)return void n(o);const i=document.createElement("script");i.src=e,i.async=!0,i.crossOrigin="anonymous",t&&(i.integrity=t),i.onload=()=>n(i),i.onerror=()=>r(new Error(`Failed to load Primer SDK script from ${e}`)),document.head.appendChild(i)})}async function C(e){if(p)return;if(u)return u;if("undefined"!=typeof window&&window.Primer&&"function"==typeof window.Primer.createHeadless)return void(p=!0);const t=e||"2.57.3",n=`${l}/v${t}/Primer.min.js`,r=`${l}/v${t}/Checkout.css`,o=h[t];return u=(async()=>{try{await Promise.all([(e=r,t=o?.css,new Promise((n,r)=>{const o=document.querySelector(`link[href="${e}"]`);if(o)return void n(o);const i=document.createElement("link");i.rel="stylesheet",i.href=e,i.crossOrigin="anonymous",t&&(i.integrity=t),i.onload=()=>n(i),i.onerror=()=>r(new Error(`Failed to load Primer SDK CSS from ${e}`)),document.head.appendChild(i)})),m(n,o?.js)]),await function(e=1e4){return new Promise((t,n)=>{const r=Date.now(),o=()=>{"undefined"!=typeof window&&window.Primer&&"function"==typeof window.Primer.createHeadless?t():Date.now()-r>e?n(new Error("Timeout waiting for Primer SDK to initialize on window")):setTimeout(o,50)};o()})}(),p=!0}catch(e){throw u=null,e}var e,t})(),u}var f;e.PaymentMethod=void 0,(f=e.PaymentMethod||(e.PaymentMethod={})).GOOGLE_PAY="GOOGLE_PAY",f.APPLE_PAY="APPLE_PAY",f.PAYPAL="PAYPAL",f.PAYMENT_CARD="PAYMENT_CARD";const y={BASE_URL:"https://billing.funnelfox.com",REGION:"default",SANDBOX:!1,REQUEST_TIMEOUT:3e4,RETRY_ATTEMPTS:3,RETRY_BASE_DELAY:1e3},g={SUCCESS:"success",ERROR:"error",STATUS_CHANGE:"status-change",DESTROY:"destroy",INPUT_ERROR:"input-error",LOADER_CHANGE:"loader-change",METHOD_RENDER:"method-render",METHOD_RENDER_ERROR:"method-render-error",START_PURCHASE:"start-purchase",PURCHASE_FAILURE:"purchase-failure",PURCHASE_COMPLETED:"purchase-completed",PURCHASE_CANCELLED:"purchase-cancelled",METHODS_AVAILABLE:"methods-available"},E="/v1/checkout/create_client_session",M="/v1/checkout/update_client_session",w="/v1/checkout/create_payment",S="/v1/checkout/resume_payment",I={SDK_ERROR:"SDK_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",API_ERROR:"API_ERROR",PRIMER_ERROR:"PRIMER_ERROR",CHECKOUT_ERROR:"CHECKOUT_ERROR",CONFIGURATION_ERROR:"CONFIGURATION_ERROR",NETWORK_ERROR:"NETWORK_ERROR"},k=[...[e.PaymentMethod.GOOGLE_PAY,e.PaymentMethod.APPLE_PAY,e.PaymentMethod.PAYPAL],...[e.PaymentMethod.PAYMENT_CARD]],R={input:{error:{borderColor:"rgb(227, 47, 65)"},base:{borderWidth:"1px",borderStyle:"solid",borderColor:"rgb(0 0 0 / 10%)",height:"36px",paddingHorizontal:10,borderRadius:"6px"}}};R.input.base.paddingHorizontal,R.input.base.paddingHorizontal;const v=[e.PaymentMethod.APPLE_PAY,e.PaymentMethod.GOOGLE_PAY,e.PaymentMethod.PAYPAL,e.PaymentMethod.PAYMENT_CARD];class L{constructor(){this.isInitialized=!1,this.destroyCallbacks=[],this.headless=null,this.availableMethods=[],this.paymentMethodsInterfaces=[]}isPrimerAvailable(){return"undefined"!=typeof window&&window.Primer&&"function"==typeof window.Primer?.createHeadless}async ensurePrimerLoaded(e){if(!this.isPrimerAvailable())try{await C(e)}catch(e){throw new i("Failed to load Primer SDK",e)}}ensurePrimerAvailable(){if(!this.isPrimerAvailable())throw new i("Primer SDK not found. Please include the Primer SDK script before initializing FunnefoxSDK.")}async createHeadlessCheckout(e,t){if(this.headless)return this.headless;await this.ensurePrimerLoaded();const n=d({paymentHandling:"MANUAL",apiVersion:"2.4"},t);try{const t=await window.Primer.createHeadless(e,n);await t.start(),this.headless=t}catch(e){throw new i("Failed to create Primer headless checkout",e)}}disableButtons(e){if(this.paymentMethodsInterfaces)for(const t of this.paymentMethodsInterfaces)t.setDisabled(e)}waitForPayPalReady(){return new Promise((t,n)=>{let r=0;const o=async()=>{await new Promise(e=>{setTimeout(()=>{e()},1e3)});const a=!!window?.paypalPrimer?.Buttons?.instances?.[0];++r<20&&!a?setTimeout(o,0):a?t():n(new i("PayPal paypal_js_sdk_v5_unhandled_exception was detected",e.PaymentMethod.PAYPAL))};o()})}async renderButton(t,{htmlNode:n,onMethodRenderError:r,onMethodRender:o}){let a;if(await this.ensurePrimerLoaded(),!this.headless)throw new i("Headless checkout not found");try{const r=await this.headless.createPaymentMethodManager(t);if(!r)throw new Error("Payment method manager is not available");return a=r.createButton(),await a.render(n,{}),t===e.PaymentMethod.PAYPAL&&await this.waitForPayPalReady(),this.destroyCallbacks.push(()=>a.clean()),o(t),{setDisabled:e=>{a.setDisabled(e)},destroy:()=>a.clean()}}catch(e){throw r(t),new i("Failed to initialize Primer checkout",e)}}async initMethod(t,n,r){if(t===e.PaymentMethod.PAYMENT_CARD){if(!r.cardElements||!r.onSubmit||!r.onInputChange)throw new i("Card elements, onSubmit, and onInputChange are required for PAYMENT_CARD method");const e=await this.renderCardCheckoutWithElements(r.cardElements,{onSubmit:r.onSubmit,onInputChange:r.onInputChange,onMethodRenderError:r.onMethodRenderError,onMethodRender:r.onMethodRender});return this.paymentMethodsInterfaces.push(e),e}try{const e=await this.renderButton(t,{htmlNode:n,onMethodRenderError:r.onMethodRenderError,onMethodRender:r.onMethodRender});return this.paymentMethodsInterfaces.push(e),e}catch(e){throw new i("Failed to initialize Primer checkout",e)}}async renderCardCheckoutWithElements(t,{onSubmit:n,onInputChange:r,onMethodRenderError:o,onMethodRender:a}){try{const o=await this.headless.createPaymentMethodManager("PAYMENT_CARD");if(!o)throw new Error("Payment method manager is not available");const{cardNumberInput:s,expiryInput:d,cvvInput:c}=o.createHostedInputs(),l=async()=>{if(!o)return!1;const{valid:e,validationErrors:t}=await o.validate(),n=t.find(e=>"cardholderName"===e.name);return h("cardholderName",n?.message||null),e},h=(e,t)=>{r(e,t)},u=e=>t=>{const n=t;n.submitted&&h(e,n.error)},p=async e=>{o.setCardholderName(e.target.value),h("cardholderName",null)};t.cardholderName?.addEventListener("input",p),s.addEventListener("change",u("cardNumber")),d.addEventListener("change",u("expiryDate")),c.addEventListener("change",u("cvv"));const m=async()=>{if(await l())try{n(!0),await o.submit()}catch(e){throw new i("Failed to submit payment",e)}finally{n(!1)}};t.button?.addEventListener("click",m),await Promise.all([s.render(t.cardNumber,{placeholder:"1234 1234 1234 1234",ariaLabel:"Card number",style:R}),d.render(t.expiryDate,{placeholder:"MM/YY",ariaLabel:"Expiry date",style:R}),c.render(t.cvv,{placeholder:"123",ariaLabel:"CVV",style:R})]);const C=()=>{o.removeHostedInputs(),t.cardholderName?.removeEventListener("change",p),t.button?.removeEventListener("click",m)};return this.destroyCallbacks.push(C),a(e.PaymentMethod.PAYMENT_CARD),{setDisabled:e=>{s.setDisabled(e),d.setDisabled(e),c.setDisabled(e),t.button&&(t.button.disabled=e),t.cardholderName&&(t.cardholderName.disabled=e)},submit:()=>m(),destroy:()=>{this.destroyCallbacks=this.destroyCallbacks.filter(e=>e!==C),C()}}}catch(t){throw o(e.PaymentMethod.PAYMENT_CARD),new i("Failed to initialize Primer checkout",t)}}async initializeHeadlessCheckout(t,n){await this.createHeadlessCheckout(t,{...n,onTokenizeSuccess:this.wrapTokenizeHandler(n.onTokenizeSuccess),onResumeSuccess:this.wrapResumeHandler(n.onResumeSuccess),onAvailablePaymentMethodsLoad:t=>{let n=!1;if(this.availableMethods=k.filter(r=>t.some(t=>(t.type===e.PaymentMethod.APPLE_PAY&&(n=!0),t.type===r))),n&&(this.availableMethods=this.availableMethods.filter(t=>t!==e.PaymentMethod.GOOGLE_PAY)),0===this.availableMethods.length)throw new i("No allowed payment methods found")}})}async renderCheckout(t,n,r){const{cardElements:o,paymentButtonElements:i,container:a,onSubmit:s,onInputChange:d,onMethodRender:c,onMethodRenderError:l,onMethodsAvailable:h}=r;await this.initializeHeadlessCheckout(t,n),h?.(this.availableMethods),await Promise.all(this.availableMethods.map(t=>{if(t===e.PaymentMethod.PAYMENT_CARD)return this.initMethod(t,a,{cardElements:o,onSubmit:s,onInputChange:d,onMethodRender:c,onMethodRenderError:l});{const n={[e.PaymentMethod.PAYPAL]:i.paypal,[e.PaymentMethod.GOOGLE_PAY]:i.googlePay,[e.PaymentMethod.APPLE_PAY]:i.applePay}[t];return this.initMethod(t,n,{onMethodRender:c,onMethodRenderError:l})}})),this.isInitialized=!0}wrapTokenizeHandler(e){return async(t,n)=>{try{await e(t,n)}catch(e){console.error("Error in tokenize handler:",e),n.handleFailure("Payment processing failed. Please try again.")}}}wrapResumeHandler(e){return async(t,n)=>{try{await e(t,n)}catch(e){console.error("Error in resume handler:",e),n.handleFailure("Payment processing failed. Please try again.")}}}async destroy(){if(this.destroyCallbacks)try{Promise.all(this.destroyCallbacks.map(e=>e()))}catch(e){console.warn("Error destroying Primer checkout:",e)}this.destroyCallbacks=[],this.isInitialized=!1}createHandlers(e){return{handleSuccess:()=>{e.onSuccess&&e.onSuccess()},handleFailure:t=>{e.onError&&e.onError(new Error(t))},continueWithNewClientToken:t=>{e.onActionRequired&&e.onActionRequired(t)}}}getCurrentCheckout(){return this.destroyCallbacks}isActive(){return this.isInitialized&&this.destroyCallbacks.length>0}validateContainer(e){const t=document.querySelector(e);if(!t)throw new i(`Checkout container not found: ${e}`);return"none"===window.getComputedStyle(t).display&&console.warn("Checkout container is hidden, this may cause display issues"),t}}class b{constructor(e){this.baseUrl=e.baseUrl.replace(/\/$/,""),this.orgId=e.orgId,this.timeout=e.timeout||3e4,this.retryAttempts=e.retryAttempts||3}async request(e,t={}){const n=`${this.baseUrl}/${this.orgId}${e}`,r={method:"GET",headers:{"Content-Type":"application/json",...t.headers||{}},...t};try{return await async function(e,t=3,n=1e3){let r;for(let o=1;o<=t;o++)try{return await e()}catch(e){if(r=e,o===t)throw r;const i=n*Math.pow(2,o-1);await c(i)}throw r}(async()=>await function(e,t,n="Operation timed out"){const r=new Promise((e,r)=>{setTimeout(()=>r(new Error(n)),t)});return Promise.race([e,r])}(this._makeRequest(n,r),this.timeout,"Request timed out"),this.retryAttempts)}catch(e){if(e instanceof Error&&"APIError"===e.name)throw e;throw new s("Network request failed",e)}}async _makeRequest(e,t){let n,r;try{n=await fetch(e,t)}catch(e){if(e instanceof Error&&"NetworkError"===e.name)throw e;throw new s("Network request failed",e)}try{r=await n.json()}catch{throw new o("Invalid JSON response",n.status,{})}if(!n.ok){const e=r,t=e.error?.[0]?.msg||"Failed to create payment";throw new o(t,n.status,{response:r})}return r}async createClientSession(e){const t={region:e.region||"default",integration_type:"primer",pp_ident:e.priceId,external_id:e.externalId,email_address:e.email,client_metadata:e.clientMetadata||{}};return void 0!==e.countryCode&&(t.country_code=e.countryCode),await this.request(E,{method:"POST",body:JSON.stringify(t)})}async updateClientSession(e){const t={order_id:e.orderId,client_token:e.clientToken,pp_ident:e.priceId};return await this.request(M,{method:"POST",body:JSON.stringify(t)})}async createPayment(e){const t={order_id:e.orderId,payment_method_token:e.paymentMethodToken};return await this.request(w,{method:"POST",body:JSON.stringify(t)})}async resumePayment(e){const t={order_id:e.orderId,resume_token:e.resumeToken};return await this.request(S,{method:"POST",body:JSON.stringify(t)})}processSessionResponse(e){if("error"===e.status){const t=e.error?.[0];throw new o(t?.msg||"Session creation failed",null,{errorCode:t?.code,errorType:t?.type,requestId:e.req_id,response:e})}const t=e.data;return{type:"session_created",orderId:t.order_id,clientToken:t.client_token}}processPaymentResponse(e){if("error"===e.status){const t=e.error?.[0];throw new o(t?.msg||"Payment request failed",null,{errorCode:t?.code,errorType:t?.type,response:e})}const t=e.data;if(t.action_required_token)return{type:"action_required",orderId:t.order_id,clientToken:t.action_required_token};if(t.checkout_status)switch(t.checkout_status){case"succeeded":return{type:"success",orderId:t.order_id,status:"succeeded"};case"failed":throw new o(t.failed_message_for_user||"Payment failed",null,{response:e});case"cancelled":throw new o("Payment was cancelled by user",null,{response:e});case"processing":return{type:"processing",orderId:t.order_id,status:"processing"};default:throw new o(`Unhandled checkout status: ${t.checkout_status}`,null,{response:e})}throw new o("Invalid payment response format",null,{response:e})}async oneClick(e){return await this.request(`/billing/${this.orgId}/v1/checkout/one_click`,{method:"POST",body:JSON.stringify(e)})}}"undefined"!=typeof document&&(document.head.appendChild(document.createElement("style")).textContent=".ff-sdk-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.ff-sdk-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 }");const P='<div class="ff-sdk-loader-container">\n <div class="ff-sdk-loader"></div>\n</div>\n',A={loaderContainer:".ff-sdk-loader-container"};class D extends t{constructor(e){super(),this.counter=0,this.handleInputChange=(e,t)=>{this.emit(g.INPUT_ERROR,{name:e,error:t})},this.handleMethodRender=e=>{this.emit(g.METHOD_RENDER,e)},this.handleMethodRenderError=e=>{this.emit(g.METHOD_RENDER_ERROR,e)},this.handleSubmit=e=>{this.onLoaderChangeWithRace(e),this._setState(e?"processing":"ready")},this.handleTokenizeSuccess=async(e,t)=>{try{this.onLoaderChangeWithRace(!0),this._setState("processing");const n=await this.apiClient.createPayment({orderId:this.orderId,paymentMethodToken:e.token}),r=this.apiClient.processPaymentResponse(n);await this._processPaymentResult(r,t)}catch(e){this._setState("error"),this.emit(g.PURCHASE_FAILURE,new Error(e.message||"Payment processing failed")),t.handleFailure(e.message||"Payment processing failed")}finally{this.onLoaderChangeWithRace(!1),this._setState("ready")}},this.handleResumeSuccess=async(e,t)=>{try{this.onLoaderChangeWithRace(!0),this._setState("processing");const n=await this.apiClient.resumePayment({orderId:this.orderId,resumeToken:e.resumeToken}),r=this.apiClient.processPaymentResponse(n);await this._processPaymentResult(r,t)}catch(e){this._setState("error"),this.emit(g.PURCHASE_FAILURE,new Error(e.message||"Payment processing failed")),t.handleFailure(e.message||"Payment processing failed")}finally{this.emit(g.PURCHASE_COMPLETED),this.onLoaderChangeWithRace(!1),this._setState("ready")}},this.handleMethodsAvailable=e=>{this.emit(g.METHODS_AVAILABLE,e)},this.onLoaderChangeWithRace=e=>{const t=!!(e?++this.counter:--this.counter);this.primerWrapper.disableButtons(t),this.emit(g.LOADER_CHANGE,t)},this.id=function(e=""){return`${e}${Date.now().toString(36)}_${Math.random().toString(36).substr(2,5)}`}("checkout_"),this.orgId=e.orgId,this.baseUrl=e.baseUrl,this.region=e.region,this.checkoutConfig={...e.checkoutConfig},this.callbacks={onSuccess:this.checkoutConfig.onSuccess,onError:this.checkoutConfig.onError,onStatusChange:this.checkoutConfig.onStatusChange,onDestroy:this.checkoutConfig.onDestroy},delete this.checkoutConfig?.onSuccess,delete this.checkoutConfig?.onError,delete this.checkoutConfig?.onStatusChange,delete this.checkoutConfig?.onDestroy,this.state="initializing",this.orderId=null,this.clientToken=null,this.primerWrapper=new L,this.isDestroyed=!1,this._setupCallbackBridges()}_setupCallbackBridges(){this.callbacks.onSuccess&&this.on(g.SUCCESS,this.callbacks.onSuccess),this.callbacks.onError&&this.on(g.ERROR,this.callbacks.onError),this.callbacks.onStatusChange&&this.on(g.STATUS_CHANGE,this.callbacks.onStatusChange),this.callbacks.onDestroy&&this.on(g.DESTROY,this.callbacks.onDestroy)}removeAllListeners(){return super.removeAllListeners()}async initialize(){try{return this.showInitializingLoader(),this._setState("initializing"),await this.createSession(),await this._initializePrimerCheckout(),this._setState("ready"),this.checkoutConfig?.onInitialized?.(),this}catch(e){throw this._setState("error"),this.emit(g.ERROR,e),e}finally{this.hideInitializingLoader()}}async createSession(){this.apiClient=new b({baseUrl:this.baseUrl||y.BASE_URL,orgId:this.orgId,timeout:y.REQUEST_TIMEOUT,retryAttempts:y.RETRY_ATTEMPTS});const e={priceId:this.checkoutConfig.priceId,externalId:this.checkoutConfig.customer.externalId,email:this.checkoutConfig.customer.email,region:this.region||y.REGION,clientMetadata:this.checkoutConfig.clientMetadata,countryCode:this.checkoutConfig.customer.countryCode},t=[this.orgId,this.checkoutConfig.priceId,this.checkoutConfig.customer.externalId,this.checkoutConfig.customer.email].join("-");let n;const r=await D.sessionCache.get(t);if(r)n=r;else{const r=this.apiClient.createClientSession(e);D.sessionCache.set(t,r),n=await r}const o=this.apiClient.processSessionResponse(n);this.orderId=o.orderId,this.clientToken=o.clientToken}convertCardSelectorsToElements(e,t){const n=t.querySelector(e.cardNumber),r=t.querySelector(e.expiryDate),o=t.querySelector(e.cvv),i=t.querySelector(e.cardholderName),s=t.querySelector(e.button);if(!(n&&r&&o&&s))throw new a("Required card input elements not found in container");return{cardNumber:n,expiryDate:r,cvv:o,cardholderName:i,button:s}}convertPaymentButtonSelectorsToElements(e){const t=document.querySelector(e.paypal),n=document.querySelector(e.googlePay),r=document.querySelector(e.applePay);if(!t||!n||!r)throw new a("Required payment button elements not found in container");return{paypal:t,googlePay:n,applePay:r}}async _initializePrimerCheckout(){const e=this.getContainer();if(!e)throw new a(`Checkout container not found: ${this.checkoutConfig.container}`);let t,n,r;if(this.checkoutConfig.cardSelectors&&this.checkoutConfig.paymentButtonSelectors)this.checkoutConfig.paymentMethodOrder&&console.warn("paymentMethodOrder is using only for default skin and will be ignored if you are using custom checkout"),t=this.convertCardSelectorsToElements(this.checkoutConfig.cardSelectors,e),n=this.convertPaymentButtonSelectorsToElements(this.checkoutConfig.paymentButtonSelectors),r=this.getCheckoutOptions({});else{this.checkoutConfig.paymentMethodOrder=this.checkoutConfig.paymentMethodOrder||v;const e=await this.getDefaultSkinCheckoutOptions();if(!e.cardElements||!e.paymentButtonElements)throw new a("Default skin must provide cardSelectors and paymentButtonSelectors");t=e.cardElements,n=e.paymentButtonElements,r=this.getCheckoutOptions(e)}await this.primerWrapper.renderCheckout(this.clientToken,r,{container:e,cardElements:t,paymentButtonElements:n,onSubmit:this.handleSubmit,onInputChange:this.handleInputChange,onMethodRender:this.handleMethodRender,onMethodsAvailable:this.handleMethodsAvailable,onMethodRenderError:this.handleMethodRenderError})}async _processPaymentResult(e,t){switch(e.orderId&&(this.orderId=e.orderId),e.type){case"success":this._setState("completed"),this.emit(g.SUCCESS,{orderId:e.orderId,status:e.status}),t.handleSuccess();break;case"action_required":this._setState("action_required"),this.clientToken=e.clientToken,t.continueWithNewClientToken(e.clientToken);break;case"processing":this._setState("processing"),setTimeout(()=>{t.handleFailure("Payment is still processing. Please check back later.")},3e4);break;default:throw new a(`Unknown payment result type: ${e.type}`)}}getCheckoutOptions(e){let t=!1;return{...this.checkoutConfig,...e,onTokenizeSuccess:this.handleTokenizeSuccess,onResumeSuccess:this.handleResumeSuccess,onResumeError:e=>{e.stack?.includes("PROCESSOR_3DS")&&"RESUME_ERROR"===e.code&&e.message?.includes("fetch resume key")||this.emit(g.PURCHASE_FAILURE,e)},onCheckoutFail:e=>{this.emit(g.PURCHASE_FAILURE,e)},onTokenizeError:e=>{this.emit(g.PURCHASE_FAILURE,e)},onTokenizeShouldStart:e=>(this.emit(g.ERROR,void 0),this.emit(g.START_PURCHASE,e.paymentMethodType),!0),onPaymentMethodAction:e=>{switch(e){case"PAYMENT_METHOD_SELECTED":this.emit(g.ERROR,void 0);break;case"PAYMENT_METHOD_UNSELECTED":t||this.emit(g.PURCHASE_CANCELLED),t=!1}}}}async updatePrice(e){if(this._ensureNotDestroyed(),function(e,t){var n;if(0===(n=e,n?.trim()||"").length)throw new r(t,"must be a non-empty string",e)}(e,"priceId"),"processing"===this.state)throw new a("Cannot update price while payment is processing");try{this._setState("updating"),D.sessionCache.clear(),await this.apiClient.updateClientSession({orderId:this.orderId,clientToken:this.clientToken,priceId:e}),this.checkoutConfig.priceId=e,this._setState("ready")}catch(e){throw this._setState("error"),this.emit(g.ERROR,e),e}}getStatus(){return{id:this.id,state:this.state,orderId:this.orderId,priceId:this.checkoutConfig.priceId,isDestroyed:this.isDestroyed}}async destroy(){if(!this.isDestroyed)try{await this.primerWrapper.destroy(),this._setState("destroyed"),this.orderId=null,this.clientToken=null,this.isDestroyed=!0,this.emit(g.DESTROY),this.removeAllListeners()}catch(e){console.warn("Error during checkout cleanup:",e)}}_setState(e){if(this.state!==e){const t=this.state;this.state=e,this.emit(g.STATUS_CHANGE,e,t)}}_ensureNotDestroyed(){if(this.isDestroyed)throw new a("Checkout instance has been destroyed")}getContainer(){return document.querySelector(this.checkoutConfig.container)}isInState(e){return this.state===e}isReady(){return"ready"===this.state&&!this.isDestroyed}isProcessing(){return["processing","action_required"].includes(this.state)}async getDefaultSkinCheckoutOptions(){const e=(await Promise.resolve().then(function(){return q})).default,t=await e(this.checkoutConfig);return this.on(g.INPUT_ERROR,t.onInputError),this.on(g.STATUS_CHANGE,t.onStatusChange),this.on(g.ERROR,e=>t.onError(e)),this.on(g.LOADER_CHANGE,t.onLoaderChange),this.on(g.DESTROY,t.onDestroy),this.on(g.SUCCESS,t.onSuccess),this.on(g.START_PURCHASE,t.onStartPurchase),this.on(g.PURCHASE_FAILURE,t.onPurchaseFailure),this.on(g.PURCHASE_COMPLETED,t.onPurchaseCompleted),this.on(g.METHODS_AVAILABLE,t.onMethodsAvailable),this.on(g.METHODS_AVAILABLE,this.hideInitializingLoader),t.getCheckoutOptions()}async getCardDefaultSkinCheckoutOptions(e){const t=new(0,(await Promise.resolve().then(function(){return H})).default)(e,this.checkoutConfig);return t.init(),this.on(g.INPUT_ERROR,t.onInputError),this.on(g.METHOD_RENDER,t.onMethodRender),this.on(g.SUCCESS,t.onDestroy),t.getCheckoutOptions()}showInitializingLoader(){(e=>{const t=document.querySelector(e);t&&(t.innerHTML=P)})(this.checkoutConfig.container)}hideInitializingLoader(){(()=>{const e=document.querySelector(A.loaderContainer);e&&e.remove()})()}}D.sessionCache=new Map;let x=null;function T(e){x=e}function _(e,t){const{orgId:n,apiConfig:r}=e||{},o=n||x?.orgId;if(!o)throw new Error(`orgId is required. Pass it to ${t}() or call configure() first.`);return{orgId:o,baseUrl:r?.baseUrl||x?.baseUrl||y.BASE_URL,region:r?.region||x?.region||y.REGION}}async function N(e){const{...t}=e,n=new L;await n.ensurePrimerLoaded();const r=_(e,"createCheckout"),o=new D({...r,checkoutConfig:{...t}});return await o.initialize(),o}async function O(e){const{priceId:t,externalId:n,email:r,clientMetadata:o,countryCode:i}=e,a=_(e,"createClientSession"),s=new b({baseUrl:a.baseUrl,orgId:a.orgId,timeout:y.REQUEST_TIMEOUT,retryAttempts:y.RETRY_ATTEMPTS}),d=await s.createClientSession({priceId:t,externalId:n,email:r,region:a.region,clientMetadata:o,countryCode:i});return s.processSessionResponse(d)}const z={configure:T,createCheckout:N,createClientSession:O,initMethod:async function(t,n,r){const o=new L;await o.ensurePrimerLoaded();const i=new D({orgId:r.orgId,baseUrl:r.baseUrl,checkoutConfig:{priceId:r.priceId,customer:{externalId:r.externalId,email:r.email},container:"",clientMetadata:r.meta,card:r.card,style:r.style,applePay:r.applePay,paypal:r.paypal,googlePay:r.googlePay}});if(i._ensureNotDestroyed(),i.isReady()||await i.createSession(),i.on(g.METHOD_RENDER,r.onRenderSuccess),i.on(g.METHOD_RENDER_ERROR,r.onRenderError),i.on(g.LOADER_CHANGE,r.onLoaderChange),i.on(g.SUCCESS,r.onPaymentSuccess),i.on(g.PURCHASE_FAILURE,r.onPaymentFail),i.on(g.PURCHASE_CANCELLED,r.onPaymentCancel),i.on(g.ERROR,r.onErrorMessageChange),t===e.PaymentMethod.PAYMENT_CARD){const e=await i.getCardDefaultSkinCheckoutOptions(n),r=i.getCheckoutOptions({...e});return await i.primerWrapper.initializeHeadlessCheckout(i.clientToken,r),i.primerWrapper.initMethod(t,n,{cardElements:e.cardElements,onSubmit:i.handleSubmit,onInputChange:i.handleInputChange,onMethodRender:i.handleMethodRender,onMethodRenderError:i.handleMethodRenderError})}return await i.primerWrapper.initializeHeadlessCheckout(i.clientToken,i.getCheckoutOptions({})),i.primerWrapper.initMethod(t,n,{onMethodRender:i.handleMethodRender,onMethodRenderError:i.handleMethodRenderError})},silentPurchase:async function(e){const{priceId:t,externalId:n,clientMetadata:r,orgId:i,baseUrl:a}=e,s=new b({baseUrl:a,orgId:i,timeout:y.REQUEST_TIMEOUT,retryAttempts:y.RETRY_ATTEMPTS}),d=await s.oneClick({pp_ident:t,external_id:n,client_metadata:r});if("success"!==d.status&&d.error.some(({code:e})=>"double_purchase"===e))throw new o("This product was already purchased");return"success"===d.status}};"undefined"!=typeof window&&(window.Billing=z);"undefined"!=typeof document&&(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}\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/* 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\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/* hack for FFB-169 */\n.ff-google-pay-button-container button, .ff-apple-pay-button-container button {\n height: 54px !important;\n border-radius: 28px !important;\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");"undefined"!=typeof document&&(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-cardholder-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-cardholder-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 }");class j{constructor(e,t){if(this.onInputError=e=>{const{name:t,error:n}=e,r=this.getCardInputElements(),o={cardNumber:r.cardNumber.parentElement,expiryDate:r.expiryDate.parentElement,cvv:r.cvv.parentElement,cardholderName:r.cardholderName?.parentElement},i=o[t]?.querySelector(".errorContainer");i&&(i.textContent=n||""),"cardholderName"===t&&(n?r.cardholderName?.classList?.add("error"):r.cardholderName?.classList?.remove("error"))},this.onMethodRender=()=>{this.containerEl.style.display="block"},this.onDestroy=()=>{this.containerEl.remove()},!e)throw new Error("Container element not found");this.containerEl=e,this.checkoutConfig=t,this.containerEl.style.display="none"}wireCardInputs(){const e=this.containerEl.querySelector("#cardNumberInput"),t=this.containerEl.querySelector("#expiryInput"),n=this.containerEl.querySelector("#cvvInput"),r=!!this.checkoutConfig?.card?.cardholderName;let o;if(r?o=this.containerEl.querySelector("#cardHolderInput"):this.containerEl.querySelector("#cardHolderInput").parentElement.style.display="none",!e||!t||!n||r&&!o)throw new Error("One or more card input elements are missing in the default skin");this.cardInputElements={cardNumber:e,expiryDate:t,cvv:n,cardholderName:o}}async init(){this.containerEl.insertAdjacentHTML("afterbegin",'<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">Card holder</label>\n <input class="ff-card-form-cardholder-input" id="cardHolderInput" placeholder="Card holder">\n <div class="errorContainer"></div>\n</div>\n'),this.wireCardInputs()}renderCardForm(){}getCardInputSelectors(){return{cardNumber:"#cardNumberInput",expiryDate:"#expiryInput",cvv:"#cvvInput",cardholderName:"#cardHolderInput",button:"#submitButton"}}getCardInputElements(){return this.cardInputElements}getCheckoutOptions(){return{cardElements:this.getCardInputElements(),card:{cardholderName:{required:!!this.checkoutConfig?.card?.cardholderName}}}}}var H=Object.freeze({__proto__:null,default:j});const U={[e.PaymentMethod.PAYMENT_CARD]:'\x3c!-- Card Payments Section --\x3e\n<div class="ff-payment-method-card ff-payment-method-payment-card">\n <label class="ff-payment-method-label">\n <input type="radio" name="payment-method" value="PAYMENT_CARD" class="ff-payment-method-radio">\n <div class="ff-payment-method-header">\n <div class="ff-card-logos">\n <img class="payment-method-icon" style="max-height: 30px" src="https://assets.fnlfx.com/common/checkout/cards.webp" alt="visa, mastercard">\n </div>\n </div>\n </label>\n <div class="ff-payment-method-content">\n <div class="ff-card-form-container ff-payment-container" id="cardForm">\n <div class="loader-container">\n <div class="loader"></div>\n </div>\n <div class="payment-errors-container"></div>\n <button class="ff-card-form-submit-button" id="submitButton">\n Continue\n </button>\n <p class="ff-security-message">\n Your payment information is secure with SSL/TLS encryption\n </p>\n </div>\n </div>\n</div>\n',[e.PaymentMethod.PAYPAL]:'<div class="ff-payment-method-card ff-payment-method-paypal">\n <label class="ff-payment-method-label">\n <input type="radio" name="payment-method" value="PAYPAL" class="ff-payment-method-radio">\n <div class="ff-payment-method-header">\n <div class="ff-payment-logo ff-paypal-logo">\n <img class="payment-method-icon" style="max-height: 22px" src="https://assets.fnlfx.com/common/checkout/paypal.webp" alt="PayPal logo">\n </div>\n </div>\n </label>\n <div class="ff-payment-method-content">\n <ul class="ff-payment-features">\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span> Fast, convenient payment option </span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span> Keeps your financial info safe with end-to-end encryption </span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span> Backed by PayPal’s industry-leading fraud protection </span>\n </li>\n </ul>\n <div class="ff-paypal-button-container ff-payment-container" id="paypalButton"></div>\n <div class="loader-container payment-button-loader">\n <div class="loader"></div>\n </div>\n <div class="payment-errors-container"></div>\n <p class="ff-security-message">\n Your payment information is secure with SSL/TLS encryption\n </p>\n </div>\n</div>\n',[e.PaymentMethod.GOOGLE_PAY]:'\x3c!-- Google Pay Section --\x3e\n<div class="ff-payment-method-card ff-payment-method-google-pay">\n <label class="ff-payment-method-label">\n <input type="radio" name="payment-method" value="GOOGLE_PAY" class="ff-payment-method-radio" checked="checked">\n <div class="ff-payment-method-header">\n <div class="ff-payment-logo ff-google-pay-logo">\n <svg class="payment-method-icon" height="26" viewBox="0 0 59 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M27.3601 11.6862V18.4674H25.208V1.72177H30.9132C32.3591 1.72177 33.592 2.20374 34.6008 3.16768C35.632 4.13162 36.1476 5.30852 36.1476 6.69838C36.1476 8.12187 35.632 9.29877 34.6008 10.2515C33.6032 11.2042 32.3703 11.675 30.9132 11.675H27.3601V11.6862ZM27.3601 3.78415V9.62382H30.958C31.8099 9.62382 32.5272 9.3324 33.0876 8.76076C33.6593 8.18912 33.9507 7.49419 33.9507 6.70959C33.9507 5.9362 33.6593 5.25248 33.0876 4.68084C32.5272 4.08678 31.8211 3.79536 30.958 3.79536H27.3601V3.78415Z" fill="currentColor"/>\n <path d="M41.7742 6.63107C43.3658 6.63107 44.6212 7.057 45.5403 7.90885C46.4594 8.7607 46.9189 9.9264 46.9189 11.4059V18.4673H44.8677V16.8757H44.7781C43.8926 18.1871 42.7045 18.8372 41.225 18.8372C39.9584 18.8372 38.9048 18.4673 38.0529 17.7164C37.2011 16.9654 36.7751 16.0351 36.7751 14.9142C36.7751 13.7261 37.2235 12.7846 38.1202 12.0896C39.0169 11.3835 40.2162 11.036 41.7069 11.036C42.9847 11.036 44.0383 11.2714 44.8565 11.7422V11.249C44.8565 10.498 44.5651 9.87035 43.9711 9.34355C43.377 8.81674 42.6821 8.55895 41.8863 8.55895C40.6869 8.55895 39.7342 9.06333 39.0393 10.0833L37.145 8.8952C38.1874 7.38205 39.7342 6.63107 41.7742 6.63107ZM38.9944 14.9478C38.9944 15.5083 39.2298 15.979 39.7118 16.3489C40.1826 16.7188 40.743 16.9093 41.3819 16.9093C42.2898 16.9093 43.0968 16.5731 43.8029 15.9006C44.5091 15.228 44.8677 14.4435 44.8677 13.5356C44.1952 13.0088 43.2649 12.7397 42.0656 12.7397C41.1913 12.7397 40.4628 12.9527 39.8799 13.3674C39.2859 13.8046 38.9944 14.3314 38.9944 14.9478Z" fill="currentColor"/>\n <path d="M58.6207 7.00095L51.4472 23.5H49.2279L51.8955 17.7276L47.1655 7.00095H49.5081L52.9155 15.228H52.9604L56.2781 7.00095H58.6207Z" fill="currentColor"/>\n <path d="M18.8001 10.3187C18.8001 9.61709 18.7373 8.94569 18.6208 8.30008H9.6001V11.9989L14.7953 12C14.5846 13.2307 13.9064 14.2799 12.8674 14.9793V17.379H15.9598C17.7655 15.7078 18.8001 13.2375 18.8001 10.3187Z" fill="#4285F4"/>\n <path d="M12.8685 14.9793C12.0076 15.5599 10.8991 15.8995 9.60228 15.8995C7.09717 15.8995 4.97202 14.2115 4.21096 11.9361H1.021V14.411C2.60141 17.5472 5.84965 19.6992 9.60228 19.6992C12.1959 19.6992 14.3749 18.8462 15.9609 17.3779L12.8685 14.9793Z" fill="#34A853"/>\n <path d="M3.91043 10.1002C3.91043 9.46129 4.01691 8.8437 4.21082 8.26309V5.78824H1.02086C0.367396 7.08507 -0.000244141 8.54891 -0.000244141 10.1002C-0.000244141 11.6514 0.368516 13.1153 1.02086 14.4121L4.21082 11.9373C4.01691 11.3567 3.91043 10.7391 3.91043 10.1002Z" fill="#FABB05"/>\n <path d="M9.60228 4.29974C11.0179 4.29974 12.2856 4.78731 13.2865 5.74004L16.027 3.00179C14.3626 1.45164 12.1926 0.500031 9.60228 0.500031C5.85077 0.500031 2.60141 2.65208 1.021 5.78824L4.21096 8.26309C4.97202 5.98775 7.09717 4.29974 9.60228 4.29974Z" fill="#E94235"/>\n </svg>\n </div>\n </div>\n </label>\n <div class="ff-payment-method-content">\n <ul class="ff-payment-features">\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Easy and private payments with Face/Touch ID</span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Keeps your financial info safe with end-to-end encryption</span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Protected by Google Pay\'s unique Device Account Number</span>\n </li>\n </ul>\n <div class="ff-google-pay-button-container ff-payment-container" id="googlePayButton"></div>\n <div class="loader-container payment-button-loader">\n <div class="loader"></div>\n </div>\n <div class="payment-errors-container"></div>\n <p class="ff-security-message">\n Your payment information is secure with SSL/TLS encryption\n </p>\n </div>\n</div>\n',[e.PaymentMethod.APPLE_PAY]:'\x3c!-- Apple Pay Section --\x3e\n<div class="ff-payment-method-card ff-payment-method-apple-pay">\n <label class="ff-payment-method-label">\n <input type="radio" name="payment-method" value="APPLE_PAY" class="ff-payment-method-radio">\n <div class="ff-payment-method-header">\n <div class="ff-payment-logo ff-apple-pay-logo">\n <svg class="payment-method-icon" height="26" viewBox="0 0 63 26" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M8.41022 4.82398C9.5916 4.92293 10.773 4.23026 11.5113 3.35205C12.2374 2.4491 12.7173 1.23692 12.5943 0C11.5483 0.0494767 10.2561 0.692674 9.51777 1.59562C8.84093 2.37488 8.26255 3.63654 8.41022 4.82398ZM22.4638 20.7555V1.47193H29.6628C33.3793 1.47193 35.9758 4.04471 35.9758 7.80494C35.9758 11.5652 33.33 14.1627 29.5644 14.1627H25.4418V20.7555H22.4638ZM12.5819 5.05898C11.5411 4.99877 10.5914 5.37358 9.82438 5.67633C9.33075 5.87116 8.91274 6.03614 8.59472 6.03614C8.23784 6.03614 7.80257 5.86234 7.31387 5.66719C6.6735 5.4115 5.94138 5.11916 5.17364 5.13319C3.41387 5.15793 1.77716 6.15983 0.878819 7.75545C-0.967091 10.9467 0.398882 15.6717 2.18326 18.2693C3.05699 19.5556 4.10301 20.9657 5.48129 20.9163C6.08765 20.8933 6.52383 20.7072 6.97524 20.5147C7.49492 20.293 8.0348 20.0628 8.87776 20.0628C9.69151 20.0628 10.2078 20.287 10.7033 20.5023C11.1746 20.707 11.6271 20.9036 12.2989 20.8915C13.7264 20.8668 14.6247 19.6051 15.4984 18.3187C16.4413 16.9381 16.8557 15.5906 16.9186 15.3861C16.9222 15.3745 16.9246 15.3665 16.9259 15.3625C16.9244 15.361 16.9128 15.3556 16.8922 15.3462C16.577 15.2011 14.1679 14.0926 14.1448 11.1199C14.1216 8.62473 16.0556 7.36054 16.3601 7.16153C16.3786 7.14944 16.3911 7.14125 16.3968 7.137C15.1662 5.30636 13.2464 5.10845 12.5819 5.05898ZM41.4153 20.9039C43.2858 20.9039 45.0209 19.9515 45.8085 18.4424H45.8701V20.7555H48.6266V11.157C48.6266 8.37393 46.4115 6.5804 43.0027 6.5804C39.8401 6.5804 37.5019 8.39866 37.4158 10.8972H40.0985C40.32 9.70979 41.4153 8.93054 42.9166 8.93054C44.7379 8.93054 45.7593 9.78401 45.7593 11.3549V12.4186L42.0429 12.6413C38.5849 12.8516 36.7143 14.274 36.7143 16.7479C36.7143 19.2464 38.6464 20.9039 41.4153 20.9039ZM42.215 18.6156C40.6275 18.6156 39.6184 17.8487 39.6184 16.6736C39.6184 15.4615 40.5906 14.7564 42.4488 14.6451L45.7591 14.4348V15.5233C45.7591 17.3292 44.2332 18.6156 42.215 18.6156ZM57.7699 21.51C56.5762 24.8868 55.2103 26 52.306 26C52.0845 26 51.3461 25.9753 51.1739 25.9258V23.6127C51.3585 23.6375 51.8138 23.6622 52.0476 23.6622C53.3643 23.6622 54.1027 23.1056 54.558 21.6584L54.8288 20.8049L49.7833 6.76594H52.8967L56.4039 18.1579H56.4655L59.9727 6.76594H63L57.7699 21.51ZM25.4416 3.99524H28.875C31.4592 3.99524 32.936 5.38059 32.936 7.81731C32.936 10.254 31.4592 11.6518 28.8627 11.6518H25.4416V3.99524Z" fill="currentColor"/>\n </svg>\n </div>\n </div>\n </label>\n <div class="ff-payment-method-content">\n <ul class="ff-payment-features">\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Easy and private payments with Face/Touch ID</span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Keeps your financial info safe with end-to-end encryption</span>\n </li>\n <li class="ff-payment-feature">\n <svg width="13" height="11" viewBox="0 0 13 11" fill="none">\n <path stroke="#F8545D" d="M11.1997 1.80133L6.99269 8.63774C6.68226 9.14218 5.9932 9.24721 5.54659 8.85815L2.19971 5.94254" stroke-width="2.66667" stroke-linecap="round"></path>\n </svg>\n <span>Protected by Apple Pay’s unique Device Account Numbe</span>\n </li>\n </ul>\n <div class="ff-apple-pay-button-container ff-payment-container" id="applePayButton"></div>\n <div class="loader-container payment-button-loader">\n <div class="loader"></div>\n </div>\n <div class="payment-errors-container"></div>\n <p class="ff-security-message">\n Your payment information is secure with Apple Pay encryption\n </p>\n </div>\n</div>\n'};class Y{constructor(t){this.onLoaderChange=e=>{document.querySelectorAll(`${this.containerSelector} .loader-container`)?.forEach(t=>{t.style.display=e?"flex":"none"})},this.onError=(e,t)=>{if(!e)return void this.containerEl.querySelectorAll(".payment-errors-container")?.forEach(e=>{e.innerHTML=""});let n=null;if(t){const e=t.replace("_","-").toLowerCase();n=this.containerEl.querySelector(`.ff-payment-method-${e} .payment-errors-container`)}n&&(n.textContent=e?.message||"")},this.onStatusChange=(e,t)=>{["initializing"].includes(e)||"initializing"!==t||this.onLoaderChange(!1),"updating"===e&&this.onLoaderChange(!0),"ready"===e&&"updating"===t&&this.onLoaderChange(!1)},this.onSuccess=()=>{const e=document.querySelector("#success-screen")?.innerHTML;document.querySelectorAll(".ff-payment-container").forEach(t=>{t.innerHTML=e}),this.onLoaderChange(!1)},this.onDestroy=()=>{this.containerEl.remove()},this.onInputError=e=>{this.cardInstance.onInputError(e)},this.onMethodRender=t=>{const n=t.replace("_","-").toLowerCase(),r=this.containerEl.querySelector(`.ff-payment-method-${n}`);t===e.PaymentMethod.PAYMENT_CARD&&this.cardInstance.onMethodRender(),r&&r.classList.add("visible")},this.onMethodsAvailable=e=>{this.availableMethods=e,this.initAccordion(),e.forEach(this.onMethodRender)},this.onStartPurchase=e=>{this.currentPurchaseMethod=e},this.onPurchaseFailure=e=>{this.currentPurchaseMethod&&this.onError(e,this.currentPurchaseMethod),this.currentPurchaseMethod=null},this.onPurchaseCompleted=()=>{this.currentPurchaseMethod=null},this.containerSelector=t.container,this.paymentMethodOrder=t.paymentMethodOrder;const n=document.querySelector(this.containerSelector);if(!n)throw new Error(`Container element not found for selector: ${this.containerSelector}`);this.containerEl=n,this.checkoutConfig=t}initAccordion(){const e=this.containerEl.querySelectorAll(".ff-payment-method-card"),t=this.containerEl.querySelectorAll(".ff-payment-method-radio"),n=t=>{e.forEach(e=>{const n=e.querySelector(".ff-payment-method-radio");n===t&&n?.checked?e.classList.add("expanded"):e.classList.remove("expanded")})},r=Array.from(t).find(e=>this.availableMethods.includes(e.value));if(!r)throw new Error("Default skin accordion initialization error: No radio button found");setTimeout(()=>{r.checked=!0,n(r)},0),t.forEach(e=>{e.addEventListener("change",()=>{e.checked&&n(e)})})}wireCardInputs(){this.cardInstance.wireCardInputs();const e=this.containerEl.querySelector("#submitButton");if(!e)throw new Error("One or more card input elements are missing in the default skin");this.cardInputElements={...this.cardInstance.getCardInputElements(),button:e}}async init(){this.containerEl.insertAdjacentHTML("beforeend",'<div class="ff-skin-default" id="ff-payment-method-containers">\n <div id="success-screen" style="display: none">\n <div class="success">\n <img alt="Loading" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIHZpZXdCb3g9IjAgMCA1MCA1MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTI1IDAuMTExMzI4QzIwLjA3NzQgMC4xMTEzMjggMTUuMjY1NCAxLjU3MTA0IDExLjE3MjUgNC4zMDU4NkM3LjA3OTUyIDcuMDQwNjkgMy44ODk0NSAxMC45Mjc4IDIuMDA1NjYgMTUuNDc1N0MwLjEyMTg4MyAyMC4wMjM1IC0wLjM3MSAyNS4wMjc4IDAuNTg5MzQzIDI5Ljg1NThDMS41NDk2OSAzNC42ODM4IDMuOTIwMTIgMzkuMTE4NSA3LjQwMDkgNDIuNTk5M0MxMC44ODE3IDQ2LjA4MDEgMTUuMzE2NCA0OC40NTA1IDIwLjE0NDQgNDkuNDEwOUMyNC45NzI0IDUwLjM3MTIgMjkuOTc2NyA0OS44NzgzIDM0LjUyNDYgNDcuOTk0NkMzOS4wNzI0IDQ2LjExMDggNDIuOTU5NSA0Mi45MjA3IDQ1LjY5NDQgMzguODI3N0M0OC40MjkyIDM0LjczNDggNDkuODg4OSAyOS45MjI4IDQ5Ljg4ODkgMjUuMDAwMkM0OS44ODg5IDE4LjM5OTMgNDcuMjY2NyAxMi4wNjg3IDQyLjU5OTEgNy40MDExMkMzNy45MzE1IDIuNzMzNTQgMzEuNjAwOSAwLjExMTMyOCAyNSAwLjExMTMyOFpNNDEuMjU1NiAxNi42NDY5TDIwLjgxNTYgMzcuMDcxM0w4Ljc0NDQ0IDI1LjAwMDJDOC4zMzE4OCAyNC41ODc3IDguMTAwMTEgMjQuMDI4MSA4LjEwMDExIDIzLjQ0NDdDOC4xMDAxMSAyMi44NjEyIDguMzMxODggMjIuMzAxNyA4Ljc0NDQ0IDIxLjg4OTFDOS4xNTcgMjEuNDc2NSA5LjcxNjU1IDIxLjI0NDggMTAuMyAyMS4yNDQ4QzEwLjg4MzQgMjEuMjQ0OCAxMS40NDMgMjEuNDc2NSAxMS44NTU2IDIxLjg4OTFMMjAuODQ2NyAzMC44ODAyTDM4LjE3NTYgMTMuNTY2OUMzOC4zNzk4IDEzLjM2MjYgMzguNjIyMyAxMy4yMDA2IDM4Ljg4OTIgMTMuMDlDMzkuMTU2MiAxMi45Nzk1IDM5LjQ0MjIgMTIuOTIyNiAzOS43MzExIDEyLjkyMjZDNDAuMDIgMTIuOTIyNiA0MC4zMDYxIDEyLjk3OTUgNDAuNTczIDEzLjA5QzQwLjgzOTkgMTMuMjAwNiA0MS4wODI0IDEzLjM2MjYgNDEuMjg2NyAxMy41NjY5QzQxLjQ5MDkgMTMuNzcxMiA0MS42NTMgMTQuMDEzNyA0MS43NjM1IDE0LjI4MDZDNDEuODc0MSAxNC41NDc1IDQxLjkzMSAxNC44MzM1IDQxLjkzMSAxNS4xMjI0QzQxLjkzMSAxNS40MTEzIDQxLjg3NDEgMTUuNjk3NCA0MS43NjM1IDE1Ljk2NDNDNDEuNjUzIDE2LjIzMTIgNDEuNDkwOSAxNi40NzM3IDQxLjI4NjcgMTYuNjc4TDQxLjI1NTYgMTYuNjQ2OVoiIGZpbGw9IiM4RURGQzIiLz4KPC9zdmc+Cg==">\n <div>Payment completed successfully</div>\n </div>\n </div>\n</div>\n');const e=this.containerEl.querySelector("#ff-payment-method-containers");this.paymentMethodOrder.forEach(t=>{e.insertAdjacentHTML("beforeend",U[t])}),this.cardInstance=new j(document.querySelector("#cardForm"),this.checkoutConfig),this.cardInstance.init(),this.wireCardInputs()}renderCardForm(){}getCardInputSelectors(){return{...this.cardInstance.getCardInputSelectors(),button:"#submitButton"}}getCardInputElements(){return{...this.cardInstance.getCardInputElements(),button:this.cardInputElements.button}}getPaymentButtonElements(){return{paypal:this.containerEl.querySelector("#paypalButton"),googlePay:this.containerEl.querySelector("#googlePayButton"),applePay:this.containerEl.querySelector("#applePayButton")}}getCheckoutOptions(){return{...this.cardInstance.getCheckoutOptions(),cardElements:this.getCardInputElements(),paymentButtonElements:this.getPaymentButtonElements(),applePay:{buttonStyle:"black"},paypal:{buttonColor:"gold",buttonShape:"pill",buttonLabel:"pay",buttonSize:"large",buttonHeight:54},googlePay:{buttonColor:"black",buttonSizeMode:"fill",buttonType:"pay"}}}}var q=Object.freeze({__proto__:null,default:async e=>{const t=new Y(e);return await t.init(),t}});e.APIError=o,e.Billing=z,e.CHECKOUT_STATES={INITIALIZING:"initializing",READY:"ready",PROCESSING:"processing",ACTION_REQUIRED:"action_required",UPDATING:"updating",COMPLETED:"completed",ERROR:"error",DESTROYED:"destroyed"},e.CheckoutError=a,e.ConfigurationError=class extends n{constructor(e){super(e,I.CONFIGURATION_ERROR),this.name="ConfigurationError"}},e.DEFAULTS=y,e.ERROR_CODES=I,e.EVENTS=g,e.FunnefoxSDKError=n,e.NetworkError=s,e.PrimerError=i,e.SDK_VERSION="0.5.0",e.ValidationError=r,e.configure=T,e.createCheckout=N,e.createClientSession=O,e.default=z,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelfox/billing",
|
|
3
|
-
"version": "0.5.0
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Funnelfox",
|
|
6
6
|
"description": "JavaScript SDK for Funnelfox billing with Primer integration",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "rm -rf dist && rollup -c",
|
|
28
28
|
"build:watch": "rollup -c -w",
|
|
29
|
-
"build:examples": "npm run build && npm pack && npm i ./funnelfox-billing-0.5.0
|
|
29
|
+
"build:examples": "npm run build && npm pack && npm i ./funnelfox-billing-0.5.0.tgz --prefix examples/basic && npm run build --prefix examples/basic",
|
|
30
30
|
"dev": "rollup -c -w",
|
|
31
31
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
32
32
|
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
@@ -49,10 +49,8 @@
|
|
|
49
49
|
"javascript",
|
|
50
50
|
"funnelfox"
|
|
51
51
|
],
|
|
52
|
-
"peerDependencies": {
|
|
53
|
-
"@primer-io/checkout-web": "^2.x"
|
|
54
|
-
},
|
|
55
52
|
"devDependencies": {
|
|
53
|
+
"@primer-io/checkout-web": "^2.57.3",
|
|
56
54
|
"@babel/core": "^7.23.0",
|
|
57
55
|
"@babel/preset-env": "^7.23.0",
|
|
58
56
|
"@eslint/js": "^9.39.1",
|