@paystack/inline-js 2.22.8-dev.1 → 2.23.0-dev.1
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/inline.js +233 -180
- package/es/inline.js +233 -180
- package/lib/inline.js +233 -180
- package/package.json +1 -1
package/dist/inline.js
CHANGED
|
@@ -17,6 +17,37 @@ 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
|
+
|
|
20
51
|
function _classCallCheck(a, n) {
|
|
21
52
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
22
53
|
}
|
|
@@ -404,116 +435,6 @@ var PaystackPop = (function () {
|
|
|
404
435
|
};
|
|
405
436
|
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";
|
|
406
437
|
|
|
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
|
-
|
|
437
|
-
var formatIntervalString = function formatIntervalString(interval) {
|
|
438
|
-
var plans = {
|
|
439
|
-
biannually: 'BIANNUAL PLAN',
|
|
440
|
-
annually: 'ANNUAL PLAN'
|
|
441
|
-
};
|
|
442
|
-
return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
|
|
446
|
-
var currency = _ref.currency,
|
|
447
|
-
amount = _ref.amount,
|
|
448
|
-
merchantName = _ref.merchantName,
|
|
449
|
-
interval = _ref.interval;
|
|
450
|
-
return _objectSpread2({
|
|
451
|
-
countryCode: 'NG',
|
|
452
|
-
currencyCode: currency,
|
|
453
|
-
merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
|
|
454
|
-
supportedNetworks: ['visa', 'masterCard'],
|
|
455
|
-
requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
|
|
456
|
-
total: {
|
|
457
|
-
label: "".concat(merchantName, " - Paystack"),
|
|
458
|
-
type: 'final',
|
|
459
|
-
amount: String(amountSubunitToBase(amount))
|
|
460
|
-
}
|
|
461
|
-
}, typeof interval === 'string' && interval.trim() !== '' && {
|
|
462
|
-
lineItems: [{
|
|
463
|
-
label: formatIntervalString(interval),
|
|
464
|
-
amount: String(amountSubunitToBase(amount))
|
|
465
|
-
}]
|
|
466
|
-
});
|
|
467
|
-
};
|
|
468
|
-
var validateApplePaySession = function validateApplePaySession(_ref2) {
|
|
469
|
-
var transactionId = _ref2.transactionId,
|
|
470
|
-
validationURL = _ref2.validationURL,
|
|
471
|
-
merchantName = _ref2.merchantName,
|
|
472
|
-
_ref2$domainName = _ref2.domainName,
|
|
473
|
-
domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
|
|
474
|
-
var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
|
|
475
|
-
var params = {
|
|
476
|
-
transaction: transactionId,
|
|
477
|
-
sessionUrl: validationURL,
|
|
478
|
-
displayName: merchantName,
|
|
479
|
-
domainName: domainName
|
|
480
|
-
};
|
|
481
|
-
var formBody = createFormBody(params);
|
|
482
|
-
var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
483
|
-
body: formBody
|
|
484
|
-
})).then(function (response) {
|
|
485
|
-
return response.json();
|
|
486
|
-
});
|
|
487
|
-
return validateSession;
|
|
488
|
-
};
|
|
489
|
-
var chargeApplePay = function chargeApplePay(_ref3) {
|
|
490
|
-
var transactionId = _ref3.transactionId,
|
|
491
|
-
payment = _ref3.payment;
|
|
492
|
-
var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
|
|
493
|
-
var params = {
|
|
494
|
-
transaction: transactionId,
|
|
495
|
-
paymentObject: JSON.stringify(payment)
|
|
496
|
-
};
|
|
497
|
-
var formBody = createFormBody(params);
|
|
498
|
-
var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
|
|
499
|
-
body: formBody
|
|
500
|
-
})).then(function (response) {
|
|
501
|
-
return response.json();
|
|
502
|
-
});
|
|
503
|
-
return charge;
|
|
504
|
-
};
|
|
505
|
-
var deviceSupportsApplePay = function deviceSupportsApplePay() {
|
|
506
|
-
try {
|
|
507
|
-
return window.location && window.location.protocol === 'https:' && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
|
|
508
|
-
} catch (error) {
|
|
509
|
-
return false;
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
var canUseApplePay = function canUseApplePay() {
|
|
513
|
-
var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
514
|
-
return deviceSupportsApplePay() && channels.includes('apple_pay');
|
|
515
|
-
};
|
|
516
|
-
|
|
517
438
|
/* eslint-env browser */
|
|
518
439
|
function findHighestZIndex() {
|
|
519
440
|
var highestZIndex = 0;
|
|
@@ -529,8 +450,8 @@ var PaystackPop = (function () {
|
|
|
529
450
|
return highestZIndex;
|
|
530
451
|
}
|
|
531
452
|
|
|
532
|
-
var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.
|
|
533
|
-
var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-
|
|
453
|
+
var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.2.0/apple-pay-sdk.js';
|
|
454
|
+
var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-hopRfycfKWs+MFyVuNk99Lb7EEhZdyoatMFJRsBk8bXoxaBXkQ+LCPm98iPgFw3a';
|
|
534
455
|
|
|
535
456
|
function createIframe(id) {
|
|
536
457
|
var iframe = document.createElement('iframe');
|
|
@@ -764,54 +685,87 @@ var PaystackPop = (function () {
|
|
|
764
685
|
};
|
|
765
686
|
return new Promise(function (resolve, reject) {
|
|
766
687
|
if (container) {
|
|
767
|
-
if (
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
688
|
+
if (!channels.includes('apple_pay')) {
|
|
689
|
+
reject('No wallet payment method is available on this device');
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
773
692
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
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
|
+
|
|
732
|
+
if (!(_context.t0.message === 'Apple Pay is not supported on this device')) {
|
|
733
|
+
_context.next = 13;
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
throw _context.t0;
|
|
738
|
+
|
|
739
|
+
case 13:
|
|
740
|
+
if ((_window$ApplePaySessi2 = window.ApplePaySession) !== null && _window$ApplePaySessi2 !== void 0 && (_window$ApplePaySessi3 = _window$ApplePaySessi2.canMakePayments) !== null && _window$ApplePaySessi3 !== void 0 && _window$ApplePaySessi3.call(_window$ApplePaySessi2)) {
|
|
741
|
+
_context.next = 15;
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
throw new Error('Apple Pay is not supported on this device');
|
|
746
|
+
|
|
747
|
+
case 15:
|
|
748
|
+
mountApplePayButton(container, {
|
|
749
|
+
styles: parseApplePayCustomStyles(styles.applePay),
|
|
750
|
+
theme: styles.theme
|
|
751
|
+
});
|
|
752
|
+
mountedElements.applePay = true;
|
|
753
|
+
resolve(mountedElements);
|
|
754
|
+
|
|
755
|
+
case 18:
|
|
756
|
+
case "end":
|
|
757
|
+
return _context.stop();
|
|
793
758
|
}
|
|
794
759
|
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
mountedElements.applePay = true;
|
|
801
|
-
resolve(mountedElements);
|
|
802
|
-
}).catch(function () {
|
|
803
|
-
// if the loading of the apple pay SDK fails, that means using the apple-pay-button web component won't work
|
|
804
|
-
// so custom styled apple pay button is mounted instead. See documentation here https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_css
|
|
805
|
-
mountApplePayFallbackButton(container, {
|
|
806
|
-
styles: parseApplePayCustomStyles(styles.applePay),
|
|
807
|
-
theme: styles.theme
|
|
808
|
-
});
|
|
809
|
-
mountedElements.applePay = true;
|
|
810
|
-
resolve(mountedElements);
|
|
760
|
+
}, _callee, null, [[0, 9]]);
|
|
761
|
+
}))).catch(function () {
|
|
762
|
+
mountApplePayFallbackButton(container, {
|
|
763
|
+
styles: parseApplePayCustomStyles(styles.applePay),
|
|
764
|
+
theme: styles.theme
|
|
811
765
|
});
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
766
|
+
mountedElements.applePay = true;
|
|
767
|
+
resolve(mountedElements);
|
|
768
|
+
});
|
|
815
769
|
} else {
|
|
816
770
|
reject('Container to mount elements was not provided');
|
|
817
771
|
}
|
|
@@ -895,8 +849,8 @@ var PaystackPop = (function () {
|
|
|
895
849
|
}
|
|
896
850
|
}
|
|
897
851
|
|
|
898
|
-
function defaultPreCheckoutModalView(container,
|
|
899
|
-
var hasOtherPaymentMethods =
|
|
852
|
+
function defaultPreCheckoutModalView(container, _ref6) {
|
|
853
|
+
var hasOtherPaymentMethods = _ref6.hasOtherPaymentMethods;
|
|
900
854
|
var applePayIcon = document.createElement('div');
|
|
901
855
|
applePayIcon.innerHTML = applePayMarkLight;
|
|
902
856
|
container.appendChild(applePayIcon);
|
|
@@ -939,14 +893,14 @@ var PaystackPop = (function () {
|
|
|
939
893
|
content.classList.add('pre-checkout-modal__content');
|
|
940
894
|
modal.appendChild(content);
|
|
941
895
|
|
|
942
|
-
var
|
|
943
|
-
merchantLogo =
|
|
944
|
-
merchantName =
|
|
945
|
-
email =
|
|
946
|
-
amount =
|
|
947
|
-
currency =
|
|
948
|
-
label =
|
|
949
|
-
channels =
|
|
896
|
+
var _ref7 = transaction || {},
|
|
897
|
+
merchantLogo = _ref7.merchant_logo,
|
|
898
|
+
merchantName = _ref7.merchant_name,
|
|
899
|
+
email = _ref7.email,
|
|
900
|
+
amount = _ref7.amount,
|
|
901
|
+
currency = _ref7.currency,
|
|
902
|
+
label = _ref7.label,
|
|
903
|
+
channels = _ref7.channels;
|
|
950
904
|
|
|
951
905
|
var formattedAmount = new Intl.NumberFormat('en', {
|
|
952
906
|
style: 'currency',
|
|
@@ -1443,17 +1397,6 @@ var PaystackPop = (function () {
|
|
|
1443
1397
|
return iOSDevices.includes(devicePlatform) || // iPAD os safari detection. iPad OS uses the same version of safari as Mac OS
|
|
1444
1398
|
userAgent.includes('Mac') && 'ontouchend' in document;
|
|
1445
1399
|
};
|
|
1446
|
-
var isAppleOS = function isAppleOS() {
|
|
1447
|
-
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1448
|
-
platform = _ref2.platform,
|
|
1449
|
-
_ref2$userAgent = _ref2.userAgent,
|
|
1450
|
-
userAgent = _ref2$userAgent === void 0 ? window && window.navigator && window.navigator.userAgent : _ref2$userAgent;
|
|
1451
|
-
|
|
1452
|
-
var devicePlatform = platform || DEVICE_PLATFORM;
|
|
1453
|
-
var isSafari = userAgent && !!userAgent.match(/Version\/[\d.]+.*Safari/);
|
|
1454
|
-
var isMAC = devicePlatform && /(Mac)/i.test(devicePlatform);
|
|
1455
|
-
return isIOS() || isMAC && isSafari;
|
|
1456
|
-
};
|
|
1457
1400
|
|
|
1458
1401
|
/* eslint-env browser */
|
|
1459
1402
|
var AnalyticsAPI = {
|
|
@@ -1770,6 +1713,116 @@ var PaystackPop = (function () {
|
|
|
1770
1713
|
return InlineTransaction;
|
|
1771
1714
|
}();
|
|
1772
1715
|
|
|
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
|
+
|
|
1773
1826
|
var canUseVault = function canUseVault() {
|
|
1774
1827
|
var _transaction$link_con, _transaction$link_con2;
|
|
1775
1828
|
|
|
@@ -1893,7 +1946,7 @@ var PaystackPop = (function () {
|
|
|
1893
1946
|
var transaction = resumableTransaction || new InlineTransaction(params);
|
|
1894
1947
|
return new Promise(function (resolve, reject) {
|
|
1895
1948
|
transaction.requestInline().then(function (response) {
|
|
1896
|
-
var canPayWithApplePay =
|
|
1949
|
+
var canPayWithApplePay = response.channels.includes('apple_pay');
|
|
1897
1950
|
var canPayWithVault = canUseVault(response);
|
|
1898
1951
|
var shouldLoadPreCheckoutModal = canPayWithVault || canPayWithApplePay;
|
|
1899
1952
|
|
|
@@ -1924,9 +1977,9 @@ var PaystackPop = (function () {
|
|
|
1924
1977
|
styles: {
|
|
1925
1978
|
applePay: {
|
|
1926
1979
|
width: '100%',
|
|
1927
|
-
type: '
|
|
1980
|
+
type: 'plain',
|
|
1928
1981
|
height: '42px',
|
|
1929
|
-
padding: '
|
|
1982
|
+
padding: '0px',
|
|
1930
1983
|
borderRadius: '5px'
|
|
1931
1984
|
}
|
|
1932
1985
|
}
|