@paystack/inline-js 2.13.0-dev.7 → 2.13.0-dev.9

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 CHANGED
@@ -401,9 +401,9 @@ var PaystackPop = (function () {
401
401
  padding = _ref2.padding,
402
402
  type = _ref2.type,
403
403
  locale = _ref2.locale;
404
- 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
+ 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");
405
405
  };
406
- var preCheckoutModalCSS = "\n\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: 30px 24px;\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: 450px;\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 }\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 padding-bottom: 0;\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 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: 28px;\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: linear-gradient(180deg, #40ad57 21.43%, #44b669 88.1%), #44b669;\n border: 1px solid #49a861;\n box-sizing: border-box;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n color: #ffffff;\n font-weight: 600;\n font-size: 14px;\n line-height: 14px;\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 #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 }\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
+ 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: 30px 24px;\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: 450px;\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 }\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 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: 28px;\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: linear-gradient(180deg, #40ad57 21.43%, #44b669 88.1%), #44b669;\n border: 1px solid #49a861;\n box-sizing: border-box;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n color: #ffffff;\n font-weight: 600;\n font-size: 14px;\n line-height: 14px;\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 #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";
407
407
 
408
408
  var amountSubunitToBase = function amountSubunitToBase() {
409
409
  var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
@@ -832,6 +832,7 @@ var PaystackPop = (function () {
832
832
  wrapper.classList.add('modal-wrapper');
833
833
  wrapper.innerHTML = applePayMarkLight;
834
834
  var applePayDescription = document.createElement('p');
835
+ applePayDescription.id = 'apple-pay-description';
835
836
  applePayDescription.innerHTML = 'Pay with Apple Pay to complete your purchase without filling a form';
836
837
  wrapper.appendChild(applePayDescription);
837
838
  var paymentButtonContainer = document.createElement('div');
@@ -873,6 +874,14 @@ var PaystackPop = (function () {
873
874
  modal.classList.remove('show');
874
875
  }
875
876
  }
877
+ function showErrorInPreCheckoutModal(modal) {
878
+ if (modal) {
879
+ modal.getElementById('payment-request-button').remove();
880
+ var applePayDescription = modal.getElementById('apple-pay-description');
881
+ applePayDescription.style.color = '#f00707';
882
+ applePayDescription.textContent = 'Error while paying with apple pay. Please retry or use another payment method.';
883
+ }
884
+ }
876
885
 
877
886
  var allParameters = [{
878
887
  value: 'key',
@@ -1262,25 +1271,6 @@ var PaystackPop = (function () {
1262
1271
  return formattedParameters;
1263
1272
  }
1264
1273
 
1265
- function serializeRequestParameters(parameters) {
1266
- var clonedParameters = _objectSpread2({}, parameters);
1267
-
1268
- if (clonedParameters.channels && Array.isArray(clonedParameters.channels)) {
1269
- clonedParameters.channels = JSON.stringify(clonedParameters.channels);
1270
- }
1271
-
1272
- if (clonedParameters.metadata && _typeof(clonedParameters.metadata) === 'object') {
1273
- clonedParameters.metadata = JSON.stringify(clonedParameters.metadata);
1274
- }
1275
-
1276
- if (clonedParameters.split && _typeof(clonedParameters.split) === 'object') {
1277
- clonedParameters.split = JSON.stringify(clonedParameters.split);
1278
- }
1279
-
1280
- var serializedString = serialize(clonedParameters);
1281
- return serializedString;
1282
- }
1283
-
1284
1274
  /* eslint-env browser */
1285
1275
  var iOSDevices = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'];
1286
1276
  /**
@@ -1455,17 +1445,25 @@ var PaystackPop = (function () {
1455
1445
  var TransactionApi = {
1456
1446
  requestInline: function requestInline() {
1457
1447
  var inlineTransactionInstance = this;
1458
- var url = "".concat(config.paystackApiUrl, "checkout/request_inline?").concat(serializeRequestParameters(this.urlParameters));
1448
+ var request;
1459
1449
 
1460
1450
  if (this.accessCode) {
1461
- url = "".concat(config.paystackApiUrl, "transaction/verify_access_code/").concat(this.accessCode);
1451
+ request = fetch(new URL("transaction/verify_access_code/".concat(this.accessCode), config.paystackApiUrl).toString(), {
1452
+ headers: {
1453
+ 'Content-Type': 'application/json'
1454
+ }
1455
+ });
1456
+ } else {
1457
+ request = fetch(new URL('/checkout/request_inline', config.paystackApiUrl).toString(), {
1458
+ method: 'POST',
1459
+ body: JSON.stringify(this.urlParameters),
1460
+ headers: {
1461
+ 'Content-Type': 'application/json'
1462
+ }
1463
+ });
1462
1464
  }
1463
1465
 
1464
- return fetch(url, {
1465
- headers: {
1466
- 'Content-Type': 'application/json'
1467
- }
1468
- }).then(function (res) {
1466
+ return request.then(function (res) {
1469
1467
  return res.json();
1470
1468
  }).then(function (res) {
1471
1469
  if (res.status === false) {
@@ -1827,11 +1825,15 @@ var PaystackPop = (function () {
1827
1825
  }
1828
1826
  }, {
1829
1827
  key: "closePreCheckoutModal",
1830
- value: function closePreCheckoutModal() {
1828
+ value: function closePreCheckoutModal(error) {
1831
1829
  if (this.preCheckoutModal) {
1832
- hidePreCheckoutModal(this.preCheckoutModal);
1833
- this.preCheckoutModal.remove();
1834
- this.preCheckoutModal = null;
1830
+ if (!error) {
1831
+ hidePreCheckoutModal(this.preCheckoutModal);
1832
+ this.preCheckoutModal.remove();
1833
+ this.preCheckoutModal = null;
1834
+ } else {
1835
+ showErrorInPreCheckoutModal(this.preCheckoutModal);
1836
+ }
1835
1837
  }
1836
1838
  }
1837
1839
  }, {
@@ -2093,7 +2095,10 @@ var PaystackPop = (function () {
2093
2095
  });
2094
2096
  }
2095
2097
 
2096
- inlineInstance.closePreCheckoutModal();
2098
+ inlineInstance.closePreCheckoutModal({
2099
+ channel: 'apple_pay',
2100
+ message: response && response.message || 'Transaction attempt failed'
2101
+ });
2097
2102
  }).catch(function (error) {
2098
2103
  applePaySession.completePayment(applePaySession.STATUS_FAILURE);
2099
2104
  transaction.onSetupError(error);
@@ -2103,7 +2108,10 @@ var PaystackPop = (function () {
2103
2108
  message: error && error.message || 'Error occurred'
2104
2109
  });
2105
2110
 
2106
- inlineInstance.closePreCheckoutModal();
2111
+ inlineInstance.closePreCheckoutModal({
2112
+ channel: 'apple_pay',
2113
+ message: error && error.message || 'Error occurred'
2114
+ });
2107
2115
  });
2108
2116
  };
2109
2117
 
package/es/inline.js CHANGED
@@ -398,9 +398,9 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
398
398
  padding = _ref2.padding,
399
399
  type = _ref2.type,
400
400
  locale = _ref2.locale;
401
- 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");
401
+ 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");
402
402
  };
403
- var preCheckoutModalCSS = "\n\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: 30px 24px;\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: 450px;\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 }\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 padding-bottom: 0;\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 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: 28px;\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: linear-gradient(180deg, #40ad57 21.43%, #44b669 88.1%), #44b669;\n border: 1px solid #49a861;\n box-sizing: border-box;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n color: #ffffff;\n font-weight: 600;\n font-size: 14px;\n line-height: 14px;\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 #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 }\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";
403
+ 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: 30px 24px;\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: 450px;\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 }\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 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: 28px;\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: linear-gradient(180deg, #40ad57 21.43%, #44b669 88.1%), #44b669;\n border: 1px solid #49a861;\n box-sizing: border-box;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n color: #ffffff;\n font-weight: 600;\n font-size: 14px;\n line-height: 14px;\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 #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";
404
404
 
405
405
  var amountSubunitToBase = function amountSubunitToBase() {
406
406
  var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
@@ -829,6 +829,7 @@ function mountPreCheckoutModal(id, transaction) {
829
829
  wrapper.classList.add('modal-wrapper');
830
830
  wrapper.innerHTML = applePayMarkLight;
831
831
  var applePayDescription = document.createElement('p');
832
+ applePayDescription.id = 'apple-pay-description';
832
833
  applePayDescription.innerHTML = 'Pay with Apple Pay to complete your purchase without filling a form';
833
834
  wrapper.appendChild(applePayDescription);
834
835
  var paymentButtonContainer = document.createElement('div');
@@ -870,6 +871,14 @@ function hidePreCheckoutModal(modal) {
870
871
  modal.classList.remove('show');
871
872
  }
872
873
  }
874
+ function showErrorInPreCheckoutModal(modal) {
875
+ if (modal) {
876
+ modal.getElementById('payment-request-button').remove();
877
+ var applePayDescription = modal.getElementById('apple-pay-description');
878
+ applePayDescription.style.color = '#f00707';
879
+ applePayDescription.textContent = 'Error while paying with apple pay. Please retry or use another payment method.';
880
+ }
881
+ }
873
882
 
874
883
  var allParameters = [{
875
884
  value: 'key',
@@ -1259,25 +1268,6 @@ function buildQuery(parameters) {
1259
1268
  return formattedParameters;
1260
1269
  }
1261
1270
 
1262
- function serializeRequestParameters(parameters) {
1263
- var clonedParameters = _objectSpread2({}, parameters);
1264
-
1265
- if (clonedParameters.channels && Array.isArray(clonedParameters.channels)) {
1266
- clonedParameters.channels = JSON.stringify(clonedParameters.channels);
1267
- }
1268
-
1269
- if (clonedParameters.metadata && _typeof(clonedParameters.metadata) === 'object') {
1270
- clonedParameters.metadata = JSON.stringify(clonedParameters.metadata);
1271
- }
1272
-
1273
- if (clonedParameters.split && _typeof(clonedParameters.split) === 'object') {
1274
- clonedParameters.split = JSON.stringify(clonedParameters.split);
1275
- }
1276
-
1277
- var serializedString = serialize(clonedParameters);
1278
- return serializedString;
1279
- }
1280
-
1281
1271
  /* eslint-env browser */
1282
1272
  var iOSDevices = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'];
1283
1273
  /**
@@ -1452,17 +1442,25 @@ var AnalyticsFunctions = {
1452
1442
  var TransactionApi = {
1453
1443
  requestInline: function requestInline() {
1454
1444
  var inlineTransactionInstance = this;
1455
- var url = "".concat(config.paystackApiUrl, "checkout/request_inline?").concat(serializeRequestParameters(this.urlParameters));
1445
+ var request;
1456
1446
 
1457
1447
  if (this.accessCode) {
1458
- url = "".concat(config.paystackApiUrl, "transaction/verify_access_code/").concat(this.accessCode);
1448
+ request = fetch(new URL("transaction/verify_access_code/".concat(this.accessCode), config.paystackApiUrl).toString(), {
1449
+ headers: {
1450
+ 'Content-Type': 'application/json'
1451
+ }
1452
+ });
1453
+ } else {
1454
+ request = fetch(new URL('/checkout/request_inline', config.paystackApiUrl).toString(), {
1455
+ method: 'POST',
1456
+ body: JSON.stringify(this.urlParameters),
1457
+ headers: {
1458
+ 'Content-Type': 'application/json'
1459
+ }
1460
+ });
1459
1461
  }
1460
1462
 
1461
- return fetch(url, {
1462
- headers: {
1463
- 'Content-Type': 'application/json'
1464
- }
1465
- }).then(function (res) {
1463
+ return request.then(function (res) {
1466
1464
  return res.json();
1467
1465
  }).then(function (res) {
1468
1466
  if (res.status === false) {
@@ -1824,11 +1822,15 @@ var Inline = /*#__PURE__*/function () {
1824
1822
  }
1825
1823
  }, {
1826
1824
  key: "closePreCheckoutModal",
1827
- value: function closePreCheckoutModal() {
1825
+ value: function closePreCheckoutModal(error) {
1828
1826
  if (this.preCheckoutModal) {
1829
- hidePreCheckoutModal(this.preCheckoutModal);
1830
- this.preCheckoutModal.remove();
1831
- this.preCheckoutModal = null;
1827
+ if (!error) {
1828
+ hidePreCheckoutModal(this.preCheckoutModal);
1829
+ this.preCheckoutModal.remove();
1830
+ this.preCheckoutModal = null;
1831
+ } else {
1832
+ showErrorInPreCheckoutModal(this.preCheckoutModal);
1833
+ }
1832
1834
  }
1833
1835
  }
1834
1836
  }, {
@@ -2090,7 +2092,10 @@ var Inline = /*#__PURE__*/function () {
2090
2092
  });
2091
2093
  }
2092
2094
 
2093
- inlineInstance.closePreCheckoutModal();
2095
+ inlineInstance.closePreCheckoutModal({
2096
+ channel: 'apple_pay',
2097
+ message: response && response.message || 'Transaction attempt failed'
2098
+ });
2094
2099
  }).catch(function (error) {
2095
2100
  applePaySession.completePayment(applePaySession.STATUS_FAILURE);
2096
2101
  transaction.onSetupError(error);
@@ -2100,7 +2105,10 @@ var Inline = /*#__PURE__*/function () {
2100
2105
  message: error && error.message || 'Error occurred'
2101
2106
  });
2102
2107
 
2103
- inlineInstance.closePreCheckoutModal();
2108
+ inlineInstance.closePreCheckoutModal({
2109
+ channel: 'apple_pay',
2110
+ message: error && error.message || 'Error occurred'
2111
+ });
2104
2112
  });
2105
2113
  };
2106
2114
 
package/lib/inline.js CHANGED
@@ -400,9 +400,9 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
400
400
  padding = _ref2.padding,
401
401
  type = _ref2.type,
402
402
  locale = _ref2.locale;
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");
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\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: 30px 24px;\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: 450px;\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 }\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 padding-bottom: 0;\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 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: 28px;\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: linear-gradient(180deg, #40ad57 21.43%, #44b669 88.1%), #44b669;\n border: 1px solid #49a861;\n box-sizing: border-box;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n color: #ffffff;\n font-weight: 600;\n font-size: 14px;\n line-height: 14px;\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 #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 }\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";
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: 30px 24px;\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: 450px;\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 }\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 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: 28px;\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: linear-gradient(180deg, #40ad57 21.43%, #44b669 88.1%), #44b669;\n border: 1px solid #49a861;\n box-sizing: border-box;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.1);\n border-radius: 5px;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n color: #ffffff;\n font-weight: 600;\n font-size: 14px;\n line-height: 14px;\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 #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
 
407
407
  var amountSubunitToBase = function amountSubunitToBase() {
408
408
  var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
@@ -831,6 +831,7 @@ function mountPreCheckoutModal(id, transaction) {
831
831
  wrapper.classList.add('modal-wrapper');
832
832
  wrapper.innerHTML = applePayMarkLight;
833
833
  var applePayDescription = document.createElement('p');
834
+ applePayDescription.id = 'apple-pay-description';
834
835
  applePayDescription.innerHTML = 'Pay with Apple Pay to complete your purchase without filling a form';
835
836
  wrapper.appendChild(applePayDescription);
836
837
  var paymentButtonContainer = document.createElement('div');
@@ -872,6 +873,14 @@ function hidePreCheckoutModal(modal) {
872
873
  modal.classList.remove('show');
873
874
  }
874
875
  }
876
+ function showErrorInPreCheckoutModal(modal) {
877
+ if (modal) {
878
+ modal.getElementById('payment-request-button').remove();
879
+ var applePayDescription = modal.getElementById('apple-pay-description');
880
+ applePayDescription.style.color = '#f00707';
881
+ applePayDescription.textContent = 'Error while paying with apple pay. Please retry or use another payment method.';
882
+ }
883
+ }
875
884
 
876
885
  var allParameters = [{
877
886
  value: 'key',
@@ -1261,25 +1270,6 @@ function buildQuery(parameters) {
1261
1270
  return formattedParameters;
1262
1271
  }
1263
1272
 
1264
- function serializeRequestParameters(parameters) {
1265
- var clonedParameters = _objectSpread2({}, parameters);
1266
-
1267
- if (clonedParameters.channels && Array.isArray(clonedParameters.channels)) {
1268
- clonedParameters.channels = JSON.stringify(clonedParameters.channels);
1269
- }
1270
-
1271
- if (clonedParameters.metadata && _typeof(clonedParameters.metadata) === 'object') {
1272
- clonedParameters.metadata = JSON.stringify(clonedParameters.metadata);
1273
- }
1274
-
1275
- if (clonedParameters.split && _typeof(clonedParameters.split) === 'object') {
1276
- clonedParameters.split = JSON.stringify(clonedParameters.split);
1277
- }
1278
-
1279
- var serializedString = serialize(clonedParameters);
1280
- return serializedString;
1281
- }
1282
-
1283
1273
  /* eslint-env browser */
1284
1274
  var iOSDevices = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'];
1285
1275
  /**
@@ -1454,17 +1444,25 @@ var AnalyticsFunctions = {
1454
1444
  var TransactionApi = {
1455
1445
  requestInline: function requestInline() {
1456
1446
  var inlineTransactionInstance = this;
1457
- var url = "".concat(config.paystackApiUrl, "checkout/request_inline?").concat(serializeRequestParameters(this.urlParameters));
1447
+ var request;
1458
1448
 
1459
1449
  if (this.accessCode) {
1460
- url = "".concat(config.paystackApiUrl, "transaction/verify_access_code/").concat(this.accessCode);
1450
+ request = fetch(new URL("transaction/verify_access_code/".concat(this.accessCode), config.paystackApiUrl).toString(), {
1451
+ headers: {
1452
+ 'Content-Type': 'application/json'
1453
+ }
1454
+ });
1455
+ } else {
1456
+ request = fetch(new URL('/checkout/request_inline', config.paystackApiUrl).toString(), {
1457
+ method: 'POST',
1458
+ body: JSON.stringify(this.urlParameters),
1459
+ headers: {
1460
+ 'Content-Type': 'application/json'
1461
+ }
1462
+ });
1461
1463
  }
1462
1464
 
1463
- return fetch(url, {
1464
- headers: {
1465
- 'Content-Type': 'application/json'
1466
- }
1467
- }).then(function (res) {
1465
+ return request.then(function (res) {
1468
1466
  return res.json();
1469
1467
  }).then(function (res) {
1470
1468
  if (res.status === false) {
@@ -1826,11 +1824,15 @@ var Inline = /*#__PURE__*/function () {
1826
1824
  }
1827
1825
  }, {
1828
1826
  key: "closePreCheckoutModal",
1829
- value: function closePreCheckoutModal() {
1827
+ value: function closePreCheckoutModal(error) {
1830
1828
  if (this.preCheckoutModal) {
1831
- hidePreCheckoutModal(this.preCheckoutModal);
1832
- this.preCheckoutModal.remove();
1833
- this.preCheckoutModal = null;
1829
+ if (!error) {
1830
+ hidePreCheckoutModal(this.preCheckoutModal);
1831
+ this.preCheckoutModal.remove();
1832
+ this.preCheckoutModal = null;
1833
+ } else {
1834
+ showErrorInPreCheckoutModal(this.preCheckoutModal);
1835
+ }
1834
1836
  }
1835
1837
  }
1836
1838
  }, {
@@ -2092,7 +2094,10 @@ var Inline = /*#__PURE__*/function () {
2092
2094
  });
2093
2095
  }
2094
2096
 
2095
- inlineInstance.closePreCheckoutModal();
2097
+ inlineInstance.closePreCheckoutModal({
2098
+ channel: 'apple_pay',
2099
+ message: response && response.message || 'Transaction attempt failed'
2100
+ });
2096
2101
  }).catch(function (error) {
2097
2102
  applePaySession.completePayment(applePaySession.STATUS_FAILURE);
2098
2103
  transaction.onSetupError(error);
@@ -2102,7 +2107,10 @@ var Inline = /*#__PURE__*/function () {
2102
2107
  message: error && error.message || 'Error occurred'
2103
2108
  });
2104
2109
 
2105
- inlineInstance.closePreCheckoutModal();
2110
+ inlineInstance.closePreCheckoutModal({
2111
+ channel: 'apple_pay',
2112
+ message: error && error.message || 'Error occurred'
2113
+ });
2106
2114
  });
2107
2115
  };
2108
2116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/inline-js",
3
- "version": "2.13.0-dev.7",
3
+ "version": "2.13.0-dev.9",
4
4
  "description": "Client-side library to load the Paystack checkout form",
5
5
  "main": "lib/inline.js",
6
6
  "module": "es/inline.js",