@paystack/inline-js 2.22.8-dev.1 → 2.23.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/dist/inline.js +233 -180
  2. package/es/inline.js +233 -180
  3. package/lib/inline.js +233 -180
  4. package/package.json +1 -1
package/lib/inline.js CHANGED
@@ -16,6 +16,37 @@ function _arrayWithoutHoles(r) {
16
16
  if (Array.isArray(r)) return _arrayLikeToArray(r);
17
17
  }
18
18
 
19
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
20
+ try {
21
+ var i = n[a](c),
22
+ u = i.value;
23
+ } catch (n) {
24
+ return void e(n);
25
+ }
26
+
27
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
28
+ }
29
+
30
+ function _asyncToGenerator(n) {
31
+ return function () {
32
+ var t = this,
33
+ e = arguments;
34
+ return new Promise(function (r, o) {
35
+ var a = n.apply(t, e);
36
+
37
+ function _next(n) {
38
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
39
+ }
40
+
41
+ function _throw(n) {
42
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
43
+ }
44
+
45
+ _next(void 0);
46
+ });
47
+ };
48
+ }
49
+
19
50
  function _classCallCheck(a, n) {
20
51
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
21
52
  }
@@ -403,116 +434,6 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
403
434
  };
404
435
  var preCheckoutModalCSS = "\n .pre-checkout-modal {\n display: none;\n position: fixed;\n z-index: 1;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100%;\n overflow: auto;\n background-color: rgba(0, 0, 0, 0.75);\n transition: all 0.2s ease;\n }\n\n .pre-checkout-modal.show {\n display: block;\n }\n\n .pre-checkout-modal__content {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n background-color: #fefefe;\n padding: 20px;\n padding-bottom: max(30px, env(safe-area-inset-bottom));\n width: 100%;\n border-radius: 6px 6px 0 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n max-width: 350px;\n\n box-sizing: border-box;\n transform: translateY(238px);\n transition: transform 0.3s cubic-bezier(.16,.81,.32,1);\n }\n\n .modal-wrapper {\n width: 100%;\n }\n\n .payment-info {\n position: relative;\n padding-bottom: 15px;\n border-bottom: solid 1px whitesmoke;\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n width: 100%;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n }\n\n .customer-email {\n color: #737373;\n font-size: 13px;\n line-height: 16px;\n }\n\n .customer-info {\n flex: 1;\n text-align: right;\n }\n\n .merchant-logo {\n display: flex;\n align-items: center;\n height: 30px;\n }\n .transaction-amount {\n margin-top: 5px;\n font-size: 13px;\n line-height: 16px;\n color: #737373;\n }\n\n .amount {\n color: #29b263;\n font-weight: bold;\n }\n\n @media only screen and (min-width: 500px) {\n .pre-checkout-modal__content {\n bottom: 0;\n top: 0;\n margin: auto;\n border-radius: 6px;\n height: fit-content;\n }\n }\n\n .pre-checkout-modal__content.show {\n transform: translateY(0);\n margin: 0 auto;\n margin-top: 100px;\n }\n\n .pre-checkout-modal__content > * {\n margin-top: 0;\n margin-bottom: 40px;\n }\n .pre-checkout-modal__content > *:last-child {\n margin-bottom: 0;\n }\n\n .pre-checkout-modal__content svg {\n margin: auto;\n width: 100%;\n }\n\n #inline-button-wordmark--white {\n position: absolute;\n bottom: -50px;\n margin: auto;\n left: 0;\n right: 0;\n width: fit-content;\n }\n\n #inline-button-wordmark--grey {\n display: none;\n }\n\n .pre-checkout-modal__content #apple-pay-mark--light {\n margin-bottom: 16px;\n }\n\n .pre-checkout-modal p {\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n color: #4E4E4E;\n line-height: 140%;\n font-size: 14px;\n font-weight: 500;\n margin: 0;\n padding: 0 20px;\n text-align: center;\n letter-spacing: -0.3px;\n }\n\n .pre-checkout-modal button {\n height: 42px;\n width: 100%;\n \n box-sizing: border-box;\n border-radius: 3px;\n font-size: 14px;\n line-height: 24px;\n cursor: pointer;\n -webkit-text-size-adjust: 100%;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n }\n\n .pre-checkout-modal .open-paystack-pop-button {\n background: #FAFAFA;\n border: 1px solid #F2F3F3;\n color: #4E4E4E;\n font-weight: 500;\n }\n\n .pre-checkout-modal .open-paystack-pop-button:hover, \n .pre-checkout-modal .open-paystack-pop-button:active, \n .pre-checkout-modal .open-paystack-pop-button:focus {\n background: #F2F3F3;\n }\n\n .pre-checkout-modal .pay-with-vault-button {\n font-weight: 700;\n background: #44b669;\n background: linear-gradient(to bottom, #44b669 0%, #40ad57 100%);\n border: solid 1px #49a861;\n text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n outline: none;\n color: white;\n transition: all 300ms;\n }\n\n .pre-checkout-modal .vault-instruction {\n color: #2f3d4d;\n font-size: 14px;\n letter-spacing: normal;\n line-height: 1.4;\n margin: 0 auto 24px;\n padding: 0;\n }\n .vault-logo-container {\n width: 74px;\n height: 20px;\n margin: 0 auto 24px\n }\n .vault-logo-container img {\n height: 100%;\n width: 100%;\n border-radius: 8px;\n }\n .vault-divider {\n margin-bottom: 16px;\n margin-top: 24px;\n position: relative;\n }\n .vault-divider__container {\n align-items: center;\n bottom: 0;\n display: flex;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n }\n .vault-divider__line {\n border: 1px dashed #ccced0;\n width: 100%;\n }\n .vault-divider__text-container {\n display: flex;\n justify-content: center;\n position: relative;\n }\n .vault-divider__text {\n background-color: #fff;\n color: #999da1;\n font-size: 14px;\n font-weight: 500;\n letter-spacing: -.3px;\n line-height: 19.6px;\n margin-bottom: 2px;\n padding: 0 8px;\n }\n\n #payment-request-button {\n width: 100%;\n height: fit-content;\n margin: 24px 0 16px 0;\n }\n\n #paystackpop-button {\n padding: 0 16px;\n }\n\n #apple-pay-close-button {\n position: absolute;\n text-align: center;\n top: 0;\n right: -26px;\n height: 16px;\n width: 16px;\n padding: 0;\n display: inline-block;\n z-index: 3;\n border-radius: 50%;\n background: transparent;\n transition: all 300ms;\n outline: none;\n cursor: pointer;\n border: none;\n }\n\n #apple-pay-close-button svg {\n width: initial;\n }\n \n #apple-pay-close-button:hover {\n background-color: #e22b28;\n }\n\n @media only screen and (max-width: 500px) {\n .pre-checkout-modal__content {\n max-width: 500px;\n border-radius: 0;\n padding-bottom: 0;\n }\n\n .modal-wrapper {\n padding: 0;\n }\n\n .vault-logo-container {\n width: 74px;\n height: 20px;\n }\n\n #inline-button-wordmark--white {\n display: none\n }\n \n #inline-button-wordmark--grey {\n display: block;\n width: 100%;\n margin: 16px 0;\n height: 13px;\n }\n\n #apple-pay-close-button {\n display: none;\n }\n }\n";
