@paystack/inline-js 2.19.0-dev.3 → 2.19.0-dev.5
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 +42 -42
- package/es/inline.js +42 -42
- package/lib/inline.js +42 -42
- package/package.json +1 -1
package/dist/inline.js
CHANGED
|
@@ -405,10 +405,10 @@ var PaystackPop = (function () {
|
|
|
405
405
|
locale = _ref2.locale;
|
|
406
406
|
return "\n @supports (-webkit-appearance: -apple-pay-button) { \n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n width: ".concat(width, ";\n height: ").concat(height, ";\n border-radius: ").concat(borderRadius, ";\n padding: ").concat(padding, ";\n -apple-pay-button-type: ").concat(type, ";\n -webkit-locale: ").concat(locale, ";\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n");
|
|
407
407
|
};
|
|
408
|
-
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 padding: 0 16px;\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:
|
|
408
|
+
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 padding: 0 16px;\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 background: #FAFAFA;\n border: 1px solid #F2F3F3;\n box-sizing: border-box;\n border-radius: 3px;\n color: #4E4E4E;\n font-weight: 500;\n font-size: 14px;\n line-height: 24px;\n cursor: pointer;\n\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 button:hover, \n .pre-checkout-modal button:active, \n .pre-checkout-modal button:focus {\n background: #F2F3F3;\n }\n\n .pre-checkout-modal .link-description {\n color: #2f3d4d;\n font-size: 14px;\n letter-spacing: normal;\n line-height: 1.4;\n margin: 0 auto 24px;\n max-width: 260px;\n padding: 0;\n }\n\n .link-logo {\n margin-bottom: 24px;\n }\n\n .pre-checkout-modal .link-error {\n color: #d44141;\n margin-top: 24px;\n }\n\n .link-divider {\n margin-bottom: 16px;\n margin-top: 24px;\n position: relative;\n }\n\n .link-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\n .link-divider__line {\n border: 1px dashed #ccced0;\n width: 100%;\n }\n\n .link-divider__text-container {\n display: flex;\n justify-content: center;\n position: relative;\n }\n\n .link-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-left: 8px;\n padding-right: 8px;\n }\n\n .link-otp-not-received {\n background-color: #f5f6f7;\n padding: 20px;\n margin-bottom: 16px;\n border-radius: 4px;\n text-align: center;\n\n .description,\n .title {\n font-weight: 400;\n font-size: 14px;\n line-height: 21px;\n color: #323d4b;\n\n @media all and (min-width: 529px) {\n width: 270px;\n padding: 0 4px;\n margin: 0 auto;\n }\n }\n .title {\n font-weight: 500;\n margin-bottom: 12px;\n }\n .description {\n margin-bottom: 24px;\n }\n }\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 #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";
|
|
409
409
|
var PinInputCSS = "\n.pin-input-container {\n display: flex;\n justify-content: center;\n gap: 8px;\n .pin-input {\n border-radius: 3px;\n border: 1px solid #e4e4e4;\n color: #011b33;\n font-size: 14px;\n font-weight: 500;\n height: 40px;\n letter-spacing: -0.1px;\n line-height: 19.6px;\n margin: 0;\n outline: none;\n text-align: center;\n width: 40px;\n }\n .pin-input:hover,\n .pin-input--focused {\n border: 1px solid #77ade4;\n }\n}\n";
|
|
410
410
|
var CountdownTimerCSS = "\n.countdown-timer-container {\n display: flex;\n justify-content: center;\n gap: 4px;\n .countdown-message,\n .countdown-time {\n font-size: 12px;\n font-weight: 500;\n letter-spacing: 0em;\n line-height: 14px;\n text-align: center;\n }\n .countdown-time {\n color: #3bb75e;\n }\n .countdown-time--completing {\n color: #f05050;\n }\n}\n";
|
|
411
|
-
var OptRetryCSS = "\n.pre-checkout-modal .link-retry-text {\n color: #3bb75e;\n cursor: pointer;\n margin-top: 24px;\n}\n
|
|
411
|
+
var OptRetryCSS = "\n.pre-checkout-modal .link-retry-text {\n color: #3bb75e;\n cursor: pointer;\n margin-top: 24px;\n}\n";
|
|
412
412
|
var LoaderCSS = "\n.loader {\n margin: 24px auto 8px;\n text-align: center;\n color: white;\n}\n@keyframes loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n}\n@-webkit-keyframes loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n}\n.loader__spinner {\n position: relative;\n display: inline-block;\n}\n.loader__spinner div {\n left: 95px;\n top: 35px;\n position: absolute;\n -webkit-animation: loader__spinner linear 1s infinite;\n animation: loader__spinner linear 1s infinite;\n background: #393939;\n width: 10px;\n height: 30px;\n border-radius: 40%;\n -webkit-transform-origin: 5px 65px;\n transform-origin: 5px 65px;\n}\n.loader__spinner div:nth-child(1) {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n -webkit-animation-delay: -0.916666666666667s;\n animation-delay: -0.916666666666667s;\n}\n.loader__spinner div:nth-child(2) {\n -webkit-transform: rotate(30deg);\n transform: rotate(30deg);\n -webkit-animation-delay: -0.833333333333333s;\n animation-delay: -0.833333333333333s;\n}\n.loader__spinner div:nth-child(3) {\n -webkit-transform: rotate(60deg);\n transform: rotate(60deg);\n -webkit-animation-delay: -0.75s;\n animation-delay: -0.75s;\n}\n.loader__spinner div:nth-child(4) {\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg);\n -webkit-animation-delay: -0.666666666666667s;\n animation-delay: -0.666666666666667s;\n}\n.loader__spinner div:nth-child(5) {\n -webkit-transform: rotate(120deg);\n transform: rotate(120deg);\n -webkit-animation-delay: -0.583333333333333s;\n animation-delay: -0.583333333333333s;\n}\n.loader__spinner div:nth-child(6) {\n -webkit-transform: rotate(150deg);\n transform: rotate(150deg);\n -webkit-animation-delay: -0.5s;\n animation-delay: -0.5s;\n}\n.loader__spinner div:nth-child(7) {\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n -webkit-animation-delay: -0.416666666666667s;\n animation-delay: -0.416666666666667s;\n}\n.loader__spinner div:nth-child(8) {\n -webkit-transform: rotate(210deg);\n transform: rotate(210deg);\n -webkit-animation-delay: -0.333333333333333s;\n animation-delay: -0.333333333333333s;\n}\n.loader__spinner div:nth-child(9) {\n -webkit-transform: rotate(240deg);\n transform: rotate(240deg);\n -webkit-animation-delay: -0.25s;\n animation-delay: -0.25s;\n}\n.loader__spinner div:nth-child(10) {\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg);\n -webkit-animation-delay: -0.166666666666667s;\n animation-delay: -0.166666666666667s;\n}\n.loader__spinner div:nth-child(11) {\n -webkit-transform: rotate(300deg);\n transform: rotate(300deg);\n -webkit-animation-delay: -0.083333333333333s;\n animation-delay: -0.083333333333333s;\n}\n.loader__spinner div:nth-child(12) {\n -webkit-transform: rotate(330deg);\n transform: rotate(330deg);\n -webkit-animation-delay: 0s;\n animation-delay: 0s;\n}\n.loader__spinner {\n width: 40px;\n height: 40px;\n -webkit-transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n}\n";
|
|
413
413
|
/**
|
|
414
414
|
* Loads CSS styles dynamically into the document.
|
|
@@ -650,11 +650,6 @@ var PaystackPop = (function () {
|
|
|
650
650
|
return PinInput;
|
|
651
651
|
}();
|
|
652
652
|
|
|
653
|
-
var CHARGE_TYPES = {
|
|
654
|
-
RECURRING: 'resume',
|
|
655
|
-
PREAUTHORIZATION: 'preauthorization',
|
|
656
|
-
DEFAULT: 'default'
|
|
657
|
-
};
|
|
658
653
|
/**
|
|
659
654
|
* Get the common headers for the request.
|
|
660
655
|
* @param {Object} param - Request parameters.
|
|
@@ -674,18 +669,6 @@ var PaystackPop = (function () {
|
|
|
674
669
|
Authorization: "Bearer ".concat(token)
|
|
675
670
|
});
|
|
676
671
|
};
|
|
677
|
-
/**
|
|
678
|
-
* Get the charge type from the URL.
|
|
679
|
-
* @returns {String} - Charge type.
|
|
680
|
-
*/
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
function getChargeType() {
|
|
684
|
-
var _window, _window$location, _window$location$path;
|
|
685
|
-
|
|
686
|
-
var chargeType = (_window = window) === null || _window === void 0 ? void 0 : (_window$location = _window.location) === null || _window$location === void 0 ? void 0 : (_window$location$path = _window$location.pathname) === null || _window$location$path === void 0 ? void 0 : _window$location$path.split('/').slice(1)[0];
|
|
687
|
-
return [CHARGE_TYPES.RECURRING, CHARGE_TYPES.PREAUTHORIZATION].includes(chargeType) ? chargeType : CHARGE_TYPES.DEFAULT;
|
|
688
|
-
}
|
|
689
672
|
/**
|
|
690
673
|
* send OTP to the user's email or phone number.
|
|
691
674
|
* @param {Object} transaction - Transaction object.
|
|
@@ -768,7 +751,7 @@ var PaystackPop = (function () {
|
|
|
768
751
|
function canPayWithLink(transaction) {
|
|
769
752
|
var _transaction$link_con, _transaction$link_con2;
|
|
770
753
|
|
|
771
|
-
return (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con = transaction.link_config) === null || _transaction$link_con === void 0 ? void 0 : _transaction$link_con.enabled) && (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con2 = transaction.link_config) === null || _transaction$link_con2 === void 0 ? void 0 : _transaction$link_con2.has_payment_instruments)
|
|
754
|
+
return (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con = transaction.link_config) === null || _transaction$link_con === void 0 ? void 0 : _transaction$link_con.enabled) && (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con2 = transaction.link_config) === null || _transaction$link_con2 === void 0 ? void 0 : _transaction$link_con2.has_payment_instruments);
|
|
772
755
|
}
|
|
773
756
|
|
|
774
757
|
var CountdownTimer = /*#__PURE__*/function () {
|
|
@@ -923,15 +906,11 @@ var PaystackPop = (function () {
|
|
|
923
906
|
this.container = document.createElement('div');
|
|
924
907
|
this.container.id = 'otp-retry-container';
|
|
925
908
|
this.resendOtpText = document.createElement('p');
|
|
926
|
-
this.otpErrorText = document.createElement('p');
|
|
927
909
|
this.otpHint = document.createElement('p');
|
|
928
910
|
this.countdownContainer = document.createElement('div');
|
|
929
911
|
this.resendOtpText.className = 'link-retry-text';
|
|
930
912
|
this.resendOtpText.innerText = OTP_RESEND_COUNT_CONFIG[this.otpResendCount].text;
|
|
931
913
|
this.container.appendChild(this.resendOtpText);
|
|
932
|
-
this.otpErrorText.className = 'link-retry-error';
|
|
933
|
-
this.otpErrorText.style.display = 'none';
|
|
934
|
-
this.container.appendChild(this.otpErrorText);
|
|
935
914
|
this.otpHint.className = 'link-retry-text';
|
|
936
915
|
this.otpHint.innerText = 'Still not getting OTPs?';
|
|
937
916
|
this.otpHint.style.display = 'none';
|
|
@@ -951,12 +930,11 @@ var PaystackPop = (function () {
|
|
|
951
930
|
sendLinkOtp({
|
|
952
931
|
channels: channels || OTP_RESEND_COUNT_CONFIG[this.otpResendCount].channels,
|
|
953
932
|
email: this.transaction.email,
|
|
954
|
-
transaction: this.transaction
|
|
933
|
+
transaction: this.transaction
|
|
955
934
|
}).then(function (response) {
|
|
956
935
|
return _this.onSuccess(response.data.token);
|
|
957
|
-
}).catch(function (
|
|
958
|
-
|
|
959
|
-
_this.otpErrorText.style.display = 'block';
|
|
936
|
+
}).catch(function () {// catching here so a unhandledrejection error is not thrown
|
|
937
|
+
// We don't want to show an error to the user in the event of a failure
|
|
960
938
|
});
|
|
961
939
|
}
|
|
962
940
|
}, {
|
|
@@ -1523,7 +1501,10 @@ var PaystackPop = (function () {
|
|
|
1523
1501
|
* */
|
|
1524
1502
|
|
|
1525
1503
|
|
|
1526
|
-
function getLinkContent(
|
|
1504
|
+
function getLinkContent(_ref4) {
|
|
1505
|
+
var transaction = _ref4.transaction,
|
|
1506
|
+
closePreCheckoutModal = _ref4.closePreCheckoutModal,
|
|
1507
|
+
inlineInstanceId = _ref4.inlineInstanceId;
|
|
1527
1508
|
var wrapper = document.createElement('div');
|
|
1528
1509
|
wrapper.classList.add('modal-wrapper');
|
|
1529
1510
|
wrapper.innerHTML = wrapper.innerHTML + secureByPaystackWhite + secureByPaystackGrey;
|
|
@@ -1556,13 +1537,14 @@ var PaystackPop = (function () {
|
|
|
1556
1537
|
transaction: transaction,
|
|
1557
1538
|
token: linkToken
|
|
1558
1539
|
}).then(function (response) {
|
|
1559
|
-
getCheckoutIframe().contentWindow.postMessage({
|
|
1540
|
+
getCheckoutIframe(inlineInstanceId).contentWindow.postMessage({
|
|
1560
1541
|
type: 'link-success',
|
|
1561
1542
|
data: response
|
|
1562
1543
|
}, '*');
|
|
1563
1544
|
otpRetry.unmount();
|
|
1564
1545
|
loader.unmount();
|
|
1565
1546
|
pinInput.unmount();
|
|
1547
|
+
closePreCheckoutModal();
|
|
1566
1548
|
}).catch(function (error) {
|
|
1567
1549
|
loader.hide();
|
|
1568
1550
|
otpRetry.show();
|
|
@@ -1598,7 +1580,7 @@ var PaystackPop = (function () {
|
|
|
1598
1580
|
return wrapper;
|
|
1599
1581
|
}
|
|
1600
1582
|
|
|
1601
|
-
function mountPreCheckoutModal(id, transaction) {
|
|
1583
|
+
function mountPreCheckoutModal(id, transaction, closePreCheckoutModal) {
|
|
1602
1584
|
var mountedModal = document.querySelector("#pre-checkout-modal-".concat(id));
|
|
1603
1585
|
|
|
1604
1586
|
if (mountedModal) {
|
|
@@ -1617,13 +1599,13 @@ var PaystackPop = (function () {
|
|
|
1617
1599
|
content.classList.add('pre-checkout-modal__content');
|
|
1618
1600
|
modal.appendChild(content);
|
|
1619
1601
|
|
|
1620
|
-
var
|
|
1621
|
-
merchantLogo =
|
|
1622
|
-
merchantName =
|
|
1623
|
-
email =
|
|
1624
|
-
amount =
|
|
1625
|
-
currency =
|
|
1626
|
-
label =
|
|
1602
|
+
var _ref5 = transaction || {},
|
|
1603
|
+
merchantLogo = _ref5.merchant_logo,
|
|
1604
|
+
merchantName = _ref5.merchant_name,
|
|
1605
|
+
email = _ref5.email,
|
|
1606
|
+
amount = _ref5.amount,
|
|
1607
|
+
currency = _ref5.currency,
|
|
1608
|
+
label = _ref5.label;
|
|
1627
1609
|
|
|
1628
1610
|
var applePayPaymentInfo = document.createElement('div');
|
|
1629
1611
|
var formattedAmount = new Intl.NumberFormat('en', {
|
|
@@ -1637,7 +1619,11 @@ var PaystackPop = (function () {
|
|
|
1637
1619
|
applePayPaymentInfo.innerHTML = "<img class=\"merchant-logo\" src=\"".concat(merchantLogo, "\" alt=\"").concat(merchantName, " Logo\">\n <div class=\"customer-info\">\n <div class=\"customer-email\">").concat(label || email, "</div>\n <div class=\"transaction-amount\">Pay <span class=\"amount\">").concat(formattedAmount, "</span></div>\n </div>");
|
|
1638
1620
|
content.appendChild(applePayPaymentInfo);
|
|
1639
1621
|
content.innerHTML += applePayCloseButton;
|
|
1640
|
-
var wrapper = canPayWithLink(transaction) ? getLinkContent(
|
|
1622
|
+
var wrapper = canPayWithLink(transaction) ? getLinkContent({
|
|
1623
|
+
transaction: transaction,
|
|
1624
|
+
closePreCheckoutModal: closePreCheckoutModal,
|
|
1625
|
+
inlineInstanceId: id
|
|
1626
|
+
}) : getApplePayContent();
|
|
1641
1627
|
content.appendChild(wrapper);
|
|
1642
1628
|
var style = document.createElement('style');
|
|
1643
1629
|
style.textContent = preCheckoutModalCSS;
|
|
@@ -2529,9 +2515,16 @@ var PaystackPop = (function () {
|
|
|
2529
2515
|
inlineInstance = this;
|
|
2530
2516
|
var resumableTransaction = findResumableTransaction(this.transactions, params);
|
|
2531
2517
|
var transaction = resumableTransaction || new InlineTransaction(params);
|
|
2518
|
+
|
|
2519
|
+
var closePreCheckoutModal = function closePreCheckoutModal() {
|
|
2520
|
+
inlineInstance.closePreCheckoutModal();
|
|
2521
|
+
inlineInstance.animateCheckoutIn();
|
|
2522
|
+
};
|
|
2523
|
+
|
|
2532
2524
|
return new Promise(function (resolve, reject) {
|
|
2533
2525
|
transaction.requestInline().then(function (response) {
|
|
2534
|
-
var
|
|
2526
|
+
var linkEnabled = canPayWithLink(response);
|
|
2527
|
+
var shouldLoadPreCheckoutModal = linkEnabled || canUseApplePay(response.channels);
|
|
2535
2528
|
|
|
2536
2529
|
if (!shouldLoadPreCheckoutModal) {
|
|
2537
2530
|
inlineInstance.newTransaction({
|
|
@@ -2542,7 +2535,7 @@ var PaystackPop = (function () {
|
|
|
2542
2535
|
inlineInstance.preloadTransaction({
|
|
2543
2536
|
inlineTransaction: transaction
|
|
2544
2537
|
});
|
|
2545
|
-
inlineInstance.preCheckoutModal = mountPreCheckoutModal(inlineInstance.id, response);
|
|
2538
|
+
inlineInstance.preCheckoutModal = mountPreCheckoutModal(inlineInstance.id, response, closePreCheckoutModal);
|
|
2546
2539
|
inlineInstance.paymentRequestContainer = getPreCheckoutModalPaymentRequestContainer(inlineInstance.preCheckoutModal);
|
|
2547
2540
|
mountPaymentRequestButtons(inlineInstance.paymentRequestContainer, {
|
|
2548
2541
|
channels: response.channels,
|
|
@@ -2557,10 +2550,17 @@ var PaystackPop = (function () {
|
|
|
2557
2550
|
}
|
|
2558
2551
|
}, response.merchant_id).then(function () {
|
|
2559
2552
|
inlineInstance.registerPaymentRequestEventListeners();
|
|
2560
|
-
}).finally(function () {
|
|
2561
2553
|
inlineInstance.registerPreCheckoutModalEventListeners();
|
|
2562
2554
|
animatePreCheckoutModalIn(inlineInstance.preCheckoutModal);
|
|
2563
2555
|
resolve(transaction);
|
|
2556
|
+
}).catch(function () {
|
|
2557
|
+
if (linkEnabled) {
|
|
2558
|
+
inlineInstance.registerPreCheckoutModalEventListeners();
|
|
2559
|
+
animatePreCheckoutModalIn(inlineInstance.preCheckoutModal);
|
|
2560
|
+
resolve(transaction);
|
|
2561
|
+
} else {
|
|
2562
|
+
closePreCheckoutModal();
|
|
2563
|
+
}
|
|
2564
2564
|
});
|
|
2565
2565
|
}
|
|
2566
2566
|
}).catch(function (error) {
|
package/es/inline.js
CHANGED
|
@@ -402,10 +402,10 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
|
|
|
402
402
|
locale = _ref2.locale;
|
|
403
403
|
return "\n @supports (-webkit-appearance: -apple-pay-button) { \n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n width: ".concat(width, ";\n height: ").concat(height, ";\n border-radius: ").concat(borderRadius, ";\n padding: ").concat(padding, ";\n -apple-pay-button-type: ").concat(type, ";\n -webkit-locale: ").concat(locale, ";\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n");
|
|
404
404
|
};
|
|
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 padding: 0 16px;\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:
|
|
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 padding: 0 16px;\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 background: #FAFAFA;\n border: 1px solid #F2F3F3;\n box-sizing: border-box;\n border-radius: 3px;\n color: #4E4E4E;\n font-weight: 500;\n font-size: 14px;\n line-height: 24px;\n cursor: pointer;\n\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 button:hover, \n .pre-checkout-modal button:active, \n .pre-checkout-modal button:focus {\n background: #F2F3F3;\n }\n\n .pre-checkout-modal .link-description {\n color: #2f3d4d;\n font-size: 14px;\n letter-spacing: normal;\n line-height: 1.4;\n margin: 0 auto 24px;\n max-width: 260px;\n padding: 0;\n }\n\n .link-logo {\n margin-bottom: 24px;\n }\n\n .pre-checkout-modal .link-error {\n color: #d44141;\n margin-top: 24px;\n }\n\n .link-divider {\n margin-bottom: 16px;\n margin-top: 24px;\n position: relative;\n }\n\n .link-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\n .link-divider__line {\n border: 1px dashed #ccced0;\n width: 100%;\n }\n\n .link-divider__text-container {\n display: flex;\n justify-content: center;\n position: relative;\n }\n\n .link-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-left: 8px;\n padding-right: 8px;\n }\n\n .link-otp-not-received {\n background-color: #f5f6f7;\n padding: 20px;\n margin-bottom: 16px;\n border-radius: 4px;\n text-align: center;\n\n .description,\n .title {\n font-weight: 400;\n font-size: 14px;\n line-height: 21px;\n color: #323d4b;\n\n @media all and (min-width: 529px) {\n width: 270px;\n padding: 0 4px;\n margin: 0 auto;\n }\n }\n .title {\n font-weight: 500;\n margin-bottom: 12px;\n }\n .description {\n margin-bottom: 24px;\n }\n }\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 #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
406
|
var PinInputCSS = "\n.pin-input-container {\n display: flex;\n justify-content: center;\n gap: 8px;\n .pin-input {\n border-radius: 3px;\n border: 1px solid #e4e4e4;\n color: #011b33;\n font-size: 14px;\n font-weight: 500;\n height: 40px;\n letter-spacing: -0.1px;\n line-height: 19.6px;\n margin: 0;\n outline: none;\n text-align: center;\n width: 40px;\n }\n .pin-input:hover,\n .pin-input--focused {\n border: 1px solid #77ade4;\n }\n}\n";
|
|
407
407
|
var CountdownTimerCSS = "\n.countdown-timer-container {\n display: flex;\n justify-content: center;\n gap: 4px;\n .countdown-message,\n .countdown-time {\n font-size: 12px;\n font-weight: 500;\n letter-spacing: 0em;\n line-height: 14px;\n text-align: center;\n }\n .countdown-time {\n color: #3bb75e;\n }\n .countdown-time--completing {\n color: #f05050;\n }\n}\n";
|
|
408
|
-
var OptRetryCSS = "\n.pre-checkout-modal .link-retry-text {\n color: #3bb75e;\n cursor: pointer;\n margin-top: 24px;\n}\n
|
|
408
|
+
var OptRetryCSS = "\n.pre-checkout-modal .link-retry-text {\n color: #3bb75e;\n cursor: pointer;\n margin-top: 24px;\n}\n";
|
|
409
409
|
var LoaderCSS = "\n.loader {\n margin: 24px auto 8px;\n text-align: center;\n color: white;\n}\n@keyframes loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n}\n@-webkit-keyframes loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n}\n.loader__spinner {\n position: relative;\n display: inline-block;\n}\n.loader__spinner div {\n left: 95px;\n top: 35px;\n position: absolute;\n -webkit-animation: loader__spinner linear 1s infinite;\n animation: loader__spinner linear 1s infinite;\n background: #393939;\n width: 10px;\n height: 30px;\n border-radius: 40%;\n -webkit-transform-origin: 5px 65px;\n transform-origin: 5px 65px;\n}\n.loader__spinner div:nth-child(1) {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n -webkit-animation-delay: -0.916666666666667s;\n animation-delay: -0.916666666666667s;\n}\n.loader__spinner div:nth-child(2) {\n -webkit-transform: rotate(30deg);\n transform: rotate(30deg);\n -webkit-animation-delay: -0.833333333333333s;\n animation-delay: -0.833333333333333s;\n}\n.loader__spinner div:nth-child(3) {\n -webkit-transform: rotate(60deg);\n transform: rotate(60deg);\n -webkit-animation-delay: -0.75s;\n animation-delay: -0.75s;\n}\n.loader__spinner div:nth-child(4) {\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg);\n -webkit-animation-delay: -0.666666666666667s;\n animation-delay: -0.666666666666667s;\n}\n.loader__spinner div:nth-child(5) {\n -webkit-transform: rotate(120deg);\n transform: rotate(120deg);\n -webkit-animation-delay: -0.583333333333333s;\n animation-delay: -0.583333333333333s;\n}\n.loader__spinner div:nth-child(6) {\n -webkit-transform: rotate(150deg);\n transform: rotate(150deg);\n -webkit-animation-delay: -0.5s;\n animation-delay: -0.5s;\n}\n.loader__spinner div:nth-child(7) {\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n -webkit-animation-delay: -0.416666666666667s;\n animation-delay: -0.416666666666667s;\n}\n.loader__spinner div:nth-child(8) {\n -webkit-transform: rotate(210deg);\n transform: rotate(210deg);\n -webkit-animation-delay: -0.333333333333333s;\n animation-delay: -0.333333333333333s;\n}\n.loader__spinner div:nth-child(9) {\n -webkit-transform: rotate(240deg);\n transform: rotate(240deg);\n -webkit-animation-delay: -0.25s;\n animation-delay: -0.25s;\n}\n.loader__spinner div:nth-child(10) {\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg);\n -webkit-animation-delay: -0.166666666666667s;\n animation-delay: -0.166666666666667s;\n}\n.loader__spinner div:nth-child(11) {\n -webkit-transform: rotate(300deg);\n transform: rotate(300deg);\n -webkit-animation-delay: -0.083333333333333s;\n animation-delay: -0.083333333333333s;\n}\n.loader__spinner div:nth-child(12) {\n -webkit-transform: rotate(330deg);\n transform: rotate(330deg);\n -webkit-animation-delay: 0s;\n animation-delay: 0s;\n}\n.loader__spinner {\n width: 40px;\n height: 40px;\n -webkit-transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n}\n";
|
|
410
410
|
/**
|
|
411
411
|
* Loads CSS styles dynamically into the document.
|
|
@@ -647,11 +647,6 @@ var PinInput = /*#__PURE__*/function () {
|
|
|
647
647
|
return PinInput;
|
|
648
648
|
}();
|
|
649
649
|
|
|
650
|
-
var CHARGE_TYPES = {
|
|
651
|
-
RECURRING: 'resume',
|
|
652
|
-
PREAUTHORIZATION: 'preauthorization',
|
|
653
|
-
DEFAULT: 'default'
|
|
654
|
-
};
|
|
655
650
|
/**
|
|
656
651
|
* Get the common headers for the request.
|
|
657
652
|
* @param {Object} param - Request parameters.
|
|
@@ -671,18 +666,6 @@ var getCommonHeaders = function getCommonHeaders(_ref) {
|
|
|
671
666
|
Authorization: "Bearer ".concat(token)
|
|
672
667
|
});
|
|
673
668
|
};
|
|
674
|
-
/**
|
|
675
|
-
* Get the charge type from the URL.
|
|
676
|
-
* @returns {String} - Charge type.
|
|
677
|
-
*/
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
function getChargeType() {
|
|
681
|
-
var _window, _window$location, _window$location$path;
|
|
682
|
-
|
|
683
|
-
var chargeType = (_window = window) === null || _window === void 0 ? void 0 : (_window$location = _window.location) === null || _window$location === void 0 ? void 0 : (_window$location$path = _window$location.pathname) === null || _window$location$path === void 0 ? void 0 : _window$location$path.split('/').slice(1)[0];
|
|
684
|
-
return [CHARGE_TYPES.RECURRING, CHARGE_TYPES.PREAUTHORIZATION].includes(chargeType) ? chargeType : CHARGE_TYPES.DEFAULT;
|
|
685
|
-
}
|
|
686
669
|
/**
|
|
687
670
|
* send OTP to the user's email or phone number.
|
|
688
671
|
* @param {Object} transaction - Transaction object.
|
|
@@ -765,7 +748,7 @@ function verifyLinkOtp(_ref3) {
|
|
|
765
748
|
function canPayWithLink(transaction) {
|
|
766
749
|
var _transaction$link_con, _transaction$link_con2;
|
|
767
750
|
|
|
768
|
-
return (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con = transaction.link_config) === null || _transaction$link_con === void 0 ? void 0 : _transaction$link_con.enabled) && (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con2 = transaction.link_config) === null || _transaction$link_con2 === void 0 ? void 0 : _transaction$link_con2.has_payment_instruments)
|
|
751
|
+
return (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con = transaction.link_config) === null || _transaction$link_con === void 0 ? void 0 : _transaction$link_con.enabled) && (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con2 = transaction.link_config) === null || _transaction$link_con2 === void 0 ? void 0 : _transaction$link_con2.has_payment_instruments);
|
|
769
752
|
}
|
|
770
753
|
|
|
771
754
|
var CountdownTimer = /*#__PURE__*/function () {
|
|
@@ -920,15 +903,11 @@ var OtpRetry = /*#__PURE__*/function () {
|
|
|
920
903
|
this.container = document.createElement('div');
|
|
921
904
|
this.container.id = 'otp-retry-container';
|
|
922
905
|
this.resendOtpText = document.createElement('p');
|
|
923
|
-
this.otpErrorText = document.createElement('p');
|
|
924
906
|
this.otpHint = document.createElement('p');
|
|
925
907
|
this.countdownContainer = document.createElement('div');
|
|
926
908
|
this.resendOtpText.className = 'link-retry-text';
|
|
927
909
|
this.resendOtpText.innerText = OTP_RESEND_COUNT_CONFIG[this.otpResendCount].text;
|
|
928
910
|
this.container.appendChild(this.resendOtpText);
|
|
929
|
-
this.otpErrorText.className = 'link-retry-error';
|
|
930
|
-
this.otpErrorText.style.display = 'none';
|
|
931
|
-
this.container.appendChild(this.otpErrorText);
|
|
932
911
|
this.otpHint.className = 'link-retry-text';
|
|
933
912
|
this.otpHint.innerText = 'Still not getting OTPs?';
|
|
934
913
|
this.otpHint.style.display = 'none';
|
|
@@ -948,12 +927,11 @@ var OtpRetry = /*#__PURE__*/function () {
|
|
|
948
927
|
sendLinkOtp({
|
|
949
928
|
channels: channels || OTP_RESEND_COUNT_CONFIG[this.otpResendCount].channels,
|
|
950
929
|
email: this.transaction.email,
|
|
951
|
-
transaction: this.transaction
|
|
930
|
+
transaction: this.transaction
|
|
952
931
|
}).then(function (response) {
|
|
953
932
|
return _this.onSuccess(response.data.token);
|
|
954
|
-
}).catch(function (
|
|
955
|
-
|
|
956
|
-
_this.otpErrorText.style.display = 'block';
|
|
933
|
+
}).catch(function () {// catching here so a unhandledrejection error is not thrown
|
|
934
|
+
// We don't want to show an error to the user in the event of a failure
|
|
957
935
|
});
|
|
958
936
|
}
|
|
959
937
|
}, {
|
|
@@ -1520,7 +1498,10 @@ function getLinkOtpHelp(linkContainer) {
|
|
|
1520
1498
|
* */
|
|
1521
1499
|
|
|
1522
1500
|
|
|
1523
|
-
function getLinkContent(
|
|
1501
|
+
function getLinkContent(_ref4) {
|
|
1502
|
+
var transaction = _ref4.transaction,
|
|
1503
|
+
closePreCheckoutModal = _ref4.closePreCheckoutModal,
|
|
1504
|
+
inlineInstanceId = _ref4.inlineInstanceId;
|
|
1524
1505
|
var wrapper = document.createElement('div');
|
|
1525
1506
|
wrapper.classList.add('modal-wrapper');
|
|
1526
1507
|
wrapper.innerHTML = wrapper.innerHTML + secureByPaystackWhite + secureByPaystackGrey;
|
|
@@ -1553,13 +1534,14 @@ function getLinkContent(transaction) {
|
|
|
1553
1534
|
transaction: transaction,
|
|
1554
1535
|
token: linkToken
|
|
1555
1536
|
}).then(function (response) {
|
|
1556
|
-
getCheckoutIframe().contentWindow.postMessage({
|
|
1537
|
+
getCheckoutIframe(inlineInstanceId).contentWindow.postMessage({
|
|
1557
1538
|
type: 'link-success',
|
|
1558
1539
|
data: response
|
|
1559
1540
|
}, '*');
|
|
1560
1541
|
otpRetry.unmount();
|
|
1561
1542
|
loader.unmount();
|
|
1562
1543
|
pinInput.unmount();
|
|
1544
|
+
closePreCheckoutModal();
|
|
1563
1545
|
}).catch(function (error) {
|
|
1564
1546
|
loader.hide();
|
|
1565
1547
|
otpRetry.show();
|
|
@@ -1595,7 +1577,7 @@ function getLinkContent(transaction) {
|
|
|
1595
1577
|
return wrapper;
|
|
1596
1578
|
}
|
|
1597
1579
|
|
|
1598
|
-
function mountPreCheckoutModal(id, transaction) {
|
|
1580
|
+
function mountPreCheckoutModal(id, transaction, closePreCheckoutModal) {
|
|
1599
1581
|
var mountedModal = document.querySelector("#pre-checkout-modal-".concat(id));
|
|
1600
1582
|
|
|
1601
1583
|
if (mountedModal) {
|
|
@@ -1614,13 +1596,13 @@ function mountPreCheckoutModal(id, transaction) {
|
|
|
1614
1596
|
content.classList.add('pre-checkout-modal__content');
|
|
1615
1597
|
modal.appendChild(content);
|
|
1616
1598
|
|
|
1617
|
-
var
|
|
1618
|
-
merchantLogo =
|
|
1619
|
-
merchantName =
|
|
1620
|
-
email =
|
|
1621
|
-
amount =
|
|
1622
|
-
currency =
|
|
1623
|
-
label =
|
|
1599
|
+
var _ref5 = transaction || {},
|
|
1600
|
+
merchantLogo = _ref5.merchant_logo,
|
|
1601
|
+
merchantName = _ref5.merchant_name,
|
|
1602
|
+
email = _ref5.email,
|
|
1603
|
+
amount = _ref5.amount,
|
|
1604
|
+
currency = _ref5.currency,
|
|
1605
|
+
label = _ref5.label;
|
|
1624
1606
|
|
|
1625
1607
|
var applePayPaymentInfo = document.createElement('div');
|
|
1626
1608
|
var formattedAmount = new Intl.NumberFormat('en', {
|
|
@@ -1634,7 +1616,11 @@ function mountPreCheckoutModal(id, transaction) {
|
|
|
1634
1616
|
applePayPaymentInfo.innerHTML = "<img class=\"merchant-logo\" src=\"".concat(merchantLogo, "\" alt=\"").concat(merchantName, " Logo\">\n <div class=\"customer-info\">\n <div class=\"customer-email\">").concat(label || email, "</div>\n <div class=\"transaction-amount\">Pay <span class=\"amount\">").concat(formattedAmount, "</span></div>\n </div>");
|
|
1635
1617
|
content.appendChild(applePayPaymentInfo);
|
|
1636
1618
|
content.innerHTML += applePayCloseButton;
|
|
1637
|
-
var wrapper = canPayWithLink(transaction) ? getLinkContent(
|
|
1619
|
+
var wrapper = canPayWithLink(transaction) ? getLinkContent({
|
|
1620
|
+
transaction: transaction,
|
|
1621
|
+
closePreCheckoutModal: closePreCheckoutModal,
|
|
1622
|
+
inlineInstanceId: id
|
|
1623
|
+
}) : getApplePayContent();
|
|
1638
1624
|
content.appendChild(wrapper);
|
|
1639
1625
|
var style = document.createElement('style');
|
|
1640
1626
|
style.textContent = preCheckoutModalCSS;
|
|
@@ -2526,9 +2512,16 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2526
2512
|
inlineInstance = this;
|
|
2527
2513
|
var resumableTransaction = findResumableTransaction(this.transactions, params);
|
|
2528
2514
|
var transaction = resumableTransaction || new InlineTransaction(params);
|
|
2515
|
+
|
|
2516
|
+
var closePreCheckoutModal = function closePreCheckoutModal() {
|
|
2517
|
+
inlineInstance.closePreCheckoutModal();
|
|
2518
|
+
inlineInstance.animateCheckoutIn();
|
|
2519
|
+
};
|
|
2520
|
+
|
|
2529
2521
|
return new Promise(function (resolve, reject) {
|
|
2530
2522
|
transaction.requestInline().then(function (response) {
|
|
2531
|
-
var
|
|
2523
|
+
var linkEnabled = canPayWithLink(response);
|
|
2524
|
+
var shouldLoadPreCheckoutModal = linkEnabled || canUseApplePay(response.channels);
|
|
2532
2525
|
|
|
2533
2526
|
if (!shouldLoadPreCheckoutModal) {
|
|
2534
2527
|
inlineInstance.newTransaction({
|
|
@@ -2539,7 +2532,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2539
2532
|
inlineInstance.preloadTransaction({
|
|
2540
2533
|
inlineTransaction: transaction
|
|
2541
2534
|
});
|
|
2542
|
-
inlineInstance.preCheckoutModal = mountPreCheckoutModal(inlineInstance.id, response);
|
|
2535
|
+
inlineInstance.preCheckoutModal = mountPreCheckoutModal(inlineInstance.id, response, closePreCheckoutModal);
|
|
2543
2536
|
inlineInstance.paymentRequestContainer = getPreCheckoutModalPaymentRequestContainer(inlineInstance.preCheckoutModal);
|
|
2544
2537
|
mountPaymentRequestButtons(inlineInstance.paymentRequestContainer, {
|
|
2545
2538
|
channels: response.channels,
|
|
@@ -2554,10 +2547,17 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2554
2547
|
}
|
|
2555
2548
|
}, response.merchant_id).then(function () {
|
|
2556
2549
|
inlineInstance.registerPaymentRequestEventListeners();
|
|
2557
|
-
}).finally(function () {
|
|
2558
2550
|
inlineInstance.registerPreCheckoutModalEventListeners();
|
|
2559
2551
|
animatePreCheckoutModalIn(inlineInstance.preCheckoutModal);
|
|
2560
2552
|
resolve(transaction);
|
|
2553
|
+
}).catch(function () {
|
|
2554
|
+
if (linkEnabled) {
|
|
2555
|
+
inlineInstance.registerPreCheckoutModalEventListeners();
|
|
2556
|
+
animatePreCheckoutModalIn(inlineInstance.preCheckoutModal);
|
|
2557
|
+
resolve(transaction);
|
|
2558
|
+
} else {
|
|
2559
|
+
closePreCheckoutModal();
|
|
2560
|
+
}
|
|
2561
2561
|
});
|
|
2562
2562
|
}
|
|
2563
2563
|
}).catch(function (error) {
|
package/lib/inline.js
CHANGED
|
@@ -404,10 +404,10 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
|
|
|
404
404
|
locale = _ref2.locale;
|
|
405
405
|
return "\n @supports (-webkit-appearance: -apple-pay-button) { \n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n width: ".concat(width, ";\n height: ").concat(height, ";\n border-radius: ").concat(borderRadius, ";\n padding: ").concat(padding, ";\n -apple-pay-button-type: ").concat(type, ";\n -webkit-locale: ").concat(locale, ";\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n");
|
|
406
406
|
};
|
|
407
|
-
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 padding: 0 16px;\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:
|
|
407
|
+
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 padding: 0 16px;\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 background: #FAFAFA;\n border: 1px solid #F2F3F3;\n box-sizing: border-box;\n border-radius: 3px;\n color: #4E4E4E;\n font-weight: 500;\n font-size: 14px;\n line-height: 24px;\n cursor: pointer;\n\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 button:hover, \n .pre-checkout-modal button:active, \n .pre-checkout-modal button:focus {\n background: #F2F3F3;\n }\n\n .pre-checkout-modal .link-description {\n color: #2f3d4d;\n font-size: 14px;\n letter-spacing: normal;\n line-height: 1.4;\n margin: 0 auto 24px;\n max-width: 260px;\n padding: 0;\n }\n\n .link-logo {\n margin-bottom: 24px;\n }\n\n .pre-checkout-modal .link-error {\n color: #d44141;\n margin-top: 24px;\n }\n\n .link-divider {\n margin-bottom: 16px;\n margin-top: 24px;\n position: relative;\n }\n\n .link-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\n .link-divider__line {\n border: 1px dashed #ccced0;\n width: 100%;\n }\n\n .link-divider__text-container {\n display: flex;\n justify-content: center;\n position: relative;\n }\n\n .link-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-left: 8px;\n padding-right: 8px;\n }\n\n .link-otp-not-received {\n background-color: #f5f6f7;\n padding: 20px;\n margin-bottom: 16px;\n border-radius: 4px;\n text-align: center;\n\n .description,\n .title {\n font-weight: 400;\n font-size: 14px;\n line-height: 21px;\n color: #323d4b;\n\n @media all and (min-width: 529px) {\n width: 270px;\n padding: 0 4px;\n margin: 0 auto;\n }\n }\n .title {\n font-weight: 500;\n margin-bottom: 12px;\n }\n .description {\n margin-bottom: 24px;\n }\n }\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 #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";
|
|
408
408
|
var PinInputCSS = "\n.pin-input-container {\n display: flex;\n justify-content: center;\n gap: 8px;\n .pin-input {\n border-radius: 3px;\n border: 1px solid #e4e4e4;\n color: #011b33;\n font-size: 14px;\n font-weight: 500;\n height: 40px;\n letter-spacing: -0.1px;\n line-height: 19.6px;\n margin: 0;\n outline: none;\n text-align: center;\n width: 40px;\n }\n .pin-input:hover,\n .pin-input--focused {\n border: 1px solid #77ade4;\n }\n}\n";
|
|
409
409
|
var CountdownTimerCSS = "\n.countdown-timer-container {\n display: flex;\n justify-content: center;\n gap: 4px;\n .countdown-message,\n .countdown-time {\n font-size: 12px;\n font-weight: 500;\n letter-spacing: 0em;\n line-height: 14px;\n text-align: center;\n }\n .countdown-time {\n color: #3bb75e;\n }\n .countdown-time--completing {\n color: #f05050;\n }\n}\n";
|
|
410
|
-
var OptRetryCSS = "\n.pre-checkout-modal .link-retry-text {\n color: #3bb75e;\n cursor: pointer;\n margin-top: 24px;\n}\n
|
|
410
|
+
var OptRetryCSS = "\n.pre-checkout-modal .link-retry-text {\n color: #3bb75e;\n cursor: pointer;\n margin-top: 24px;\n}\n";
|
|
411
411
|
var LoaderCSS = "\n.loader {\n margin: 24px auto 8px;\n text-align: center;\n color: white;\n}\n@keyframes loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n}\n@-webkit-keyframes loader__spinner {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n}\n.loader__spinner {\n position: relative;\n display: inline-block;\n}\n.loader__spinner div {\n left: 95px;\n top: 35px;\n position: absolute;\n -webkit-animation: loader__spinner linear 1s infinite;\n animation: loader__spinner linear 1s infinite;\n background: #393939;\n width: 10px;\n height: 30px;\n border-radius: 40%;\n -webkit-transform-origin: 5px 65px;\n transform-origin: 5px 65px;\n}\n.loader__spinner div:nth-child(1) {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n -webkit-animation-delay: -0.916666666666667s;\n animation-delay: -0.916666666666667s;\n}\n.loader__spinner div:nth-child(2) {\n -webkit-transform: rotate(30deg);\n transform: rotate(30deg);\n -webkit-animation-delay: -0.833333333333333s;\n animation-delay: -0.833333333333333s;\n}\n.loader__spinner div:nth-child(3) {\n -webkit-transform: rotate(60deg);\n transform: rotate(60deg);\n -webkit-animation-delay: -0.75s;\n animation-delay: -0.75s;\n}\n.loader__spinner div:nth-child(4) {\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg);\n -webkit-animation-delay: -0.666666666666667s;\n animation-delay: -0.666666666666667s;\n}\n.loader__spinner div:nth-child(5) {\n -webkit-transform: rotate(120deg);\n transform: rotate(120deg);\n -webkit-animation-delay: -0.583333333333333s;\n animation-delay: -0.583333333333333s;\n}\n.loader__spinner div:nth-child(6) {\n -webkit-transform: rotate(150deg);\n transform: rotate(150deg);\n -webkit-animation-delay: -0.5s;\n animation-delay: -0.5s;\n}\n.loader__spinner div:nth-child(7) {\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n -webkit-animation-delay: -0.416666666666667s;\n animation-delay: -0.416666666666667s;\n}\n.loader__spinner div:nth-child(8) {\n -webkit-transform: rotate(210deg);\n transform: rotate(210deg);\n -webkit-animation-delay: -0.333333333333333s;\n animation-delay: -0.333333333333333s;\n}\n.loader__spinner div:nth-child(9) {\n -webkit-transform: rotate(240deg);\n transform: rotate(240deg);\n -webkit-animation-delay: -0.25s;\n animation-delay: -0.25s;\n}\n.loader__spinner div:nth-child(10) {\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg);\n -webkit-animation-delay: -0.166666666666667s;\n animation-delay: -0.166666666666667s;\n}\n.loader__spinner div:nth-child(11) {\n -webkit-transform: rotate(300deg);\n transform: rotate(300deg);\n -webkit-animation-delay: -0.083333333333333s;\n animation-delay: -0.083333333333333s;\n}\n.loader__spinner div:nth-child(12) {\n -webkit-transform: rotate(330deg);\n transform: rotate(330deg);\n -webkit-animation-delay: 0s;\n animation-delay: 0s;\n}\n.loader__spinner {\n width: 40px;\n height: 40px;\n -webkit-transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n transform: translate(-20px, -20px) scale(0.2) translate(20px, 20px);\n}\n";
|
|
412
412
|
/**
|
|
413
413
|
* Loads CSS styles dynamically into the document.
|
|
@@ -649,11 +649,6 @@ var PinInput = /*#__PURE__*/function () {
|
|
|
649
649
|
return PinInput;
|
|
650
650
|
}();
|
|
651
651
|
|
|
652
|
-
var CHARGE_TYPES = {
|
|
653
|
-
RECURRING: 'resume',
|
|
654
|
-
PREAUTHORIZATION: 'preauthorization',
|
|
655
|
-
DEFAULT: 'default'
|
|
656
|
-
};
|
|
657
652
|
/**
|
|
658
653
|
* Get the common headers for the request.
|
|
659
654
|
* @param {Object} param - Request parameters.
|
|
@@ -673,18 +668,6 @@ var getCommonHeaders = function getCommonHeaders(_ref) {
|
|
|
673
668
|
Authorization: "Bearer ".concat(token)
|
|
674
669
|
});
|
|
675
670
|
};
|
|
676
|
-
/**
|
|
677
|
-
* Get the charge type from the URL.
|
|
678
|
-
* @returns {String} - Charge type.
|
|
679
|
-
*/
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
function getChargeType() {
|
|
683
|
-
var _window, _window$location, _window$location$path;
|
|
684
|
-
|
|
685
|
-
var chargeType = (_window = window) === null || _window === void 0 ? void 0 : (_window$location = _window.location) === null || _window$location === void 0 ? void 0 : (_window$location$path = _window$location.pathname) === null || _window$location$path === void 0 ? void 0 : _window$location$path.split('/').slice(1)[0];
|
|
686
|
-
return [CHARGE_TYPES.RECURRING, CHARGE_TYPES.PREAUTHORIZATION].includes(chargeType) ? chargeType : CHARGE_TYPES.DEFAULT;
|
|
687
|
-
}
|
|
688
671
|
/**
|
|
689
672
|
* send OTP to the user's email or phone number.
|
|
690
673
|
* @param {Object} transaction - Transaction object.
|
|
@@ -767,7 +750,7 @@ function verifyLinkOtp(_ref3) {
|
|
|
767
750
|
function canPayWithLink(transaction) {
|
|
768
751
|
var _transaction$link_con, _transaction$link_con2;
|
|
769
752
|
|
|
770
|
-
return (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con = transaction.link_config) === null || _transaction$link_con === void 0 ? void 0 : _transaction$link_con.enabled) && (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con2 = transaction.link_config) === null || _transaction$link_con2 === void 0 ? void 0 : _transaction$link_con2.has_payment_instruments)
|
|
753
|
+
return (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con = transaction.link_config) === null || _transaction$link_con === void 0 ? void 0 : _transaction$link_con.enabled) && (transaction === null || transaction === void 0 ? void 0 : (_transaction$link_con2 = transaction.link_config) === null || _transaction$link_con2 === void 0 ? void 0 : _transaction$link_con2.has_payment_instruments);
|
|
771
754
|
}
|
|
772
755
|
|
|
773
756
|
var CountdownTimer = /*#__PURE__*/function () {
|
|
@@ -922,15 +905,11 @@ var OtpRetry = /*#__PURE__*/function () {
|
|
|
922
905
|
this.container = document.createElement('div');
|
|
923
906
|
this.container.id = 'otp-retry-container';
|
|
924
907
|
this.resendOtpText = document.createElement('p');
|
|
925
|
-
this.otpErrorText = document.createElement('p');
|
|
926
908
|
this.otpHint = document.createElement('p');
|
|
927
909
|
this.countdownContainer = document.createElement('div');
|
|
928
910
|
this.resendOtpText.className = 'link-retry-text';
|
|
929
911
|
this.resendOtpText.innerText = OTP_RESEND_COUNT_CONFIG[this.otpResendCount].text;
|
|
930
912
|
this.container.appendChild(this.resendOtpText);
|
|
931
|
-
this.otpErrorText.className = 'link-retry-error';
|
|
932
|
-
this.otpErrorText.style.display = 'none';
|
|
933
|
-
this.container.appendChild(this.otpErrorText);
|
|
934
913
|
this.otpHint.className = 'link-retry-text';
|
|
935
914
|
this.otpHint.innerText = 'Still not getting OTPs?';
|
|
936
915
|
this.otpHint.style.display = 'none';
|
|
@@ -950,12 +929,11 @@ var OtpRetry = /*#__PURE__*/function () {
|
|
|
950
929
|
sendLinkOtp({
|
|
951
930
|
channels: channels || OTP_RESEND_COUNT_CONFIG[this.otpResendCount].channels,
|
|
952
931
|
email: this.transaction.email,
|
|
953
|
-
transaction: this.transaction
|
|
932
|
+
transaction: this.transaction
|
|
954
933
|
}).then(function (response) {
|
|
955
934
|
return _this.onSuccess(response.data.token);
|
|
956
|
-
}).catch(function (
|
|
957
|
-
|
|
958
|
-
_this.otpErrorText.style.display = 'block';
|
|
935
|
+
}).catch(function () {// catching here so a unhandledrejection error is not thrown
|
|
936
|
+
// We don't want to show an error to the user in the event of a failure
|
|
959
937
|
});
|
|
960
938
|
}
|
|
961
939
|
}, {
|
|
@@ -1522,7 +1500,10 @@ function getLinkOtpHelp(linkContainer) {
|
|
|
1522
1500
|
* */
|
|
1523
1501
|
|
|
1524
1502
|
|
|
1525
|
-
function getLinkContent(
|
|
1503
|
+
function getLinkContent(_ref4) {
|
|
1504
|
+
var transaction = _ref4.transaction,
|
|
1505
|
+
closePreCheckoutModal = _ref4.closePreCheckoutModal,
|
|
1506
|
+
inlineInstanceId = _ref4.inlineInstanceId;
|
|
1526
1507
|
var wrapper = document.createElement('div');
|
|
1527
1508
|
wrapper.classList.add('modal-wrapper');
|
|
1528
1509
|
wrapper.innerHTML = wrapper.innerHTML + secureByPaystackWhite + secureByPaystackGrey;
|
|
@@ -1555,13 +1536,14 @@ function getLinkContent(transaction) {
|
|
|
1555
1536
|
transaction: transaction,
|
|
1556
1537
|
token: linkToken
|
|
1557
1538
|
}).then(function (response) {
|
|
1558
|
-
getCheckoutIframe().contentWindow.postMessage({
|
|
1539
|
+
getCheckoutIframe(inlineInstanceId).contentWindow.postMessage({
|
|
1559
1540
|
type: 'link-success',
|
|
1560
1541
|
data: response
|
|
1561
1542
|
}, '*');
|
|
1562
1543
|
otpRetry.unmount();
|
|
1563
1544
|
loader.unmount();
|
|
1564
1545
|
pinInput.unmount();
|
|
1546
|
+
closePreCheckoutModal();
|
|
1565
1547
|
}).catch(function (error) {
|
|
1566
1548
|
loader.hide();
|
|
1567
1549
|
otpRetry.show();
|
|
@@ -1597,7 +1579,7 @@ function getLinkContent(transaction) {
|
|
|
1597
1579
|
return wrapper;
|
|
1598
1580
|
}
|
|
1599
1581
|
|
|
1600
|
-
function mountPreCheckoutModal(id, transaction) {
|
|
1582
|
+
function mountPreCheckoutModal(id, transaction, closePreCheckoutModal) {
|
|
1601
1583
|
var mountedModal = document.querySelector("#pre-checkout-modal-".concat(id));
|
|
1602
1584
|
|
|
1603
1585
|
if (mountedModal) {
|
|
@@ -1616,13 +1598,13 @@ function mountPreCheckoutModal(id, transaction) {
|
|
|
1616
1598
|
content.classList.add('pre-checkout-modal__content');
|
|
1617
1599
|
modal.appendChild(content);
|
|
1618
1600
|
|
|
1619
|
-
var
|
|
1620
|
-
merchantLogo =
|
|
1621
|
-
merchantName =
|
|
1622
|
-
email =
|
|
1623
|
-
amount =
|
|
1624
|
-
currency =
|
|
1625
|
-
label =
|
|
1601
|
+
var _ref5 = transaction || {},
|
|
1602
|
+
merchantLogo = _ref5.merchant_logo,
|
|
1603
|
+
merchantName = _ref5.merchant_name,
|
|
1604
|
+
email = _ref5.email,
|
|
1605
|
+
amount = _ref5.amount,
|
|
1606
|
+
currency = _ref5.currency,
|
|
1607
|
+
label = _ref5.label;
|
|
1626
1608
|
|
|
1627
1609
|
var applePayPaymentInfo = document.createElement('div');
|
|
1628
1610
|
var formattedAmount = new Intl.NumberFormat('en', {
|
|
@@ -1636,7 +1618,11 @@ function mountPreCheckoutModal(id, transaction) {
|
|
|
1636
1618
|
applePayPaymentInfo.innerHTML = "<img class=\"merchant-logo\" src=\"".concat(merchantLogo, "\" alt=\"").concat(merchantName, " Logo\">\n <div class=\"customer-info\">\n <div class=\"customer-email\">").concat(label || email, "</div>\n <div class=\"transaction-amount\">Pay <span class=\"amount\">").concat(formattedAmount, "</span></div>\n </div>");
|
|
1637
1619
|
content.appendChild(applePayPaymentInfo);
|
|
1638
1620
|
content.innerHTML += applePayCloseButton;
|
|
1639
|
-
var wrapper = canPayWithLink(transaction) ? getLinkContent(
|
|
1621
|
+
var wrapper = canPayWithLink(transaction) ? getLinkContent({
|
|
1622
|
+
transaction: transaction,
|
|
1623
|
+
closePreCheckoutModal: closePreCheckoutModal,
|
|
1624
|
+
inlineInstanceId: id
|
|
1625
|
+
}) : getApplePayContent();
|
|
1640
1626
|
content.appendChild(wrapper);
|
|
1641
1627
|
var style = document.createElement('style');
|
|
1642
1628
|
style.textContent = preCheckoutModalCSS;
|
|
@@ -2528,9 +2514,16 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2528
2514
|
inlineInstance = this;
|
|
2529
2515
|
var resumableTransaction = findResumableTransaction(this.transactions, params);
|
|
2530
2516
|
var transaction = resumableTransaction || new InlineTransaction(params);
|
|
2517
|
+
|
|
2518
|
+
var closePreCheckoutModal = function closePreCheckoutModal() {
|
|
2519
|
+
inlineInstance.closePreCheckoutModal();
|
|
2520
|
+
inlineInstance.animateCheckoutIn();
|
|
2521
|
+
};
|
|
2522
|
+
|
|
2531
2523
|
return new Promise(function (resolve, reject) {
|
|
2532
2524
|
transaction.requestInline().then(function (response) {
|
|
2533
|
-
var
|
|
2525
|
+
var linkEnabled = canPayWithLink(response);
|
|
2526
|
+
var shouldLoadPreCheckoutModal = linkEnabled || canUseApplePay(response.channels);
|
|
2534
2527
|
|
|
2535
2528
|
if (!shouldLoadPreCheckoutModal) {
|
|
2536
2529
|
inlineInstance.newTransaction({
|
|
@@ -2541,7 +2534,7 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2541
2534
|
inlineInstance.preloadTransaction({
|
|
2542
2535
|
inlineTransaction: transaction
|
|
2543
2536
|
});
|
|
2544
|
-
inlineInstance.preCheckoutModal = mountPreCheckoutModal(inlineInstance.id, response);
|
|
2537
|
+
inlineInstance.preCheckoutModal = mountPreCheckoutModal(inlineInstance.id, response, closePreCheckoutModal);
|
|
2545
2538
|
inlineInstance.paymentRequestContainer = getPreCheckoutModalPaymentRequestContainer(inlineInstance.preCheckoutModal);
|
|
2546
2539
|
mountPaymentRequestButtons(inlineInstance.paymentRequestContainer, {
|
|
2547
2540
|
channels: response.channels,
|
|
@@ -2556,10 +2549,17 @@ var Inline = /*#__PURE__*/function () {
|
|
|
2556
2549
|
}
|
|
2557
2550
|
}, response.merchant_id).then(function () {
|
|
2558
2551
|
inlineInstance.registerPaymentRequestEventListeners();
|
|
2559
|
-
}).finally(function () {
|
|
2560
2552
|
inlineInstance.registerPreCheckoutModalEventListeners();
|
|
2561
2553
|
animatePreCheckoutModalIn(inlineInstance.preCheckoutModal);
|
|
2562
2554
|
resolve(transaction);
|
|
2555
|
+
}).catch(function () {
|
|
2556
|
+
if (linkEnabled) {
|
|
2557
|
+
inlineInstance.registerPreCheckoutModalEventListeners();
|
|
2558
|
+
animatePreCheckoutModalIn(inlineInstance.preCheckoutModal);
|
|
2559
|
+
resolve(transaction);
|
|
2560
|
+
} else {
|
|
2561
|
+
closePreCheckoutModal();
|
|
2562
|
+
}
|
|
2563
2563
|
});
|
|
2564
2564
|
}
|
|
2565
2565
|
}).catch(function (error) {
|