@paystack/inline-js 2.23.0-dev.1 → 2.23.0-dev.2
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/README.md +3 -1
- package/dist/inline.js +323 -280
- package/es/inline.js +323 -280
- package/lib/inline.js +323 -280
- package/package.json +1 -1
package/es/inline.js
CHANGED
|
@@ -14,37 +14,6 @@ function _arrayWithoutHoles(r) {
|
|
|
14
14
|
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
18
|
-
try {
|
|
19
|
-
var i = n[a](c),
|
|
20
|
-
u = i.value;
|
|
21
|
-
} catch (n) {
|
|
22
|
-
return void e(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _asyncToGenerator(n) {
|
|
29
|
-
return function () {
|
|
30
|
-
var t = this,
|
|
31
|
-
e = arguments;
|
|
32
|
-
return new Promise(function (r, o) {
|
|
33
|
-
var a = n.apply(t, e);
|
|
34
|
-
|
|
35
|
-
function _next(n) {
|
|
36
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function _throw(n) {
|
|
40
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
_next(void 0);
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
17
|
function _classCallCheck(a, n) {
|
|
49
18
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
50
19
|
}
|
|
@@ -400,9 +369,9 @@ var defaultCustomApplePayStyles = {
|
|
|
400
369
|
height: '50px',
|
|
401
370
|
width: 'auto',
|
|
402
371
|
borderRadius: '3px',
|
|
403
|
-
padding: '
|
|
372
|
+
padding: '0px',
|
|
404
373
|
locale: 'en',
|
|
405
|
-
type: '
|
|
374
|
+
type: 'plain'
|
|
406
375
|
};
|
|
407
376
|
var parseApplePayCustomStyles = function parseApplePayCustomStyles(styles) {
|
|
408
377
|
if (!(styles && _typeof(styles) === 'object')) {
|
|
@@ -432,6 +401,193 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
|
|
|
432
401
|
};
|
|
433
402
|
var preCheckoutModalCSS = "\n .pre-checkout-modal {\n display: none;\n position: fixed;\n z-index: 1;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100%;\n overflow: auto;\n background-color: rgba(0, 0, 0, 0.75);\n transition: all 0.2s ease;\n }\n\n .pre-checkout-modal.show {\n display: block;\n }\n\n .pre-checkout-modal__content {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n background-color: #fefefe;\n padding: 20px;\n padding-bottom: max(30px, env(safe-area-inset-bottom));\n width: 100%;\n border-radius: 6px 6px 0 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n max-width: 350px;\n\n box-sizing: border-box;\n transform: translateY(238px);\n transition: transform 0.3s cubic-bezier(.16,.81,.32,1);\n }\n\n .modal-wrapper {\n width: 100%;\n }\n\n .payment-info {\n position: relative;\n padding-bottom: 15px;\n border-bottom: solid 1px whitesmoke;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n width: 100%;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n }\n\n .customer-email {\n color: #737373;\n font-size: 13px;\n line-height: 16px;\n }\n\n .customer-info {\n flex: 1;\n text-align: right;\n }\n\n .merchant-logo {\n display: flex;\n align-items: center;\n height: 30px;\n }\n .transaction-amount {\n margin-top: 5px;\n font-size: 13px;\n line-height: 16px;\n color: #737373;\n }\n\n .amount {\n color: #29b263;\n font-weight: bold;\n }\n\n @media only screen and (min-width: 500px) {\n .pre-checkout-modal__content {\n bottom: 0;\n top: 0;\n margin: auto;\n border-radius: 6px;\n height: fit-content;\n }\n }\n\n .pre-checkout-modal__content.show {\n transform: translateY(0);\n margin: 0 auto;\n margin-top: 100px;\n }\n\n .pre-checkout-modal__content > * {\n margin-top: 0;\n margin-bottom: 40px;\n }\n .pre-checkout-modal__content > *:last-child {\n margin-bottom: 0;\n }\n\n .pre-checkout-modal__content svg {\n margin: auto;\n width: 100%;\n }\n\n #inline-button-wordmark--white {\n position: absolute;\n bottom: -50px;\n margin: auto;\n left: 0;\n right: 0;\n width: fit-content;\n }\n\n #inline-button-wordmark--grey {\n display: none;\n }\n\n .pre-checkout-modal__content #apple-pay-mark--light {\n margin-bottom: 16px;\n }\n\n .pre-checkout-modal p {\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n color: #4E4E4E;\n line-height: 140%;\n font-size: 14px;\n font-weight: 500;\n margin: 0;\n padding: 0 20px;\n text-align: center;\n letter-spacing: -0.3px;\n }\n\n .pre-checkout-modal button {\n height: 42px;\n width: 100%;\n \n box-sizing: border-box;\n border-radius: 3px;\n font-size: 14px;\n line-height: 24px;\n cursor: pointer;\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n }\n\n .pre-checkout-modal .open-paystack-pop-button {\n background: #FAFAFA;\n border: 1px solid #F2F3F3;\n color: #4E4E4E;\n font-weight: 500;\n }\n\n .pre-checkout-modal .open-paystack-pop-button:hover, \n .pre-checkout-modal .open-paystack-pop-button:active, \n .pre-checkout-modal .open-paystack-pop-button:focus {\n background: #F2F3F3;\n }\n\n .pre-checkout-modal .pay-with-vault-button {\n font-weight: 700;\n background: #44b669;\n background: linear-gradient(to bottom, #44b669 0%, #40ad57 100%);\n border: solid 1px #49a861;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n outline: none;\n color: white;\n transition: all 300ms;\n }\n\n .pre-checkout-modal .vault-instruction {\n color: #2f3d4d;\n font-size: 14px;\n letter-spacing: normal;\n line-height: 1.4;\n margin: 0 auto 24px;\n padding: 0;\n }\n .vault-logo-container {\n width: 74px;\n height: 20px;\n margin: 0 auto 24px\n }\n .vault-logo-container img {\n height: 100%;\n width: 100%;\n border-radius: 8px;\n }\n .vault-divider {\n margin-bottom: 16px;\n margin-top: 24px;\n position: relative;\n }\n .vault-divider__container {\n align-items: center;\n bottom: 0;\n display: flex;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n }\n .vault-divider__line {\n border: 1px dashed #ccced0;\n width: 100%;\n }\n .vault-divider__text-container {\n display: flex;\n justify-content: center;\n position: relative;\n }\n .vault-divider__text {\n background-color: #fff;\n color: #999da1;\n font-size: 14px;\n font-weight: 500;\n letter-spacing: -.3px;\n line-height: 19.6px;\n margin-bottom: 2px;\n padding: 0 8px;\n }\n\n #payment-request-button {\n width: 100%;\n height: fit-content;\n margin: 24px 0 16px 0;\n }\n\n #paystackpop-button {\n padding: 0 16px;\n }\n\n #apple-pay-close-button {\n position: absolute;\n text-align: center;\n top: 0;\n right: -26px;\n height: 16px;\n width: 16px;\n padding: 0;\n display: inline-block;\n z-index: 3;\n border-radius: 50%;\n background: transparent;\n transition: all 300ms;\n outline: none;\n cursor: pointer;\n border: none;\n }\n\n #apple-pay-close-button svg {\n width: initial;\n }\n \n #apple-pay-close-button:hover {\n background-color: #e22b28;\n }\n\n @media only screen and (max-width: 500px) {\n .pre-checkout-modal__content {\n max-width: 500px;\n border-radius: 0;\n padding-bottom: 0;\n }\n\n .modal-wrapper {\n padding: 0;\n }\n\n .vault-logo-container {\n width: 74px;\n height: 20px;\n }\n\n #inline-button-wordmark--white {\n display: none\n }\n \n #inline-button-wordmark--grey {\n display: block;\n width: 100%;\n margin: 16px 0;\n height: 13px;\n }\n\n #apple-pay-close-button {\n display: none;\n }\n }\n";
|
|
434
403
|
|
|
404
|
+
var amountSubunitToBase = function amountSubunitToBase() {
|
|
405
|
+
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
406
|
+
return Number(parseFloat(amount / 100).toFixed(2));
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
var requestConfig = {
|
|
410
|
+
headers: {
|
|
411
|
+
accept: 'application/json, text/plain, */*',
|
|
412
|
+
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
|
|
413
|
+
'content-type': 'application/x-www-form-urlencoded',
|
|
414
|
+
'sec-ch-ua-mobile': '?0',
|
|
415
|
+
'sec-fetch-dest': 'empty',
|
|
416
|
+
'sec-fetch-mode': 'cors',
|
|
417
|
+
'sec-fetch-site': 'cross-site'
|
|
418
|
+
},
|
|
419
|
+
referrerPolicy: 'no-referrer-when-downgrade',
|
|
420
|
+
method: 'POST',
|
|
421
|
+
mode: 'cors',
|
|
422
|
+
credentials: 'omit'
|
|
423
|
+
};
|
|
424
|
+
function createFormBody(params) {
|
|
425
|
+
var formBody = Object.keys(params).reduce(function (formBodyArray, key) {
|
|
426
|
+
var encodedKey = encodeURIComponent(key);
|
|
427
|
+
var encodedValue = encodeURIComponent(params[key]);
|
|
428
|
+
var encodedFormBody = "".concat(encodedKey, "=").concat(encodedValue);
|
|
429
|
+
return [].concat(_toConsumableArray(formBodyArray), [encodedFormBody]);
|
|
430
|
+
}, []);
|
|
431
|
+
return formBody.join('&');
|
|
432
|
+
}
|
|
433
|
+
var APPLE_PAY_CAPABILITY_STATUS = {
|
|
434
|
+
AVAILABLE: 'paymentCredentialsAvailable',
|
|
435
|
+
UNAVAILABLE: 'paymentCredentialsUnavailable',
|
|
436
|
+
UNKNOWN: 'paymentCredentialStatusUnknown',
|
|
437
|
+
UNSUPPORTED: 'applePayUnsupported'
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
var formatIntervalString = function formatIntervalString(interval) {
|
|
441
|
+
var plans = {
|
|
442
|
+
biannually: 'BIANNUAL PLAN',
|
|
443
|
+
annually: 'ANNUAL PLAN'
|
|
444
|
+
};
|
|
445
|
+
return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
|
|
449
|
+
var currency = _ref.currency,
|
|
450
|
+
amount = _ref.amount,
|
|
451
|
+
merchantName = _ref.merchantName,
|
|
452
|
+
interval = _ref.interval;
|
|
453
|
+
return _objectSpread2({
|
|
454
|
+
countryCode: 'NG',
|
|
455
|
+
currencyCode: currency,
|
|
456
|
+
merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
|
|
457
|
+
supportedNetworks: ['visa', 'masterCard'],
|
|
458
|
+
requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
|
|
459
|
+
total: {
|
|
460
|
+
label: "".concat(merchantName, " - Paystack"),
|
|
461
|
+
type: 'final',
|
|
462
|
+
amount: String(amountSubunitToBase(amount))
|
|
463
|
+
}
|
|
464
|
+
}, typeof interval === 'string' && interval.trim() !== '' && {
|
|
465
|
+
lineItems: [{
|
|
466
|
+
label: formatIntervalString(interval),
|
|
467
|
+
amount: String(amountSubunitToBase(amount))
|
|
468
|
+
}]
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
var validateApplePaySession = function validateApplePaySession(_ref2) {
|
|
472
|
+
var transactionId = _ref2.transactionId,
|
|
473
|
+
validationURL = _ref2.validationURL,
|
|
474
|
+
merchantName = _ref2.merchantName,
|
|
475
|
+
_ref2$domainName = _ref2.domainName,
|
|
476
|
+
domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
|
|
477
|
+
var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
|
|
478
|
+
var params = {
|
|
479
|
+
transaction: transactionId,
|
|
480
|
+
sessionUrl: validationURL,
|
|
481
|
+
displayName: merchantName,
|
|
482
|
+
domainName: domainName
|
|
483
|
+
};
|
|
484
|
+
var formBody = createFormBody(params);
|
|
485
|
+
var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
486
|
+
body: formBody
|
|
487
|
+
})).then(function (response) {
|
|
488
|
+
return response.json();
|
|
489
|
+
});
|
|
490
|
+
return validateSession;
|
|
491
|
+
};
|
|
492
|
+
var chargeApplePay = function chargeApplePay(_ref3) {
|
|
493
|
+
var transactionId = _ref3.transactionId,
|
|
494
|
+
payment = _ref3.payment;
|
|
495
|
+
var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
|
|
496
|
+
var params = {
|
|
497
|
+
transaction: transactionId,
|
|
498
|
+
paymentObject: JSON.stringify(payment)
|
|
499
|
+
};
|
|
500
|
+
var formBody = createFormBody(params);
|
|
501
|
+
var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
502
|
+
body: formBody
|
|
503
|
+
})).then(function (response) {
|
|
504
|
+
return response.json();
|
|
505
|
+
});
|
|
506
|
+
return charge;
|
|
507
|
+
};
|
|
508
|
+
var deviceSupportsApplePay = function deviceSupportsApplePay() {
|
|
509
|
+
try {
|
|
510
|
+
return !!(window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion));
|
|
511
|
+
} catch (error) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
var getApplePayCapabilityStatusFromResponse = function getApplePayCapabilityStatusFromResponse(capabilities) {
|
|
517
|
+
if (!capabilities) {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
if (typeof capabilities === 'string') {
|
|
522
|
+
return capabilities;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (typeof capabilities.paymentCredentialStatus === 'string') {
|
|
526
|
+
return capabilities.paymentCredentialStatus;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
return null;
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
var getApplePayCapabilityStatus = function getApplePayCapabilityStatus() {
|
|
533
|
+
try {
|
|
534
|
+
if (!deviceSupportsApplePay()) {
|
|
535
|
+
return Promise.resolve(null);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
var _window = window,
|
|
539
|
+
ApplePaySession = _window.ApplePaySession;
|
|
540
|
+
|
|
541
|
+
if (typeof ApplePaySession.applePayCapabilities === 'function') {
|
|
542
|
+
return Promise.resolve(ApplePaySession.applePayCapabilities()).then(function (capabilities) {
|
|
543
|
+
return getApplePayCapabilityStatusFromResponse(capabilities);
|
|
544
|
+
}).catch(function () {
|
|
545
|
+
try {
|
|
546
|
+
if (window.ApplePaySession.canMakePayments()) {
|
|
547
|
+
return APPLE_PAY_CAPABILITY_STATUS.UNKNOWN;
|
|
548
|
+
}
|
|
549
|
+
} catch (fallbackError) {
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return APPLE_PAY_CAPABILITY_STATUS.UNSUPPORTED;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (typeof ApplePaySession.canMakePayments === 'function') {
|
|
558
|
+
return Promise.resolve(ApplePaySession.canMakePayments()).then(function (canMakePayments) {
|
|
559
|
+
return canMakePayments ? APPLE_PAY_CAPABILITY_STATUS.UNKNOWN : APPLE_PAY_CAPABILITY_STATUS.UNSUPPORTED;
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return Promise.resolve(null);
|
|
564
|
+
} catch (error) {
|
|
565
|
+
try {
|
|
566
|
+
if (window.ApplePaySession.canMakePayments()) {
|
|
567
|
+
return Promise.resolve(APPLE_PAY_CAPABILITY_STATUS.UNKNOWN);
|
|
568
|
+
}
|
|
569
|
+
} catch (fallbackError) {
|
|
570
|
+
return Promise.resolve(null);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
return Promise.resolve(APPLE_PAY_CAPABILITY_STATUS.UNSUPPORTED);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
var applePayCapabilityCanShowButton = function applePayCapabilityCanShowButton(status) {
|
|
577
|
+
return [APPLE_PAY_CAPABILITY_STATUS.AVAILABLE, APPLE_PAY_CAPABILITY_STATUS.UNKNOWN].includes(status);
|
|
578
|
+
};
|
|
579
|
+
var canUseApplePay = function canUseApplePay(channels) {
|
|
580
|
+
var availableChannels = channels || [];
|
|
581
|
+
|
|
582
|
+
if (!availableChannels.includes('apple_pay')) {
|
|
583
|
+
return Promise.resolve(false);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
return getApplePayCapabilityStatus().then(function (capabilityStatus) {
|
|
587
|
+
return applePayCapabilityCanShowButton(capabilityStatus);
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
|
|
435
591
|
/* eslint-env browser */
|
|
436
592
|
function findHighestZIndex() {
|
|
437
593
|
var highestZIndex = 0;
|
|
@@ -491,6 +647,7 @@ function mountEmbedCheckoutIframe(id, src) {
|
|
|
491
647
|
function getApplePayButton(container) {
|
|
492
648
|
return container.querySelector('apple-pay-button') || container.querySelector('#apple-pay-button');
|
|
493
649
|
}
|
|
650
|
+
var applePaySdkPromise;
|
|
494
651
|
var loadScript = function loadScript(url, _ref) {
|
|
495
652
|
var container = _ref.container,
|
|
496
653
|
integrity = _ref.integrity;
|
|
@@ -522,6 +679,31 @@ var loadScript = function loadScript(url, _ref) {
|
|
|
522
679
|
}
|
|
523
680
|
});
|
|
524
681
|
};
|
|
682
|
+
|
|
683
|
+
var applePayButtonComponentIsAvailable = function applePayButtonComponentIsAvailable() {
|
|
684
|
+
return !!(window && window.customElements && window.customElements.get('apple-pay-button'));
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
var ensureApplePaySdkLoaded = function ensureApplePaySdkLoaded(container) {
|
|
688
|
+
if (applePayButtonComponentIsAvailable()) {
|
|
689
|
+
return Promise.resolve(true);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if (applePaySdkPromise) {
|
|
693
|
+
return applePaySdkPromise;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
applePaySdkPromise = loadScript(APPLE_PAY_SDK_SOURCE, {
|
|
697
|
+
container: container,
|
|
698
|
+
integrity: APPLE_PAY_SDK_INTEGRITY_HASH
|
|
699
|
+
}).then(function () {
|
|
700
|
+
return true;
|
|
701
|
+
}).catch(function (error) {
|
|
702
|
+
applePaySdkPromise = null;
|
|
703
|
+
throw error;
|
|
704
|
+
});
|
|
705
|
+
return applePaySdkPromise;
|
|
706
|
+
};
|
|
525
707
|
function appendIframeToContainer(containerId, iframe) {
|
|
526
708
|
var container = document.getElementById(containerId);
|
|
527
709
|
container.innerHTML = '';
|
|
@@ -672,7 +854,7 @@ function mountApplePayFallbackButton(container, _ref3) {
|
|
|
672
854
|
function getPaymentRequestContainer(container) {
|
|
673
855
|
return document.querySelector("#".concat(container));
|
|
674
856
|
}
|
|
675
|
-
function mountPaymentRequestButtons(container, _ref4
|
|
857
|
+
function mountPaymentRequestButtons(container, _ref4) {
|
|
676
858
|
var _ref4$channels = _ref4.channels,
|
|
677
859
|
channels = _ref4$channels === void 0 ? [] : _ref4$channels,
|
|
678
860
|
_ref4$styles = _ref4.styles,
|
|
@@ -680,92 +862,45 @@ function mountPaymentRequestButtons(container, _ref4, merchantId) {
|
|
|
680
862
|
var mountedElements = {
|
|
681
863
|
applePay: false
|
|
682
864
|
};
|
|
683
|
-
return new Promise(function (resolve, reject) {
|
|
684
|
-
if (container) {
|
|
685
|
-
if (!channels.includes('apple_pay')) {
|
|
686
|
-
reject('No wallet payment method is available on this device');
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
if (getApplePayButton(container)) {
|
|
691
|
-
mountedElements.applePay = true;
|
|
692
|
-
resolve(mountedElements);
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
loadScript(APPLE_PAY_SDK_SOURCE, {
|
|
697
|
-
container: container,
|
|
698
|
-
integrity: APPLE_PAY_SDK_INTEGRITY_HASH
|
|
699
|
-
}).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
700
|
-
var _window$ApplePaySessi, capabilities, unsupported, _window$ApplePaySessi2, _window$ApplePaySessi3;
|
|
701
|
-
|
|
702
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
703
|
-
while (1) {
|
|
704
|
-
switch (_context.prev = _context.next) {
|
|
705
|
-
case 0:
|
|
706
|
-
_context.prev = 0;
|
|
707
|
-
_context.next = 3;
|
|
708
|
-
return (_window$ApplePaySessi = window.ApplePaySession) === null || _window$ApplePaySessi === void 0 ? void 0 : _window$ApplePaySessi.applePayCapabilities();
|
|
709
|
-
|
|
710
|
-
case 3:
|
|
711
|
-
capabilities = _context.sent;
|
|
712
|
-
unsupported = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
|
|
713
|
-
|
|
714
|
-
if (!unsupported) {
|
|
715
|
-
_context.next = 7;
|
|
716
|
-
break;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
throw new Error('Apple Pay is not supported on this device');
|
|
720
|
-
|
|
721
|
-
case 7:
|
|
722
|
-
_context.next = 15;
|
|
723
|
-
break;
|
|
724
|
-
|
|
725
|
-
case 9:
|
|
726
|
-
_context.prev = 9;
|
|
727
|
-
_context.t0 = _context["catch"](0);
|
|
728
865
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
throw _context.t0;
|
|
866
|
+
if (!container) {
|
|
867
|
+
return Promise.reject(new Error('Container to mount elements was not provided'));
|
|
868
|
+
}
|
|
735
869
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
break;
|
|
740
|
-
}
|
|
870
|
+
if (!channels.includes('apple_pay')) {
|
|
871
|
+
return Promise.reject(new Error('No wallet payment method is available on this device'));
|
|
872
|
+
}
|
|
741
873
|
|
|
742
|
-
|
|
874
|
+
return ensureApplePaySdkLoaded(container).catch(function () {
|
|
875
|
+
// Safari can still render the fallback button using the native ApplePaySession.
|
|
876
|
+
return null;
|
|
877
|
+
}).then(function () {
|
|
878
|
+
return canUseApplePay(channels);
|
|
879
|
+
}).then(function (applePayAvailable) {
|
|
880
|
+
if (!applePayAvailable) {
|
|
881
|
+
throw new Error('No wallet payment method is available on this device');
|
|
882
|
+
}
|
|
743
883
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
});
|
|
749
|
-
mountedElements.applePay = true;
|
|
750
|
-
resolve(mountedElements);
|
|
884
|
+
if (getApplePayButton(container)) {
|
|
885
|
+
mountedElements.applePay = true;
|
|
886
|
+
return mountedElements;
|
|
887
|
+
}
|
|
751
888
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
});
|
|
763
|
-
mountedElements.applePay = true;
|
|
764
|
-
resolve(mountedElements);
|
|
889
|
+
try {
|
|
890
|
+
mountApplePayButton(container, {
|
|
891
|
+
styles: parseApplePayCustomStyles(styles.applePay),
|
|
892
|
+
theme: styles.theme
|
|
893
|
+
});
|
|
894
|
+
} catch (error) {
|
|
895
|
+
// If the web component is unavailable, fall back to the CSS-based Apple Pay button.
|
|
896
|
+
mountApplePayFallbackButton(container, {
|
|
897
|
+
styles: parseApplePayCustomStyles(styles.applePay),
|
|
898
|
+
theme: styles.theme
|
|
765
899
|
});
|
|
766
|
-
} else {
|
|
767
|
-
reject('Container to mount elements was not provided');
|
|
768
900
|
}
|
|
901
|
+
|
|
902
|
+
mountedElements.applePay = true;
|
|
903
|
+
return mountedElements;
|
|
769
904
|
});
|
|
770
905
|
}
|
|
771
906
|
function removeAllChildNodes(parent) {
|
|
@@ -846,8 +981,8 @@ function vaultPreCheckoutModalView(container) {
|
|
|
846
981
|
}
|
|
847
982
|
}
|
|
848
983
|
|
|
849
|
-
function defaultPreCheckoutModalView(container,
|
|
850
|
-
var hasOtherPaymentMethods =
|
|
984
|
+
function defaultPreCheckoutModalView(container, _ref5) {
|
|
985
|
+
var hasOtherPaymentMethods = _ref5.hasOtherPaymentMethods;
|
|
851
986
|
var applePayIcon = document.createElement('div');
|
|
852
987
|
applePayIcon.innerHTML = applePayMarkLight;
|
|
853
988
|
container.appendChild(applePayIcon);
|
|
@@ -890,14 +1025,14 @@ function mountPreCheckoutModal(id, transaction) {
|
|
|
890
1025
|
content.classList.add('pre-checkout-modal__content');
|
|
891
1026
|
modal.appendChild(content);
|
|
892
1027
|
|
|
893
|
-
var
|
|
894
|
-
merchantLogo =
|
|
895
|
-
merchantName =
|
|
896
|
-
email =
|
|
897
|
-
amount =
|
|
898
|
-
currency =
|
|
899
|
-
label =
|
|
900
|
-
channels =
|
|
1028
|
+
var _ref6 = transaction || {},
|
|
1029
|
+
merchantLogo = _ref6.merchant_logo,
|
|
1030
|
+
merchantName = _ref6.merchant_name,
|
|
1031
|
+
email = _ref6.email,
|
|
1032
|
+
amount = _ref6.amount,
|
|
1033
|
+
currency = _ref6.currency,
|
|
1034
|
+
label = _ref6.label,
|
|
1035
|
+
channels = _ref6.channels;
|
|
901
1036
|
|
|
902
1037
|
var formattedAmount = new Intl.NumberFormat('en', {
|
|
903
1038
|
style: 'currency',
|
|
@@ -1710,116 +1845,6 @@ var InlineTransaction = /*#__PURE__*/function () {
|
|
|
1710
1845
|
return InlineTransaction;
|
|
1711
1846
|
}();
|
|
1712
1847
|
|
|
1713
|
-
var amountSubunitToBase = function amountSubunitToBase() {
|
|
1714
|
-
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
1715
|
-
return Number(parseFloat(amount / 100).toFixed(2));
|
|
1716
|
-
};
|
|
1717
|
-
|
|
1718
|
-
var requestConfig = {
|
|
1719
|
-
headers: {
|
|
1720
|
-
accept: 'application/json, text/plain, */*',
|
|
1721
|
-
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
|
|
1722
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
1723
|
-
'sec-ch-ua-mobile': '?0',
|
|
1724
|
-
'sec-fetch-dest': 'empty',
|
|
1725
|
-
'sec-fetch-mode': 'cors',
|
|
1726
|
-
'sec-fetch-site': 'cross-site'
|
|
1727
|
-
},
|
|
1728
|
-
referrerPolicy: 'no-referrer-when-downgrade',
|
|
1729
|
-
method: 'POST',
|
|
1730
|
-
mode: 'cors',
|
|
1731
|
-
credentials: 'omit'
|
|
1732
|
-
};
|
|
1733
|
-
function createFormBody(params) {
|
|
1734
|
-
var formBody = Object.keys(params).reduce(function (formBodyArray, key) {
|
|
1735
|
-
var encodedKey = encodeURIComponent(key);
|
|
1736
|
-
var encodedValue = encodeURIComponent(params[key]);
|
|
1737
|
-
var encodedFormBody = "".concat(encodedKey, "=").concat(encodedValue);
|
|
1738
|
-
return [].concat(_toConsumableArray(formBodyArray), [encodedFormBody]);
|
|
1739
|
-
}, []);
|
|
1740
|
-
return formBody.join('&');
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
var formatIntervalString = function formatIntervalString(interval) {
|
|
1744
|
-
var plans = {
|
|
1745
|
-
biannually: 'BIANNUAL PLAN',
|
|
1746
|
-
annually: 'ANNUAL PLAN'
|
|
1747
|
-
};
|
|
1748
|
-
return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
|
|
1749
|
-
};
|
|
1750
|
-
|
|
1751
|
-
var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
|
|
1752
|
-
var currency = _ref.currency,
|
|
1753
|
-
amount = _ref.amount,
|
|
1754
|
-
merchantName = _ref.merchantName,
|
|
1755
|
-
interval = _ref.interval;
|
|
1756
|
-
return _objectSpread2({
|
|
1757
|
-
countryCode: 'NG',
|
|
1758
|
-
currencyCode: currency,
|
|
1759
|
-
merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
|
|
1760
|
-
supportedNetworks: ['visa', 'masterCard'],
|
|
1761
|
-
requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
|
|
1762
|
-
total: {
|
|
1763
|
-
label: "".concat(merchantName, " - Paystack"),
|
|
1764
|
-
type: 'final',
|
|
1765
|
-
amount: String(amountSubunitToBase(amount))
|
|
1766
|
-
}
|
|
1767
|
-
}, typeof interval === 'string' && interval.trim() !== '' && {
|
|
1768
|
-
lineItems: [{
|
|
1769
|
-
label: formatIntervalString(interval),
|
|
1770
|
-
amount: String(amountSubunitToBase(amount))
|
|
1771
|
-
}]
|
|
1772
|
-
});
|
|
1773
|
-
};
|
|
1774
|
-
var validateApplePaySession = function validateApplePaySession(_ref2) {
|
|
1775
|
-
var transactionId = _ref2.transactionId,
|
|
1776
|
-
validationURL = _ref2.validationURL,
|
|
1777
|
-
merchantName = _ref2.merchantName,
|
|
1778
|
-
_ref2$domainName = _ref2.domainName,
|
|
1779
|
-
domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
|
|
1780
|
-
var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
|
|
1781
|
-
var params = {
|
|
1782
|
-
transaction: transactionId,
|
|
1783
|
-
sessionUrl: validationURL,
|
|
1784
|
-
displayName: merchantName,
|
|
1785
|
-
domainName: domainName
|
|
1786
|
-
};
|
|
1787
|
-
var formBody = createFormBody(params);
|
|
1788
|
-
var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
1789
|
-
body: formBody
|
|
1790
|
-
})).then(function (response) {
|
|
1791
|
-
return response.json();
|
|
1792
|
-
});
|
|
1793
|
-
return validateSession;
|
|
1794
|
-
};
|
|
1795
|
-
var chargeApplePay = function chargeApplePay(_ref3) {
|
|
1796
|
-
var transactionId = _ref3.transactionId,
|
|
1797
|
-
payment = _ref3.payment;
|
|
1798
|
-
var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
|
|
1799
|
-
var params = {
|
|
1800
|
-
transaction: transactionId,
|
|
1801
|
-
paymentObject: JSON.stringify(payment)
|
|
1802
|
-
};
|
|
1803
|
-
var formBody = createFormBody(params);
|
|
1804
|
-
var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
1805
|
-
body: formBody
|
|
1806
|
-
})).then(function (response) {
|
|
1807
|
-
return response.json();
|
|
1808
|
-
});
|
|
1809
|
-
return charge;
|
|
1810
|
-
};
|
|
1811
|
-
var deviceSupportsApplePay = function deviceSupportsApplePay() {
|
|
1812
|
-
try {
|
|
1813
|
-
return window.location && window.location.protocol === 'https:' && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
|
|
1814
|
-
} catch (error) {
|
|
1815
|
-
return false;
|
|
1816
|
-
}
|
|
1817
|
-
};
|
|
1818
|
-
var canUseApplePay = function canUseApplePay() {
|
|
1819
|
-
var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1820
|
-
return deviceSupportsApplePay() && channels.includes('apple_pay');
|
|
1821
|
-
};
|
|
1822
|
-
|
|
1823
1848
|
var canUseVault = function canUseVault() {
|
|
1824
1849
|
var _transaction$link_con, _transaction$link_con2;
|
|
1825
1850
|
|
|
@@ -1878,6 +1903,19 @@ function handleError(message) {
|
|
|
1878
1903
|
throw new Error(message);
|
|
1879
1904
|
}
|
|
1880
1905
|
|
|
1906
|
+
function transactionCanUseApplePay(response, container) {
|
|
1907
|
+
if (!(response && response.channels && response.channels.includes('apple_pay'))) {
|
|
1908
|
+
return Promise.resolve(false);
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
return ensureApplePaySdkLoaded(container).catch(function () {
|
|
1912
|
+
// Native Apple Pay support can still be available even if the SDK fails to load.
|
|
1913
|
+
return null;
|
|
1914
|
+
}).then(function () {
|
|
1915
|
+
return canUseApplePay(response.channels);
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1881
1919
|
var Inline = /*#__PURE__*/function () {
|
|
1882
1920
|
function Inline(params) {
|
|
1883
1921
|
_classCallCheck(this, Inline);
|
|
@@ -1943,7 +1981,15 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1943
1981
|
var transaction = resumableTransaction || new InlineTransaction(params);
|
|
1944
1982
|
return new Promise(function (resolve, reject) {
|
|
1945
1983
|
transaction.requestInline().then(function (response) {
|
|
1946
|
-
|
|
1984
|
+
return transactionCanUseApplePay(response).then(function (canPayWithApplePay) {
|
|
1985
|
+
return {
|
|
1986
|
+
response: response,
|
|
1987
|
+
canPayWithApplePay: canPayWithApplePay
|
|
1988
|
+
};
|
|
1989
|
+
});
|
|
1990
|
+
}).then(function (_ref) {
|
|
1991
|
+
var response = _ref.response,
|
|
1992
|
+
canPayWithApplePay = _ref.canPayWithApplePay;
|
|
1947
1993
|
var canPayWithVault = canUseVault(response);
|
|
1948
1994
|
var shouldLoadPreCheckoutModal = canPayWithVault || canPayWithApplePay;
|
|
1949
1995
|
|
|
@@ -1981,7 +2027,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
1981
2027
|
}
|
|
1982
2028
|
}
|
|
1983
2029
|
}, response.merchant_id).then(function () {
|
|
1984
|
-
inlineInstance.registerPaymentRequestEventListeners();
|
|
2030
|
+
return inlineInstance.registerPaymentRequestEventListeners();
|
|
1985
2031
|
}).catch(function () {
|
|
1986
2032
|
/**
|
|
1987
2033
|
* If an error occurs when mounting the apple pay button,
|
|
@@ -2094,6 +2140,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2094
2140
|
|
|
2095
2141
|
if (transactionStatus === 'failed') {
|
|
2096
2142
|
showErrorInPreCheckoutModal(this.preCheckoutModal);
|
|
2143
|
+
animatePreCheckoutModalIn(this.preCheckoutModal);
|
|
2097
2144
|
} else {
|
|
2098
2145
|
hidePreCheckoutModal(this.preCheckoutModal);
|
|
2099
2146
|
this.preCheckoutModal.remove();
|
|
@@ -2115,11 +2162,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2115
2162
|
}
|
|
2116
2163
|
}, {
|
|
2117
2164
|
key: "newTransaction",
|
|
2118
|
-
value: function newTransaction(
|
|
2119
|
-
var preload =
|
|
2120
|
-
inlineTransaction =
|
|
2121
|
-
transactionData =
|
|
2122
|
-
options = _objectWithoutProperties(
|
|
2165
|
+
value: function newTransaction(_ref2) {
|
|
2166
|
+
var preload = _ref2.preload,
|
|
2167
|
+
inlineTransaction = _ref2.inlineTransaction,
|
|
2168
|
+
transactionData = _ref2.transactionData,
|
|
2169
|
+
options = _objectWithoutProperties(_ref2, _excluded);
|
|
2123
2170
|
|
|
2124
2171
|
var hasPaymentRequestButtons = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2125
2172
|
|
|
@@ -2198,25 +2245,6 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2198
2245
|
return new Promise(function (resolve, reject) {
|
|
2199
2246
|
var loadPaystackCheckoutButton = document.querySelector("#".concat(parameters.loadPaystackCheckoutButton));
|
|
2200
2247
|
|
|
2201
|
-
if (!deviceSupportsApplePay()) {
|
|
2202
|
-
if (parameters && parameters.loadPaystackCheckoutButton) {
|
|
2203
|
-
if (loadPaystackCheckoutButton) {
|
|
2204
|
-
var loadPopup = inlineInstance.preloadTransaction(transactionParams);
|
|
2205
|
-
loadPaystackCheckoutButton.onclick = loadPopup;
|
|
2206
|
-
} else {
|
|
2207
|
-
logWarning("This device does not support any payment request wallet options. Please consult our documentation at https://developers.paystack.co/docs/paystack-inline to see how to load alternative payment options using 'loadPaystackCheckoutButton'");
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
|
|
2211
|
-
if (onElementsMount) {
|
|
2212
|
-
onElementsMount(null);
|
|
2213
|
-
}
|
|
2214
|
-
|
|
2215
|
-
var activeTransaction = inlineInstance.activeTransaction();
|
|
2216
|
-
resolve(activeTransaction);
|
|
2217
|
-
return;
|
|
2218
|
-
}
|
|
2219
|
-
|
|
2220
2248
|
if (inlineInstance.activeTransaction()) {
|
|
2221
2249
|
inlineInstance.activeTransaction().cancel();
|
|
2222
2250
|
}
|
|
@@ -2250,12 +2278,11 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2250
2278
|
inlineInstance.registerPaymentRequestEventListeners();
|
|
2251
2279
|
|
|
2252
2280
|
if (loadPaystackCheckoutButton) {
|
|
2253
|
-
var
|
|
2281
|
+
var loadPopup = inlineInstance.preloadTransaction({
|
|
2254
2282
|
inlineTransaction: transaction,
|
|
2255
2283
|
transactionData: response
|
|
2256
2284
|
});
|
|
2257
|
-
|
|
2258
|
-
loadPaystackCheckoutButton.onclick = _loadPopup;
|
|
2285
|
+
loadPaystackCheckoutButton.onclick = loadPopup;
|
|
2259
2286
|
}
|
|
2260
2287
|
|
|
2261
2288
|
resolve(transaction);
|
|
@@ -2276,22 +2303,21 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2276
2303
|
|
|
2277
2304
|
var applePayButton = getApplePayButton(this.paymentRequestContainer);
|
|
2278
2305
|
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2306
|
+
if (applePayButton) {
|
|
2307
|
+
applePayButton.onclick = function () {
|
|
2308
|
+
return _this4.startApplePay();
|
|
2309
|
+
};
|
|
2310
|
+
}
|
|
2282
2311
|
}
|
|
2283
2312
|
}, {
|
|
2284
2313
|
key: "registerPaymentRequestEventListeners",
|
|
2285
2314
|
value: function registerPaymentRequestEventListeners() {
|
|
2286
2315
|
var transaction = this.activeTransaction();
|
|
2316
|
+
var applePayButton = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2287
2317
|
|
|
2288
|
-
if (transaction) {
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
} else {
|
|
2292
|
-
removeAllChildNodes(this.paymentRequestContainer);
|
|
2293
|
-
}
|
|
2294
|
-
} else {
|
|
2318
|
+
if (transaction && applePayButton) {
|
|
2319
|
+
this.registerApplePayEventListener();
|
|
2320
|
+
} else if (this.paymentRequestContainer) {
|
|
2295
2321
|
removeAllChildNodes(this.paymentRequestContainer);
|
|
2296
2322
|
}
|
|
2297
2323
|
}
|
|
@@ -2316,6 +2342,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2316
2342
|
amount: transaction.amount,
|
|
2317
2343
|
timeSpent: transaction.getTimeSpent()
|
|
2318
2344
|
};
|
|
2345
|
+
var pendingPreCheckoutModalStatus = null;
|
|
2319
2346
|
|
|
2320
2347
|
try {
|
|
2321
2348
|
transaction.logAttempt(paymentMethod);
|
|
@@ -2328,8 +2355,12 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2328
2355
|
});
|
|
2329
2356
|
var applePaySession = new window.ApplePaySession(config.applePayVersion, applePayPaymentRequest);
|
|
2330
2357
|
|
|
2331
|
-
|
|
2332
|
-
|
|
2358
|
+
if (inlineInstance.preCheckoutModal) {
|
|
2359
|
+
hidePreCheckoutModal(inlineInstance.preCheckoutModal);
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
applePaySession.onvalidatemerchant = function (_ref3) {
|
|
2363
|
+
var validationURL = _ref3.validationURL;
|
|
2333
2364
|
var validateSession = validateApplePaySession({
|
|
2334
2365
|
validationURL: validationURL,
|
|
2335
2366
|
transactionId: transaction.id,
|
|
@@ -2338,6 +2369,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2338
2369
|
validateSession.then(function (response) {
|
|
2339
2370
|
if (response.status !== 'success') {
|
|
2340
2371
|
transaction.onSetupError(response);
|
|
2372
|
+
pendingPreCheckoutModalStatus = 'failed';
|
|
2341
2373
|
} else {
|
|
2342
2374
|
applePaySession.completeMerchantValidation(response.data);
|
|
2343
2375
|
}
|
|
@@ -2345,17 +2377,25 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2345
2377
|
transaction.logValidationResponse(response.message);
|
|
2346
2378
|
}).catch(function (error) {
|
|
2347
2379
|
transaction.onSetupError(error);
|
|
2380
|
+
pendingPreCheckoutModalStatus = 'failed';
|
|
2348
2381
|
});
|
|
2349
2382
|
};
|
|
2350
2383
|
|
|
2351
2384
|
applePaySession.oncancel = function () {
|
|
2352
|
-
if (
|
|
2385
|
+
if (inlineInstance.preCheckoutModal) {
|
|
2386
|
+
if (pendingPreCheckoutModalStatus) {
|
|
2387
|
+
inlineInstance.closePreCheckoutModal(pendingPreCheckoutModalStatus);
|
|
2388
|
+
pendingPreCheckoutModalStatus = null;
|
|
2389
|
+
} else {
|
|
2390
|
+
animatePreCheckoutModalIn(inlineInstance.preCheckoutModal);
|
|
2391
|
+
}
|
|
2392
|
+
} else {
|
|
2353
2393
|
transaction.onCancel();
|
|
2354
2394
|
}
|
|
2355
2395
|
};
|
|
2356
2396
|
|
|
2357
|
-
applePaySession.onpaymentauthorized = function (
|
|
2358
|
-
var payment =
|
|
2397
|
+
applePaySession.onpaymentauthorized = function (_ref4) {
|
|
2398
|
+
var payment = _ref4.payment;
|
|
2359
2399
|
var charge = chargeApplePay({
|
|
2360
2400
|
transactionId: transaction.id,
|
|
2361
2401
|
payment: payment
|
|
@@ -2371,6 +2411,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2371
2411
|
} else {
|
|
2372
2412
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2373
2413
|
transaction.onSetupError(response);
|
|
2414
|
+
pendingPreCheckoutModalStatus = 'failed';
|
|
2374
2415
|
|
|
2375
2416
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2376
2417
|
channel: 'apple_pay',
|
|
@@ -2378,23 +2419,25 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2378
2419
|
});
|
|
2379
2420
|
}
|
|
2380
2421
|
|
|
2381
|
-
|
|
2422
|
+
if (response.status === 'success') {
|
|
2423
|
+
inlineInstance.closePreCheckoutModal(response.status);
|
|
2424
|
+
}
|
|
2382
2425
|
}).catch(function (error) {
|
|
2383
2426
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2384
2427
|
transaction.onSetupError(error);
|
|
2428
|
+
pendingPreCheckoutModalStatus = 'failed';
|
|
2385
2429
|
|
|
2386
2430
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2387
2431
|
channel: 'apple_pay',
|
|
2388
2432
|
message: error && error.message || 'Error occurred'
|
|
2389
2433
|
});
|
|
2390
|
-
|
|
2391
|
-
inlineInstance.closePreCheckoutModal('failed');
|
|
2392
2434
|
});
|
|
2393
2435
|
};
|
|
2394
2436
|
|
|
2395
2437
|
applePaySession.begin();
|
|
2396
2438
|
} catch (error) {
|
|
2397
2439
|
transaction.onSetupError(error);
|
|
2440
|
+
inlineInstance.closePreCheckoutModal('failed');
|
|
2398
2441
|
}
|
|
2399
2442
|
} else {
|
|
2400
2443
|
handleError('Could not initiate apple pay transaction');
|