405
436
 
406
- var amountSubunitToBase = function amountSubunitToBase() {
407
- var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
408
- return Number(parseFloat(amount / 100).toFixed(2));
409
- };
410
-
411
- var requestConfig = {
412
- headers: {
413
- accept: 'application/json, text/plain, */*',
414
- 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
415
- 'content-type': 'application/x-www-form-urlencoded',
416
- 'sec-ch-ua-mobile': '?0',
417
- 'sec-fetch-dest': 'empty',
418
- 'sec-fetch-mode': 'cors',
419
- 'sec-fetch-site': 'cross-site'
420
- },
421
- referrerPolicy: 'no-referrer-when-downgrade',
422
- method: 'POST',
423
- mode: 'cors',
424
- credentials: 'omit'
425
- };
426
- function createFormBody(params) {
427
- var formBody = Object.keys(params).reduce(function (formBodyArray, key) {
428
- var encodedKey = encodeURIComponent(key);
429
- var encodedValue = encodeURIComponent(params[key]);
430
- var encodedFormBody = "".concat(encodedKey, "=").concat(encodedValue);
431
- return [].concat(_toConsumableArray(formBodyArray), [encodedFormBody]);
432
- }, []);
433
- return formBody.join('&');
434
- }
435
-
436
- var formatIntervalString = function formatIntervalString(interval) {
437
- var plans = {
438
- biannually: 'BIANNUAL PLAN',
439
- annually: 'ANNUAL PLAN'
440
- };
441
- return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
442
- };
443
-
444
- var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
445
- var currency = _ref.currency,
446
- amount = _ref.amount,
447
- merchantName = _ref.merchantName,
448
- interval = _ref.interval;
449
- return _objectSpread2({
450
- countryCode: 'NG',
451
- currencyCode: currency,
452
- merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
453
- supportedNetworks: ['visa', 'masterCard'],
454
- requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
455
- total: {
456
- label: "".concat(merchantName, " - Paystack"),
457
- type: 'final',
458
- amount: String(amountSubunitToBase(amount))
459
- }
460
- }, typeof interval === 'string' && interval.trim() !== '' && {
461
- lineItems: [{
462
- label: formatIntervalString(interval),
463
- amount: String(amountSubunitToBase(amount))
464
- }]
465
- });
466
- };
467
- var validateApplePaySession = function validateApplePaySession(_ref2) {
468
- var transactionId = _ref2.transactionId,
469
- validationURL = _ref2.validationURL,
470
- merchantName = _ref2.merchantName,
471
- _ref2$domainName = _ref2.domainName,
472
- domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
473
- var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
474
- var params = {
475
- transaction: transactionId,
476
- sessionUrl: validationURL,
477
- displayName: merchantName,
478
- domainName: domainName
479
- };
480
- var formBody = createFormBody(params);
481
- var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
482
- body: formBody
483
- })).then(function (response) {
484
- return response.json();
485
- });
486
- return validateSession;
487
- };
488
- var chargeApplePay = function chargeApplePay(_ref3) {
489
- var transactionId = _ref3.transactionId,
490
- payment = _ref3.payment;
491
- var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
492
- var params = {
493
- transaction: transactionId,
494
- paymentObject: JSON.stringify(payment)
495
- };
496
- var formBody = createFormBody(params);
497
- var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
498
- body: formBody
499
- })).then(function (response) {
500
- return response.json();
501
- });
502
- return charge;
503
- };
504
- var deviceSupportsApplePay = function deviceSupportsApplePay() {
505
- try {
506
- return window.location && window.location.protocol === 'https:' && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
507
- } catch (error) {
508
- return false;
509
- }
510
- };
511
- var canUseApplePay = function canUseApplePay() {
512
- var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
513
- return deviceSupportsApplePay() && channels.includes('apple_pay');
514
- };
515
-
516
437
  /* eslint-env browser */
