@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/dist/inline.js
CHANGED
|
@@ -17,37 +17,6 @@ var PaystackPop = (function () {
|
|
|
17
17
|
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
21
|
-
try {
|
|
22
|
-
var i = n[a](c),
|
|
23
|
-
u = i.value;
|
|
24
|
-
} catch (n) {
|
|
25
|
-
return void e(n);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function _asyncToGenerator(n) {
|
|
32
|
-
return function () {
|
|
33
|
-
var t = this,
|
|
34
|
-
e = arguments;
|
|
35
|
-
return new Promise(function (r, o) {
|
|
36
|
-
var a = n.apply(t, e);
|
|
37
|
-
|
|
38
|
-
function _next(n) {
|
|
39
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _throw(n) {
|
|
43
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
_next(void 0);
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
20
|
function _classCallCheck(a, n) {
|
|
52
21
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
53
22
|
}
|
|
@@ -403,9 +372,9 @@ var PaystackPop = (function () {
|
|
|
403
372
|
height: '50px',
|
|
404
373
|
width: 'auto',
|
|
405
374
|
borderRadius: '3px',
|
|
406
|
-
padding: '
|
|
375
|
+
padding: '0px',
|
|
407
376
|
locale: 'en',
|
|
408
|
-
type: '
|
|
377
|
+
type: 'plain'
|
|
409
378
|
};
|
|
410
379
|
var parseApplePayCustomStyles = function parseApplePayCustomStyles(styles) {
|
|
411
380
|
if (!(styles && _typeof(styles) === 'object')) {
|
|
@@ -435,6 +404,193 @@ var PaystackPop = (function () {
|
|
|
435
404
|
};
|
|
436
405
|
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";
|
|
437
406
|
|
|
407
|
+
var amountSubunitToBase = function amountSubunitToBase() {
|
|
408
|
+
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
409
|
+
return Number(parseFloat(amount / 100).toFixed(2));
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
var requestConfig = {
|
|
413
|
+
headers: {
|
|
414
|
+
accept: 'application/json, text/plain, */*',
|
|
415
|
+
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
|
|
416
|
+
'content-type': 'application/x-www-form-urlencoded',
|
|
417
|
+
'sec-ch-ua-mobile': '?0',
|
|
418
|
+
'sec-fetch-dest': 'empty',
|
|
419
|
+
'sec-fetch-mode': 'cors',
|
|
420
|
+
'sec-fetch-site': 'cross-site'
|
|
421
|
+
},
|
|
422
|
+
referrerPolicy: 'no-referrer-when-downgrade',
|
|
423
|
+
method: 'POST',
|
|
424
|
+
mode: 'cors',
|
|
425
|
+
credentials: 'omit'
|
|
426
|
+
};
|
|
427
|
+
function createFormBody(params) {
|
|
428
|
+
var formBody = Object.keys(params).reduce(function (formBodyArray, key) {
|
|
429
|
+
var encodedKey = encodeURIComponent(key);
|
|
430
|
+
var encodedValue = encodeURIComponent(params[key]);
|
|
431
|
+
var encodedFormBody = "".concat(encodedKey, "=").concat(encodedValue);
|
|
432
|
+
return [].concat(_toConsumableArray(formBodyArray), [encodedFormBody]);
|
|
433
|
+
}, []);
|
|
434
|
+
return formBody.join('&');
|
|
435
|
+
}
|
|
436
|
+
var APPLE_PAY_CAPABILITY_STATUS = {
|
|
437
|
+
AVAILABLE: 'paymentCredentialsAvailable',
|
|
438
|
+
UNAVAILABLE: 'paymentCredentialsUnavailable',
|
|
439
|
+
UNKNOWN: 'paymentCredentialStatusUnknown',
|
|
440
|
+
UNSUPPORTED: 'applePayUnsupported'
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
var formatIntervalString = function formatIntervalString(interval) {
|
|
444
|
+
var plans = {
|
|
445
|
+
biannually: 'BIANNUAL PLAN',
|
|
446
|
+
annually: 'ANNUAL PLAN'
|
|
447
|
+
};
|
|
448
|
+
return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
|
|
452
|
+
var currency = _ref.currency,
|
|
453
|
+
amount = _ref.amount,
|
|
454
|
+
merchantName = _ref.merchantName,
|
|
455
|
+
interval = _ref.interval;
|
|
456
|
+
return _objectSpread2({
|
|
457
|
+
countryCode: 'NG',
|
|
458
|
+
currencyCode: currency,
|
|
459
|
+
merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
|
|
460
|
+
supportedNetworks: ['visa', 'masterCard'],
|
|
461
|
+
requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
|
|
462
|
+
total: {
|
|
463
|
+
label: "".concat(merchantName, " - Paystack"),
|
|
464
|
+
type: 'final',
|
|
465
|
+
amount: String(amountSubunitToBase(amount))
|
|
466
|
+
}
|
|
467
|
+
}, typeof interval === 'string' && interval.trim() !== '' && {
|
|
468
|
+
lineItems: [{
|
|
469
|
+
label: formatIntervalString(interval),
|
|
470
|
+
amount: String(amountSubunitToBase(amount))
|
|
471
|
+
}]
|
|
472
|
+
});
|
|
473
|
+
};
|
|
474
|
+
var validateApplePaySession = function validateApplePaySession(_ref2) {
|
|
475
|
+
var transactionId = _ref2.transactionId,
|
|
476
|
+
validationURL = _ref2.validationURL,
|
|
477
|
+
merchantName = _ref2.merchantName,
|
|
478
|
+
_ref2$domainName = _ref2.domainName,
|
|
479
|
+
domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
|
|
480
|
+
var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
|
|
481
|
+
var params = {
|
|
482
|
+
transaction: transactionId,
|
|
483
|
+
sessionUrl: validationURL,
|
|
484
|
+
displayName: merchantName,
|
|
485
|
+
domainName: domainName
|
|
486
|
+
};
|
|
487
|
+
var formBody = createFormBody(params);
|
|
488
|
+
var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
489
|
+
body: formBody
|
|
490
|
+
})).then(function (response) {
|
|
491
|
+
return response.json();
|
|
492
|
+
});
|
|
493
|
+
return validateSession;
|
|
494
|
+
};
|
|
495
|
+
var chargeApplePay = function chargeApplePay(_ref3) {
|
|
496
|
+
var transactionId = _ref3.transactionId,
|
|
497
|
+
payment = _ref3.payment;
|
|
498
|
+
var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
|
|
499
|
+
var params = {
|
|
500
|
+
transaction: transactionId,
|
|
501
|
+
paymentObject: JSON.stringify(payment)
|
|
502
|
+
};
|
|
503
|
+
var formBody = createFormBody(params);
|
|
504
|
+
var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
505
|
+
body: formBody
|
|
506
|
+
})).then(function (response) {
|
|
507
|
+
return response.json();
|
|
508
|
+
});
|
|
509
|
+
return charge;
|
|
510
|
+
};
|
|
511
|
+
var deviceSupportsApplePay = function deviceSupportsApplePay() {
|
|
512
|
+
try {
|
|
513
|
+
return !!(window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion));
|
|
514
|
+
} catch (error) {
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
var getApplePayCapabilityStatusFromResponse = function getApplePayCapabilityStatusFromResponse(capabilities) {
|
|
520
|
+
if (!capabilities) {
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if (typeof capabilities === 'string') {
|
|
525
|
+
return capabilities;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (typeof capabilities.paymentCredentialStatus === 'string') {
|
|
529
|
+
return capabilities.paymentCredentialStatus;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
return null;
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
var getApplePayCapabilityStatus = function getApplePayCapabilityStatus() {
|
|
536
|
+
try {
|
|
537
|
+
if (!deviceSupportsApplePay()) {
|
|
538
|
+
return Promise.resolve(null);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
var _window = window,
|
|
542
|
+
ApplePaySession = _window.ApplePaySession;
|
|
543
|
+
|
|
544
|
+
if (typeof ApplePaySession.applePayCapabilities === 'function') {
|
|
545
|
+
return Promise.resolve(ApplePaySession.applePayCapabilities()).then(function (capabilities) {
|
|
546
|
+
return getApplePayCapabilityStatusFromResponse(capabilities);
|
|
547
|
+
}).catch(function () {
|
|
548
|
+
try {
|
|
549
|
+
if (window.ApplePaySession.canMakePayments()) {
|
|
550
|
+
return APPLE_PAY_CAPABILITY_STATUS.UNKNOWN;
|
|
551
|
+
}
|
|
552
|
+
} catch (fallbackError) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
return APPLE_PAY_CAPABILITY_STATUS.UNSUPPORTED;
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
if (typeof ApplePaySession.canMakePayments === 'function') {
|
|
561
|
+
return Promise.resolve(ApplePaySession.canMakePayments()).then(function (canMakePayments) {
|
|
562
|
+
return canMakePayments ? APPLE_PAY_CAPABILITY_STATUS.UNKNOWN : APPLE_PAY_CAPABILITY_STATUS.UNSUPPORTED;
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
return Promise.resolve(null);
|
|
567
|
+
} catch (error) {
|
|
568
|
+
try {
|
|
569
|
+
if (window.ApplePaySession.canMakePayments()) {
|
|
570
|
+
return Promise.resolve(APPLE_PAY_CAPABILITY_STATUS.UNKNOWN);
|
|
571
|
+
}
|
|
572
|
+
} catch (fallbackError) {
|
|
573
|
+
return Promise.resolve(null);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return Promise.resolve(APPLE_PAY_CAPABILITY_STATUS.UNSUPPORTED);
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
var applePayCapabilityCanShowButton = function applePayCapabilityCanShowButton(status) {
|
|
580
|
+
return [APPLE_PAY_CAPABILITY_STATUS.AVAILABLE, APPLE_PAY_CAPABILITY_STATUS.UNKNOWN].includes(status);
|
|
581
|
+
};
|
|
582
|
+
var canUseApplePay = function canUseApplePay(channels) {
|
|
583
|
+
var availableChannels = channels || [];
|
|
584
|
+
|
|
585
|
+
if (!availableChannels.includes('apple_pay')) {
|
|
586
|
+
return Promise.resolve(false);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
return getApplePayCapabilityStatus().then(function (capabilityStatus) {
|
|
590
|
+
return applePayCapabilityCanShowButton(capabilityStatus);
|
|
591
|
+
});
|
|
592
|
+
};
|
|
593
|
+
|
|
438
594
|
/* eslint-env browser */
|
|
439
595
|
function findHighestZIndex() {
|
|
440
596
|
var highestZIndex = 0;
|
|
@@ -494,6 +650,7 @@ var PaystackPop = (function () {
|
|
|
494
650
|
function getApplePayButton(container) {
|
|
495
651
|
return container.querySelector('apple-pay-button') || container.querySelector('#apple-pay-button');
|
|
496
652
|
}
|
|
653
|
+
var applePaySdkPromise;
|
|
497
654
|
var loadScript = function loadScript(url, _ref) {
|
|
498
655
|
var container = _ref.container,
|
|
499
656
|
integrity = _ref.integrity;
|
|
@@ -525,6 +682,31 @@ var PaystackPop = (function () {
|
|
|
525
682
|
}
|
|
526
683
|
});
|
|
527
684
|
};
|
|
685
|
+
|
|
686
|
+
var applePayButtonComponentIsAvailable = function applePayButtonComponentIsAvailable() {
|
|
687
|
+
return !!(window && window.customElements && window.customElements.get('apple-pay-button'));
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
var ensureApplePaySdkLoaded = function ensureApplePaySdkLoaded(container) {
|
|
691
|
+
if (applePayButtonComponentIsAvailable()) {
|
|
692
|
+
return Promise.resolve(true);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (applePaySdkPromise) {
|
|
696
|
+
return applePaySdkPromise;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
applePaySdkPromise = loadScript(APPLE_PAY_SDK_SOURCE, {
|
|
700
|
+
container: container,
|
|
701
|
+
integrity: APPLE_PAY_SDK_INTEGRITY_HASH
|
|
702
|
+
}).then(function () {
|
|
703
|
+
return true;
|
|
704
|
+
}).catch(function (error) {
|
|
705
|
+
applePaySdkPromise = null;
|
|
706
|
+
throw error;
|
|
707
|
+
});
|
|
708
|
+
return applePaySdkPromise;
|
|
709
|
+
};
|
|
528
710
|
function appendIframeToContainer(containerId, iframe) {
|
|
529
711
|
var container = document.getElementById(containerId);
|
|
530
712
|
container.innerHTML = '';
|
|
@@ -675,7 +857,7 @@ var PaystackPop = (function () {
|
|
|
675
857
|
function getPaymentRequestContainer(container) {
|
|
676
858
|
return document.querySelector("#".concat(container));
|
|
677
859
|
}
|
|
678
|
-
function mountPaymentRequestButtons(container, _ref4
|
|
860
|
+
function mountPaymentRequestButtons(container, _ref4) {
|
|
679
861
|
var _ref4$channels = _ref4.channels,
|
|
680
862
|
channels = _ref4$channels === void 0 ? [] : _ref4$channels,
|
|
681
863
|
_ref4$styles = _ref4.styles,
|
|
@@ -683,92 +865,45 @@ var PaystackPop = (function () {
|
|
|
683
865
|
var mountedElements = {
|
|
684
866
|
applePay: false
|
|
685
867
|
};
|
|
686
|
-
return new Promise(function (resolve, reject) {
|
|
687
|
-
if (container) {
|
|
688
|
-
if (!channels.includes('apple_pay')) {
|
|
689
|
-
reject('No wallet payment method is available on this device');
|
|
690
|
-
return;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
if (getApplePayButton(container)) {
|
|
694
|
-
mountedElements.applePay = true;
|
|
695
|
-
resolve(mountedElements);
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
loadScript(APPLE_PAY_SDK_SOURCE, {
|
|
700
|
-
container: container,
|
|
701
|
-
integrity: APPLE_PAY_SDK_INTEGRITY_HASH
|
|
702
|
-
}).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
703
|
-
var _window$ApplePaySessi, capabilities, unsupported, _window$ApplePaySessi2, _window$ApplePaySessi3;
|
|
704
|
-
|
|
705
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
706
|
-
while (1) {
|
|
707
|
-
switch (_context.prev = _context.next) {
|
|
708
|
-
case 0:
|
|
709
|
-
_context.prev = 0;
|
|
710
|
-
_context.next = 3;
|
|
711
|
-
return (_window$ApplePaySessi = window.ApplePaySession) === null || _window$ApplePaySessi === void 0 ? void 0 : _window$ApplePaySessi.applePayCapabilities();
|
|
712
|
-
|
|
713
|
-
case 3:
|
|
714
|
-
capabilities = _context.sent;
|
|
715
|
-
unsupported = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
|
|
716
|
-
|
|
717
|
-
if (!unsupported) {
|
|
718
|
-
_context.next = 7;
|
|
719
|
-
break;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
throw new Error('Apple Pay is not supported on this device');
|
|
723
|
-
|
|
724
|
-
case 7:
|
|
725
|
-
_context.next = 15;
|
|
726
|
-
break;
|
|
727
|
-
|
|
728
|
-
case 9:
|
|
729
|
-
_context.prev = 9;
|
|
730
|
-
_context.t0 = _context["catch"](0);
|
|
731
868
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
throw _context.t0;
|
|
869
|
+
if (!container) {
|
|
870
|
+
return Promise.reject(new Error('Container to mount elements was not provided'));
|
|
871
|
+
}
|
|
738
872
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
break;
|
|
743
|
-
}
|
|
873
|
+
if (!channels.includes('apple_pay')) {
|
|
874
|
+
return Promise.reject(new Error('No wallet payment method is available on this device'));
|
|
875
|
+
}
|
|
744
876
|
|
|
745
|
-
|
|
877
|
+
return ensureApplePaySdkLoaded(container).catch(function () {
|
|
878
|
+
// Safari can still render the fallback button using the native ApplePaySession.
|
|
879
|
+
return null;
|
|
880
|
+
}).then(function () {
|
|
881
|
+
return canUseApplePay(channels);
|
|
882
|
+
}).then(function (applePayAvailable) {
|
|
883
|
+
if (!applePayAvailable) {
|
|
884
|
+
throw new Error('No wallet payment method is available on this device');
|
|
885
|
+
}
|
|
746
886
|
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
});
|
|
752
|
-
mountedElements.applePay = true;
|
|
753
|
-
resolve(mountedElements);
|
|
887
|
+
if (getApplePayButton(container)) {
|
|
888
|
+
mountedElements.applePay = true;
|
|
889
|
+
return mountedElements;
|
|
890
|
+
}
|
|
754
891
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
});
|
|
766
|
-
mountedElements.applePay = true;
|
|
767
|
-
resolve(mountedElements);
|
|
892
|
+
try {
|
|
893
|
+
mountApplePayButton(container, {
|
|
894
|
+
styles: parseApplePayCustomStyles(styles.applePay),
|
|
895
|
+
theme: styles.theme
|
|
896
|
+
});
|
|
897
|
+
} catch (error) {
|
|
898
|
+
// If the web component is unavailable, fall back to the CSS-based Apple Pay button.
|
|
899
|
+
mountApplePayFallbackButton(container, {
|
|
900
|
+
styles: parseApplePayCustomStyles(styles.applePay),
|
|
901
|
+
theme: styles.theme
|
|
768
902
|
});
|
|
769
|
-
} else {
|
|
770
|
-
reject('Container to mount elements was not provided');
|
|
771
903
|
}
|
|
904
|
+
|
|
905
|
+
mountedElements.applePay = true;
|
|
906
|
+
return mountedElements;
|
|
772
907
|
});
|
|
773
908
|
}
|
|
774
909
|
function removeAllChildNodes(parent) {
|
|
@@ -849,8 +984,8 @@ var PaystackPop = (function () {
|
|
|
849
984
|
}
|
|
850
985
|
}
|
|
851
986
|
|
|
852
|
-
function defaultPreCheckoutModalView(container,
|
|
853
|
-
var hasOtherPaymentMethods =
|
|
987
|
+
function defaultPreCheckoutModalView(container, _ref5) {
|
|
988
|
+
var hasOtherPaymentMethods = _ref5.hasOtherPaymentMethods;
|
|
854
989
|
var applePayIcon = document.createElement('div');
|
|
855
990
|
applePayIcon.innerHTML = applePayMarkLight;
|
|
856
991
|
container.appendChild(applePayIcon);
|
|
@@ -893,14 +1028,14 @@ var PaystackPop = (function () {
|
|
|
893
1028
|
content.classList.add('pre-checkout-modal__content');
|
|
894
1029
|
modal.appendChild(content);
|
|
895
1030
|
|
|
896
|
-
var
|
|
897
|
-
merchantLogo =
|
|
898
|
-
merchantName =
|
|
899
|
-
email =
|
|
900
|
-
amount =
|
|
901
|
-
currency =
|
|
902
|
-
label =
|
|
903
|
-
channels =
|
|
1031
|
+
var _ref6 = transaction || {},
|
|
1032
|
+
merchantLogo = _ref6.merchant_logo,
|
|
1033
|
+
merchantName = _ref6.merchant_name,
|
|
1034
|
+
email = _ref6.email,
|
|
1035
|
+
amount = _ref6.amount,
|
|
1036
|
+
currency = _ref6.currency,
|
|
1037
|
+
label = _ref6.label,
|
|
1038
|
+
channels = _ref6.channels;
|
|
904
1039
|
|
|
905
1040
|
var formattedAmount = new Intl.NumberFormat('en', {
|
|
906
1041
|
style: 'currency',
|
|
@@ -1713,116 +1848,6 @@ var PaystackPop = (function () {
|
|
|
1713
1848
|
return InlineTransaction;
|
|
1714
1849
|
}();
|
|
1715
1850
|
|
|
1716
|
-
var amountSubunitToBase = function amountSubunitToBase() {
|
|
1717
|
-
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
1718
|
-
return Number(parseFloat(amount / 100).toFixed(2));
|
|
1719
|
-
};
|
|
1720
|
-
|
|
1721
|
-
var requestConfig = {
|
|
1722
|
-
headers: {
|
|
1723
|
-
accept: 'application/json, text/plain, */*',
|
|
1724
|
-
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
|
|
1725
|
-
'content-type': 'application/x-www-form-urlencoded',
|
|
1726
|
-
'sec-ch-ua-mobile': '?0',
|
|
1727
|
-
'sec-fetch-dest': 'empty',
|
|
1728
|
-
'sec-fetch-mode': 'cors',
|
|
1729
|
-
'sec-fetch-site': 'cross-site'
|
|
1730
|
-
},
|
|
1731
|
-
referrerPolicy: 'no-referrer-when-downgrade',
|
|
1732
|
-
method: 'POST',
|
|
1733
|
-
mode: 'cors',
|
|
1734
|
-
credentials: 'omit'
|
|
1735
|
-
};
|
|
1736
|
-
function createFormBody(params) {
|
|
1737
|
-
var formBody = Object.keys(params).reduce(function (formBodyArray, key) {
|
|
1738
|
-
var encodedKey = encodeURIComponent(key);
|
|
1739
|
-
var encodedValue = encodeURIComponent(params[key]);
|
|
1740
|
-
var encodedFormBody = "".concat(encodedKey, "=").concat(encodedValue);
|
|
1741
|
-
return [].concat(_toConsumableArray(formBodyArray), [encodedFormBody]);
|
|
1742
|
-
}, []);
|
|
1743
|
-
return formBody.join('&');
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
var formatIntervalString = function formatIntervalString(interval) {
|
|
1747
|
-
var plans = {
|
|
1748
|
-
biannually: 'BIANNUAL PLAN',
|
|
1749
|
-
annually: 'ANNUAL PLAN'
|
|
1750
|
-
};
|
|
1751
|
-
return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
|
|
1752
|
-
};
|
|
1753
|
-
|
|
1754
|
-
var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
|
|
1755
|
-
var currency = _ref.currency,
|
|
1756
|
-
amount = _ref.amount,
|
|
1757
|
-
merchantName = _ref.merchantName,
|
|
1758
|
-
interval = _ref.interval;
|
|
1759
|
-
return _objectSpread2({
|
|
1760
|
-
countryCode: 'NG',
|
|
1761
|
-
currencyCode: currency,
|
|
1762
|
-
merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
|
|
1763
|
-
supportedNetworks: ['visa', 'masterCard'],
|
|
1764
|
-
requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
|
|
1765
|
-
total: {
|
|
1766
|
-
label: "".concat(merchantName, " - Paystack"),
|
|
1767
|
-
type: 'final',
|
|
1768
|
-
amount: String(amountSubunitToBase(amount))
|
|
1769
|
-
}
|
|
1770
|
-
}, typeof interval === 'string' && interval.trim() !== '' && {
|
|
1771
|
-
lineItems: [{
|
|
1772
|
-
label: formatIntervalString(interval),
|
|
1773
|
-
amount: String(amountSubunitToBase(amount))
|
|
1774
|
-
}]
|
|
1775
|
-
});
|
|
1776
|
-
};
|
|
1777
|
-
var validateApplePaySession = function validateApplePaySession(_ref2) {
|
|
1778
|
-
var transactionId = _ref2.transactionId,
|
|
1779
|
-
validationURL = _ref2.validationURL,
|
|
1780
|
-
merchantName = _ref2.merchantName,
|
|
1781
|
-
_ref2$domainName = _ref2.domainName,
|
|
1782
|
-
domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
|
|
1783
|
-
var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
|
|
1784
|
-
var params = {
|
|
1785
|
-
transaction: transactionId,
|
|
1786
|
-
sessionUrl: validationURL,
|
|
1787
|
-
displayName: merchantName,
|
|
1788
|
-
domainName: domainName
|
|
1789
|
-
};
|
|
1790
|
-
var formBody = createFormBody(params);
|
|
1791
|
-
var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
1792
|
-
body: formBody
|
|
1793
|
-
})).then(function (response) {
|
|
1794
|
-
return response.json();
|
|
1795
|
-
});
|
|
1796
|
-
return validateSession;
|
|
1797
|
-
};
|
|
1798
|
-
var chargeApplePay = function chargeApplePay(_ref3) {
|
|
1799
|
-
var transactionId = _ref3.transactionId,
|
|
1800
|
-
payment = _ref3.payment;
|
|
1801
|
-
var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
|
|
1802
|
-
var params = {
|
|
1803
|
-
transaction: transactionId,
|
|
1804
|
-
paymentObject: JSON.stringify(payment)
|
|
1805
|
-
};
|
|
1806
|
-
var formBody = createFormBody(params);
|
|
1807
|
-
var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
1808
|
-
body: formBody
|
|
1809
|
-
})).then(function (response) {
|
|
1810
|
-
return response.json();
|
|
1811
|
-
});
|
|
1812
|
-
return charge;
|
|
1813
|
-
};
|
|
1814
|
-
var deviceSupportsApplePay = function deviceSupportsApplePay() {
|
|
1815
|
-
try {
|
|
1816
|
-
return window.location && window.location.protocol === 'https:' && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
|
|
1817
|
-
} catch (error) {
|
|
1818
|
-
return false;
|
|
1819
|
-
}
|
|
1820
|
-
};
|
|
1821
|
-
var canUseApplePay = function canUseApplePay() {
|
|
1822
|
-
var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1823
|
-
return deviceSupportsApplePay() && channels.includes('apple_pay');
|
|
1824
|
-
};
|
|
1825
|
-
|
|
1826
1851
|
var canUseVault = function canUseVault() {
|
|
1827
1852
|
var _transaction$link_con, _transaction$link_con2;
|
|
1828
1853
|
|
|
@@ -1881,6 +1906,19 @@ var PaystackPop = (function () {
|
|
|
1881
1906
|
throw new Error(message);
|
|
1882
1907
|
}
|
|
1883
1908
|
|
|
1909
|
+
function transactionCanUseApplePay(response, container) {
|
|
1910
|
+
if (!(response && response.channels && response.channels.includes('apple_pay'))) {
|
|
1911
|
+
return Promise.resolve(false);
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
return ensureApplePaySdkLoaded(container).catch(function () {
|
|
1915
|
+
// Native Apple Pay support can still be available even if the SDK fails to load.
|
|
1916
|
+
return null;
|
|
1917
|
+
}).then(function () {
|
|
1918
|
+
return canUseApplePay(response.channels);
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1884
1922
|
var Inline = /*#__PURE__*/function () {
|
|
1885
1923
|
function Inline(params) {
|
|
1886
1924
|
_classCallCheck(this, Inline);
|
|
@@ -1946,7 +1984,15 @@ var PaystackPop = (function () {
|
|
|
1946
1984
|
var transaction = resumableTransaction || new InlineTransaction(params);
|
|
1947
1985
|
return new Promise(function (resolve, reject) {
|
|
1948
1986
|
transaction.requestInline().then(function (response) {
|
|
1949
|
-
|
|
1987
|
+
return transactionCanUseApplePay(response).then(function (canPayWithApplePay) {
|
|
1988
|
+
return {
|
|
1989
|
+
response: response,
|
|
1990
|
+
canPayWithApplePay: canPayWithApplePay
|
|
1991
|
+
};
|
|
1992
|
+
});
|
|
1993
|
+
}).then(function (_ref) {
|
|
1994
|
+
var response = _ref.response,
|
|
1995
|
+
canPayWithApplePay = _ref.canPayWithApplePay;
|
|
1950
1996
|
var canPayWithVault = canUseVault(response);
|
|
1951
1997
|
var shouldLoadPreCheckoutModal = canPayWithVault || canPayWithApplePay;
|
|
1952
1998
|
|
|
@@ -1984,7 +2030,7 @@ var PaystackPop = (function () {
|
|
|
1984
2030
|
}
|
|
1985
2031
|
}
|
|
1986
2032
|
}, response.merchant_id).then(function () {
|
|
1987
|
-
inlineInstance.registerPaymentRequestEventListeners();
|
|
2033
|
+
return inlineInstance.registerPaymentRequestEventListeners();
|
|
1988
2034
|
}).catch(function () {
|
|
1989
2035
|
/**
|
|
1990
2036
|
* If an error occurs when mounting the apple pay button,
|
|
@@ -2097,6 +2143,7 @@ var PaystackPop = (function () {
|
|
|
2097
2143
|
|
|
2098
2144
|
if (transactionStatus === 'failed') {
|
|
2099
2145
|
showErrorInPreCheckoutModal(this.preCheckoutModal);
|
|
2146
|
+
animatePreCheckoutModalIn(this.preCheckoutModal);
|
|
2100
2147
|
} else {
|
|
2101
2148
|
hidePreCheckoutModal(this.preCheckoutModal);
|
|
2102
2149
|
this.preCheckoutModal.remove();
|
|
@@ -2118,11 +2165,11 @@ var PaystackPop = (function () {
|
|
|
2118
2165
|
}
|
|
2119
2166
|
}, {
|
|
2120
2167
|
key: "newTransaction",
|
|
2121
|
-
value: function newTransaction(
|
|
2122
|
-
var preload =
|
|
2123
|
-
inlineTransaction =
|
|
2124
|
-
transactionData =
|
|
2125
|
-
options = _objectWithoutProperties(
|
|
2168
|
+
value: function newTransaction(_ref2) {
|
|
2169
|
+
var preload = _ref2.preload,
|
|
2170
|
+
inlineTransaction = _ref2.inlineTransaction,
|
|
2171
|
+
transactionData = _ref2.transactionData,
|
|
2172
|
+
options = _objectWithoutProperties(_ref2, _excluded);
|
|
2126
2173
|
|
|
2127
2174
|
var hasPaymentRequestButtons = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2128
2175
|
|
|
@@ -2201,25 +2248,6 @@ var PaystackPop = (function () {
|
|
|
2201
2248
|
return new Promise(function (resolve, reject) {
|
|
2202
2249
|
var loadPaystackCheckoutButton = document.querySelector("#".concat(parameters.loadPaystackCheckoutButton));
|
|
2203
2250
|
|
|
2204
|
-
if (!deviceSupportsApplePay()) {
|
|
2205
|
-
if (parameters && parameters.loadPaystackCheckoutButton) {
|
|
2206
|
-
if (loadPaystackCheckoutButton) {
|
|
2207
|
-
var loadPopup = inlineInstance.preloadTransaction(transactionParams);
|
|
2208
|
-
loadPaystackCheckoutButton.onclick = loadPopup;
|
|
2209
|
-
} else {
|
|
2210
|
-
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'");
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
|
|
2214
|
-
if (onElementsMount) {
|
|
2215
|
-
onElementsMount(null);
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
var activeTransaction = inlineInstance.activeTransaction();
|
|
2219
|
-
resolve(activeTransaction);
|
|
2220
|
-
return;
|
|
2221
|
-
}
|
|
2222
|
-
|
|
2223
2251
|
if (inlineInstance.activeTransaction()) {
|
|
2224
2252
|
inlineInstance.activeTransaction().cancel();
|
|
2225
2253
|
}
|
|
@@ -2253,12 +2281,11 @@ var PaystackPop = (function () {
|
|
|
2253
2281
|
inlineInstance.registerPaymentRequestEventListeners();
|
|
2254
2282
|
|
|
2255
2283
|
if (loadPaystackCheckoutButton) {
|
|
2256
|
-
var
|
|
2284
|
+
var loadPopup = inlineInstance.preloadTransaction({
|
|
2257
2285
|
inlineTransaction: transaction,
|
|
2258
2286
|
transactionData: response
|
|
2259
2287
|
});
|
|
2260
|
-
|
|
2261
|
-
loadPaystackCheckoutButton.onclick = _loadPopup;
|
|
2288
|
+
loadPaystackCheckoutButton.onclick = loadPopup;
|
|
2262
2289
|
}
|
|
2263
2290
|
|
|
2264
2291
|
resolve(transaction);
|
|
@@ -2279,22 +2306,21 @@ var PaystackPop = (function () {
|
|
|
2279
2306
|
|
|
2280
2307
|
var applePayButton = getApplePayButton(this.paymentRequestContainer);
|
|
2281
2308
|
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2309
|
+
if (applePayButton) {
|
|
2310
|
+
applePayButton.onclick = function () {
|
|
2311
|
+
return _this4.startApplePay();
|
|
2312
|
+
};
|
|
2313
|
+
}
|
|
2285
2314
|
}
|
|
2286
2315
|
}, {
|
|
2287
2316
|
key: "registerPaymentRequestEventListeners",
|
|
2288
2317
|
value: function registerPaymentRequestEventListeners() {
|
|
2289
2318
|
var transaction = this.activeTransaction();
|
|
2319
|
+
var applePayButton = this.paymentRequestContainer && getApplePayButton(this.paymentRequestContainer);
|
|
2290
2320
|
|
|
2291
|
-
if (transaction) {
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
} else {
|
|
2295
|
-
removeAllChildNodes(this.paymentRequestContainer);
|
|
2296
|
-
}
|
|
2297
|
-
} else {
|
|
2321
|
+
if (transaction && applePayButton) {
|
|
2322
|
+
this.registerApplePayEventListener();
|
|
2323
|
+
} else if (this.paymentRequestContainer) {
|
|
2298
2324
|
removeAllChildNodes(this.paymentRequestContainer);
|
|
2299
2325
|
}
|
|
2300
2326
|
}
|
|
@@ -2319,6 +2345,7 @@ var PaystackPop = (function () {
|
|
|
2319
2345
|
amount: transaction.amount,
|
|
2320
2346
|
timeSpent: transaction.getTimeSpent()
|
|
2321
2347
|
};
|
|
2348
|
+
var pendingPreCheckoutModalStatus = null;
|
|
2322
2349
|
|
|
2323
2350
|
try {
|
|
2324
2351
|
transaction.logAttempt(paymentMethod);
|
|
@@ -2331,8 +2358,12 @@ var PaystackPop = (function () {
|
|
|
2331
2358
|
});
|
|
2332
2359
|
var applePaySession = new window.ApplePaySession(config.applePayVersion, applePayPaymentRequest);
|
|
2333
2360
|
|
|
2334
|
-
|
|
2335
|
-
|
|
2361
|
+
if (inlineInstance.preCheckoutModal) {
|
|
2362
|
+
hidePreCheckoutModal(inlineInstance.preCheckoutModal);
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
applePaySession.onvalidatemerchant = function (_ref3) {
|
|
2366
|
+
var validationURL = _ref3.validationURL;
|
|
2336
2367
|
var validateSession = validateApplePaySession({
|
|
2337
2368
|
validationURL: validationURL,
|
|
2338
2369
|
transactionId: transaction.id,
|
|
@@ -2341,6 +2372,7 @@ var PaystackPop = (function () {
|
|
|
2341
2372
|
validateSession.then(function (response) {
|
|
2342
2373
|
if (response.status !== 'success') {
|
|
2343
2374
|
transaction.onSetupError(response);
|
|
2375
|
+
pendingPreCheckoutModalStatus = 'failed';
|
|
2344
2376
|
} else {
|
|
2345
2377
|
applePaySession.completeMerchantValidation(response.data);
|
|
2346
2378
|
}
|
|
@@ -2348,17 +2380,25 @@ var PaystackPop = (function () {
|
|
|
2348
2380
|
transaction.logValidationResponse(response.message);
|
|
2349
2381
|
}).catch(function (error) {
|
|
2350
2382
|
transaction.onSetupError(error);
|
|
2383
|
+
pendingPreCheckoutModalStatus = 'failed';
|
|
2351
2384
|
});
|
|
2352
2385
|
};
|
|
2353
2386
|
|
|
2354
2387
|
applePaySession.oncancel = function () {
|
|
2355
|
-
if (
|
|
2388
|
+
if (inlineInstance.preCheckoutModal) {
|
|
2389
|
+
if (pendingPreCheckoutModalStatus) {
|
|
2390
|
+
inlineInstance.closePreCheckoutModal(pendingPreCheckoutModalStatus);
|
|
2391
|
+
pendingPreCheckoutModalStatus = null;
|
|
2392
|
+
} else {
|
|
2393
|
+
animatePreCheckoutModalIn(inlineInstance.preCheckoutModal);
|
|
2394
|
+
}
|
|
2395
|
+
} else {
|
|
2356
2396
|
transaction.onCancel();
|
|
2357
2397
|
}
|
|
2358
2398
|
};
|
|
2359
2399
|
|
|
2360
|
-
applePaySession.onpaymentauthorized = function (
|
|
2361
|
-
var payment =
|
|
2400
|
+
applePaySession.onpaymentauthorized = function (_ref4) {
|
|
2401
|
+
var payment = _ref4.payment;
|
|
2362
2402
|
var charge = chargeApplePay({
|
|
2363
2403
|
transactionId: transaction.id,
|
|
2364
2404
|
payment: payment
|
|
@@ -2374,6 +2414,7 @@ var PaystackPop = (function () {
|
|
|
2374
2414
|
} else {
|
|
2375
2415
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2376
2416
|
transaction.onSetupError(response);
|
|
2417
|
+
pendingPreCheckoutModalStatus = 'failed';
|
|
2377
2418
|
|
|
2378
2419
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2379
2420
|
channel: 'apple_pay',
|
|
@@ -2381,23 +2422,25 @@ var PaystackPop = (function () {
|
|
|
2381
2422
|
});
|
|
2382
2423
|
}
|
|
2383
2424
|
|
|
2384
|
-
|
|
2425
|
+
if (response.status === 'success') {
|
|
2426
|
+
inlineInstance.closePreCheckoutModal(response.status);
|
|
2427
|
+
}
|
|
2385
2428
|
}).catch(function (error) {
|
|
2386
2429
|
applePaySession.completePayment(applePaySession.STATUS_FAILURE);
|
|
2387
2430
|
transaction.onSetupError(error);
|
|
2431
|
+
pendingPreCheckoutModalStatus = 'failed';
|
|
2388
2432
|
|
|
2389
2433
|
_this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
|
|
2390
2434
|
channel: 'apple_pay',
|
|
2391
2435
|
message: error && error.message || 'Error occurred'
|
|
2392
2436
|
});
|
|
2393
|
-
|
|
2394
|
-
inlineInstance.closePreCheckoutModal('failed');
|
|
2395
2437
|
});
|
|
2396
2438
|
};
|
|
2397
2439
|
|
|
2398
2440
|
applePaySession.begin();
|
|
2399
2441
|
} catch (error) {
|
|
2400
2442
|
transaction.onSetupError(error);
|
|
2443
|
+
inlineInstance.closePreCheckoutModal('failed');
|
|
2401
2444
|
}
|
|
2402
2445
|
} else {
|
|
2403
2446
|
handleError('Could not initiate apple pay transaction');
|