517
438
  function findHighestZIndex() {
518
439
  var highestZIndex = 0;
@@ -528,8 +449,8 @@ function findHighestZIndex() {
528
449
  return highestZIndex;
529
450
  }
530
451
 
531
- var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js';
532
- var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-z/6BVHCcSypLSykOVpaT1PQWHOOgU45uOOlMkgi/bElX4yFqmChNMb7qiv80wFav';
452
+ var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.2.0/apple-pay-sdk.js';
453
+ var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-hopRfycfKWs+MFyVuNk99Lb7EEhZdyoatMFJRsBk8bXoxaBXkQ+LCPm98iPgFw3a';
533
454
 
534
455
  function createIframe(id) {
535
456
  var iframe = document.createElement('iframe');
@@ -763,54 +684,87 @@ function mountPaymentRequestButtons(container, _ref4, merchantId) {
763
684
  };
764
685
  return new Promise(function (resolve, reject) {
765
686
  if (container) {
766
- if (canUseApplePay(channels)) {
767
- if (getApplePayButton(container)) {
768
- mountedElements.applePay = true;
769
- resolve(mountedElements);
770
- return;
771
- }
687
+ if (!channels.includes('apple_pay')) {
688
+ reject('No wallet payment method is available on this device');
689
+ return;
690
+ }
772
691
 
773
- loadScript(APPLE_PAY_SDK_SOURCE, {
774
- container: container,
775
- integrity: APPLE_PAY_SDK_INTEGRITY_HASH
776
- }).then(function () {
777
- /**
778
- * We are currently attempting to deprecate the below code to check webpackjsonp is an array.
779
- * To do this safely, we are limiting this change to single test integration before rolling
780
- * out more widely
781
- */
782
- var TEST_INTEGRATION = 1077497;
783
- /**
784
- * The Apple Pay SDK expects `window.webpackJsonp` to be array-like
785
- * but we have seen instances where that is not the case, causing the SDK to throw errors
786
- * so in this scenario, we opt out of using the SDK
787
- */
788
-
789
- if (merchantId && merchantId !== TEST_INTEGRATION) {
790
- if (window && !Array.isArray(window.webpackJsonp)) {
791
- throw new Error("Incorrect data type for 'webpackJsonp', expected array, got ".concat(_typeof(window.webpackJsonp), ". Switching to fallback apple pay button"));
692
+ if (getApplePayButton(container)) {
693
+ mountedElements.applePay = true;
694
+ resolve(mountedElements);
695
+ return;
696
+ }
697
+
698
+ loadScript(APPLE_PAY_SDK_SOURCE, {
699
+ container: container,
700
+ integrity: APPLE_PAY_SDK_INTEGRITY_HASH
701
+ }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
702
+ var _window$ApplePaySessi, capabilities, unsupported, _window$ApplePaySessi2, _window$ApplePaySessi3;
703
+
704
+ return regeneratorRuntime.wrap(function _callee$(_context) {
705
+ while (1) {
706
+ switch (_context.prev = _context.next) {
707
+ case 0:
708
+ _context.prev = 0;
709
+ _context.next = 3;
710
+ return (_window$ApplePaySessi = window.ApplePaySession) === null || _window$ApplePaySessi === void 0 ? void 0 : _window$ApplePaySessi.applePayCapabilities();
711
+
712
+ case 3:
713
+ capabilities = _context.sent;
714
+ unsupported = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
715
+
716
+ if (!unsupported) {
717
+ _context.next = 7;
718
+ break;
719
+ }
720
+
721
+ throw new Error('Apple Pay is not supported on this device');
722
+
723
+ case 7:
724
+ _context.next = 15;
725
+ break;
726
+
727
+ case 9:
728
+ _context.prev = 9;
729
+ _context.t0 = _context["catch"](0);
730
+
731
+ if (!(_context.t0.message === 'Apple Pay is not supported on this device')) {
732
+ _context.next = 13;
733
+ break;
734
+ }
735
+
736
+ throw _context.t0;
737
+
738
+ case 13:
739
+ if ((_window$ApplePaySessi2 = window.ApplePaySession) !== null && _window$ApplePaySessi2 !== void 0 && (_window$ApplePaySessi3 = _window$ApplePaySessi2.canMakePayments) !== null && _window$ApplePaySessi3 !== void 0 && _window$ApplePaySessi3.call(_window$ApplePaySessi2)) {
740
+ _context.next = 15;
741
+ break;
742
+ }
743
+
744
+ throw new Error('Apple Pay is not supported on this device');
745
+
746
+ case 15:
747
+ mountApplePayButton(container, {
748
+ styles: parseApplePayCustomStyles(styles.applePay),
749
+ theme: styles.theme
750
+ });
751
+ mountedElements.applePay = true;
752
+ resolve(mountedElements);
753
+
754
+ case 18:
755
+ case "end":
756
+ return _context.stop();
792
757
  }
793
758
  }
794
-
795
- mountApplePayButton(container, {
796
- styles: parseApplePayCustomStyles(styles.applePay),
797
- theme: styles.theme
798
- });
799
- mountedElements.applePay = true;
800
- resolve(mountedElements);
801
- }).catch(function () {
802
- // if the loading of the apple pay SDK fails, that means using the apple-pay-button web component won't work
803
- // so custom styled apple pay button is mounted instead. See documentation here https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_css
804
- mountApplePayFallbackButton(container, {
805
- styles: parseApplePayCustomStyles(styles.applePay),
806
- theme: styles.theme
807
- });
808
- mountedElements.applePay = true;
809
- resolve(mountedElements);
759
+ }, _callee, null, [[0, 9]]);
760
+ }))).catch(function () {
761
+ mountApplePayFallbackButton(container, {
762
+ styles: parseApplePayCustomStyles(styles.applePay),
763
+ theme: styles.theme
810
764
  });
811
- } else {
812
- reject('No wallet payment method is available on this device');
813
- }
765
+ mountedElements.applePay = true;
766
+ resolve(mountedElements);
767
+ });
814
768
  } else {
815
769
  reject('Container to mount elements was not provided');
816
770
  }
@@ -894,8 +848,8 @@ function vaultPreCheckoutModalView(container) {
894
848
  }
895
849
  }
896
850
 
897
- function defaultPreCheckoutModalView(container, _ref5) {
898
- var hasOtherPaymentMethods = _ref5.hasOtherPaymentMethods;
851
+ function defaultPreCheckoutModalView(container, _ref6) {
852
+ var hasOtherPaymentMethods = _ref6.hasOtherPaymentMethods;
899
853
  var applePayIcon = document.createElement('div');
900
854
  applePayIcon.innerHTML = applePayMarkLight;
901
855
  container.appendChild(applePayIcon);
@@ -938,14 +892,14 @@ function mountPreCheckoutModal(id, transaction) {
938
892
  content.classList.add('pre-checkout-modal__content');
939
893
  modal.appendChild(content);
940
894
 
941
- var _ref6 = transaction || {},
942
- merchantLogo = _ref6.merchant_logo,
943
- merchantName = _ref6.merchant_name,
944
- email = _ref6.email,
945
- amount = _ref6.amount,
946
- currency = _ref6.currency,
947
- label = _ref6.label,
948
- channels = _ref6.channels;
895
+ var _ref7 = transaction || {},
896
+ merchantLogo = _ref7.merchant_logo,
897
+ merchantName = _ref7.merchant_name,
898
+ email = _ref7.email,
899
+ amount = _ref7.amount,
900
+ currency = _ref7.currency,
901
+ label = _ref7.label,
902
+ channels = _ref7.channels;
949
903
 
950
904
  var formattedAmount = new Intl.NumberFormat('en', {
951
905
  style: 'currency',
@@ -1442,17 +1396,6 @@ var isIOS = function isIOS() {
1442
1396
  return iOSDevices.includes(devicePlatform) || // iPAD os safari detection. iPad OS uses the same version of safari as Mac OS
1443
1397
  userAgent.includes('Mac') && 'ontouchend' in document;
1444
1398
  };
1445
- var isAppleOS = function isAppleOS() {
1446
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1447
- platform = _ref2.platform,
1448
- _ref2$userAgent = _ref2.userAgent,
1449
- userAgent = _ref2$userAgent === void 0 ? window && window.navigator && window.navigator.userAgent : _ref2$userAgent;
1450
-
1451
- var devicePlatform = platform || DEVICE_PLATFORM;
1452
- var isSafari = userAgent && !!userAgent.match(/Version\/[\d.]+.*Safari/);
1453
- var isMAC = devicePlatform && /(Mac)/i.test(devicePlatform);
1454
- return isIOS() || isMAC && isSafari;
1455
- };
1456
1399
 
1457
1400
  /* eslint-env browser */
1458
1401
  var AnalyticsAPI = {
@@ -1769,6 +1712,116 @@ var InlineTransaction = /*#__PURE__*/function () {
1769
1712
  return InlineTransaction;
1770
1713
  }();
1771
1714
 
1715
+ var amountSubunitToBase = function amountSubunitToBase() {
1716
+ var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1717
+ return Number(parseFloat(amount / 100).toFixed(2));
1718
+ };
1719
+
1720
+ var requestConfig = {
1721
+ headers: {
1722
+ accept: 'application/json, text/plain, */*',
1723
+ 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
1724
+ 'content-type': 'application/x-www-form-urlencoded',
1725
+ 'sec-ch-ua-mobile': '?0',
1726
+ 'sec-fetch-dest': 'empty',
1727
+ 'sec-fetch-mode': 'cors',
1728
+ 'sec-fetch-site': 'cross-site'
1729
+ },
1730
+ referrerPolicy: 'no-referrer-when-downgrade',
1731
+ method: 'POST',
1732
+ mode: 'cors',
1733
+ credentials: 'omit'
1734
+ };
1735
+ function createFormBody(params) {
1736
+ var formBody = Object.keys(params).reduce(function (formBodyArray, key) {
1737
+ var encodedKey = encodeURIComponent(key);
1738
+ var encodedValue = encodeURIComponent(params[key]);
1739
+ var encodedFormBody = "".concat(encodedKey, "=").concat(encodedValue);
1740
+ return [].concat(_toConsumableArray(formBodyArray), [encodedFormBody]);
1741
+ }, []);
1742
+ return formBody.join('&');
1743
+ }
1744
+
1745
+ var formatIntervalString = function formatIntervalString(interval) {
1746
+ var plans = {
1747
+ biannually: 'BIANNUAL PLAN',
1748
+ annually: 'ANNUAL PLAN'
1749
+ };
1750
+ return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
1751
+ };
1752
+
1753
+ var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
1754
+ var currency = _ref.currency,
1755
+ amount = _ref.amount,
1756
+ merchantName = _ref.merchantName,
1757
+ interval = _ref.interval;
1758
+ return _objectSpread2({
1759
+ countryCode: 'NG',
1760
+ currencyCode: currency,
1761
+ merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
1762
+ supportedNetworks: ['visa', 'masterCard'],
1763
+ requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
1764
+ total: {
1765
+ label: "".concat(merchantName, " - Paystack"),
1766
+ type: 'final',
1767
+ amount: String(amountSubunitToBase(amount))
1768
+ }
1769
+ }, typeof interval === 'string' && interval.trim() !== '' && {
1770
+ lineItems: [{
1771
+ label: formatIntervalString(interval),
1772
+ amount: String(amountSubunitToBase(amount))
1773
+ }]
1774
+ });
1775
+ };
1776
+ var validateApplePaySession = function validateApplePaySession(_ref2) {
1777
+ var transactionId = _ref2.transactionId,
1778
+ validationURL = _ref2.validationURL,
1779
+ merchantName = _ref2.merchantName,
1780
+ _ref2$domainName = _ref2.domainName,
1781
+ domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
1782
+ var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
1783
+ var params = {
1784
+ transaction: transactionId,
1785
+ sessionUrl: validationURL,
1786
+ displayName: merchantName,
1787
+ domainName: domainName
1788
+ };
1789
+ var formBody = createFormBody(params);
1790
+ var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
1791
+ body: formBody
1792
+ })).then(function (response) {
1793
+ return response.json();
1794
+ });
1795
+ return validateSession;
1796
+ };
1797
+ var chargeApplePay = function chargeApplePay(_ref3) {
1798
+ var transactionId = _ref3.transactionId,
1799
+ payment = _ref3.payment;
1800
+ var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
1801
+ var params = {
1802
+ transaction: transactionId,
1803
+ paymentObject: JSON.stringify(payment)
1804
+ };
1805
+ var formBody = createFormBody(params);
1806
+ var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
1807
+ body: formBody
1808
+ })).then(function (response) {
1809
+ return response.json();
1810
+ });
1811
+ return charge;
1812
+ };
1813
+ var deviceSupportsApplePay = function deviceSupportsApplePay() {
1814
+ try {
1815
+ return window.location && window.location.protocol === 'https:' && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
1816
+ } catch (error) {
1817
+ return false;
1818
+ }
1819
+ };
1820
+ var canUseApplePay = function canUseApplePay() {
1821
+ var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1822
+ return deviceSupportsApplePay() && channels.includes('apple_pay');
1823
+ };
1824
+
1772
1825
  var canUseVault = function canUseVault() {
1773
1826
  var _transaction$link_con, _transaction$link_con2;
1774
1827
 
@@ -1892,7 +1945,7 @@ var Inline = /*#__PURE__*/function () {
1892
1945
  var transaction = resumableTransaction || new InlineTransaction(params);
1893
1946
  return new Promise(function (resolve, reject) {
1894
1947
  transaction.requestInline().then(function (response) {
1895
- var canPayWithApplePay = isAppleOS() && canUseApplePay(response.channels);
1948
+ var canPayWithApplePay = response.channels.includes('apple_pay');
1896
1949
  var canPayWithVault = canUseVault(response);
1897
1950
  var shouldLoadPreCheckoutModal = canPayWithVault || canPayWithApplePay;
1898
1951
 
@@ -1923,9 +1976,9 @@ var Inline = /*#__PURE__*/function () {
1923
1976
  styles: {
1924
1977
  applePay: {
1925
1978
  width: '100%',
1926
- type: 'pay',
1979
+ type: 'plain',
1927
1980
  height: '42px',
1928
- padding: '15px',
1981
+ padding: '0px',
1929
1982
  borderRadius: '5px'
1930
1983
  }
1931
1984
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paystack/inline-js",
3
- "version": "2.22.8-dev.1",
3
+ "version": "2.23.0-dev.1",
4
4
  "description": "Client-side library to load the Paystack checkout form",
5
5
  "main": "lib/inline.js",
6
6
  "module": "es/inline.js",