@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/es/inline.js CHANGED
@@ -14,6 +14,37 @@ function _arrayWithoutHoles(r) {
14
14
  if (Array.isArray(r)) return _arrayLikeToArray(r);
15
15
  }
16
16
 
17
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
18
+ try {
19
+ var i = n[a](c),
20
+ u = i.value;
21
+ } catch (n) {
22
+ return void e(n);
23
+ }
24
+
25
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
26
+ }
27
+
28
+ function _asyncToGenerator(n) {
29
+ return function () {
30
+ var t = this,
31
+ e = arguments;
32
+ return new Promise(function (r, o) {
33
+ var a = n.apply(t, e);
34
+
35
+ function _next(n) {
36
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
37
+ }
38
+
39
+ function _throw(n) {
40
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
41
+ }
42
+
43
+ _next(void 0);
44
+ });
45
+ };
46
+ }
47
+
17
48
  function _classCallCheck(a, n) {
18
49
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
19
50
  }
@@ -401,116 +432,6 @@ var generateApplePayFallbackCSS = function generateApplePayFallbackCSS(_ref2) {
401
432
  };
402
433
  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";
403
434
 
404
- var amountSubunitToBase = function amountSubunitToBase() {
405
- var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
406
- return Number(parseFloat(amount / 100).toFixed(2));
407
- };
408
-
409
- var requestConfig = {
410
- headers: {
411
- accept: 'application/json, text/plain, */*',
412
- 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
413
- 'content-type': 'application/x-www-form-urlencoded',
414
- 'sec-ch-ua-mobile': '?0',
415
- 'sec-fetch-dest': 'empty',
416
- 'sec-fetch-mode': 'cors',
417
- 'sec-fetch-site': 'cross-site'
418
- },
419
- referrerPolicy: 'no-referrer-when-downgrade',
420
- method: 'POST',
421
- mode: 'cors',
422
- credentials: 'omit'
423
- };
424
- function createFormBody(params) {
425
- var formBody = Object.keys(params).reduce(function (formBodyArray, key) {
426
- var encodedKey = encodeURIComponent(key);
427
- var encodedValue = encodeURIComponent(params[key]);
428
- var encodedFormBody = "".concat(encodedKey, "=").concat(encodedValue);
429
- return [].concat(_toConsumableArray(formBodyArray), [encodedFormBody]);
430
- }, []);
431
- return formBody.join('&');
432
- }
433
-
434
- var formatIntervalString = function formatIntervalString(interval) {
435
- var plans = {
436
- biannually: 'BIANNUAL PLAN',
437
- annually: 'ANNUAL PLAN'
438
- };
439
- return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
440
- };
441
-
442
- var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
443
- var currency = _ref.currency,
444
- amount = _ref.amount,
445
- merchantName = _ref.merchantName,
446
- interval = _ref.interval;
447
- return _objectSpread2({
448
- countryCode: 'NG',
449
- currencyCode: currency,
450
- merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
451
- supportedNetworks: ['visa', 'masterCard'],
452
- requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
453
- total: {
454
- label: "".concat(merchantName, " - Paystack"),
455
- type: 'final',
456
- amount: String(amountSubunitToBase(amount))
457
- }
458
- }, typeof interval === 'string' && interval.trim() !== '' && {
459
- lineItems: [{
460
- label: formatIntervalString(interval),
461
- amount: String(amountSubunitToBase(amount))
462
- }]
463
- });
464
- };
465
- var validateApplePaySession = function validateApplePaySession(_ref2) {
466
- var transactionId = _ref2.transactionId,
467
- validationURL = _ref2.validationURL,
468
- merchantName = _ref2.merchantName,
469
- _ref2$domainName = _ref2.domainName,
470
- domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
471
- var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
472
- var params = {
473
- transaction: transactionId,
474
- sessionUrl: validationURL,
475
- displayName: merchantName,
476
- domainName: domainName
477
- };
478
- var formBody = createFormBody(params);
479
- var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
480
- body: formBody
481
- })).then(function (response) {
482
- return response.json();
483
- });
484
- return validateSession;
485
- };
486
- var chargeApplePay = function chargeApplePay(_ref3) {
487
- var transactionId = _ref3.transactionId,
488
- payment = _ref3.payment;
489
- var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
490
- var params = {
491
- transaction: transactionId,
492
- paymentObject: JSON.stringify(payment)
493
- };
494
- var formBody = createFormBody(params);
495
- var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
496
- body: formBody
497
- })).then(function (response) {
498
- return response.json();
499
- });
500
- return charge;
501
- };
502
- var deviceSupportsApplePay = function deviceSupportsApplePay() {
503
- try {
504
- return window.location && window.location.protocol === 'https:' && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
505
- } catch (error) {
506
- return false;
507
- }
508
- };
509
- var canUseApplePay = function canUseApplePay() {
510
- var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
511
- return deviceSupportsApplePay() && channels.includes('apple_pay');
512
- };
513
-
514
435
  /* eslint-env browser */
515
436
  function findHighestZIndex() {
516
437
  var highestZIndex = 0;
@@ -526,8 +447,8 @@ function findHighestZIndex() {
526
447
  return highestZIndex;
527
448
  }
528
449
 
529
- var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js';
530
- var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-z/6BVHCcSypLSykOVpaT1PQWHOOgU45uOOlMkgi/bElX4yFqmChNMb7qiv80wFav';
450
+ var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.2.0/apple-pay-sdk.js';
451
+ var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-hopRfycfKWs+MFyVuNk99Lb7EEhZdyoatMFJRsBk8bXoxaBXkQ+LCPm98iPgFw3a';
531
452
 
532
453
  function createIframe(id) {
533
454
  var iframe = document.createElement('iframe');
@@ -761,54 +682,87 @@ function mountPaymentRequestButtons(container, _ref4, merchantId) {
761
682
  };
762
683
  return new Promise(function (resolve, reject) {
763
684
  if (container) {
764
- if (canUseApplePay(channels)) {
765
- if (getApplePayButton(container)) {
766
- mountedElements.applePay = true;
767
- resolve(mountedElements);
768
- return;
769
- }
685
+ if (!channels.includes('apple_pay')) {
686
+ reject('No wallet payment method is available on this device');
687
+ return;
688
+ }
770
689
 
771
- loadScript(APPLE_PAY_SDK_SOURCE, {
772
- container: container,
773
- integrity: APPLE_PAY_SDK_INTEGRITY_HASH
774
- }).then(function () {
775
- /**
776
- * We are currently attempting to deprecate the below code to check webpackjsonp is an array.
777
- * To do this safely, we are limiting this change to single test integration before rolling
778
- * out more widely
779
- */
780
- var TEST_INTEGRATION = 1077497;
781
- /**
782
- * The Apple Pay SDK expects `window.webpackJsonp` to be array-like
783
- * but we have seen instances where that is not the case, causing the SDK to throw errors
784
- * so in this scenario, we opt out of using the SDK
785
- */
786
-
787
- if (merchantId && merchantId !== TEST_INTEGRATION) {
788
- if (window && !Array.isArray(window.webpackJsonp)) {
789
- throw new Error("Incorrect data type for 'webpackJsonp', expected array, got ".concat(_typeof(window.webpackJsonp), ". Switching to fallback apple pay button"));
690
+ if (getApplePayButton(container)) {
691
+ mountedElements.applePay = true;
692
+ resolve(mountedElements);
693
+ return;
694
+ }
695
+
696
+ loadScript(APPLE_PAY_SDK_SOURCE, {
697
+ container: container,
698
+ integrity: APPLE_PAY_SDK_INTEGRITY_HASH
699
+ }).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
700
+ var _window$ApplePaySessi, capabilities, unsupported, _window$ApplePaySessi2, _window$ApplePaySessi3;
701
+
702
+ return regeneratorRuntime.wrap(function _callee$(_context) {
703
+ while (1) {
704
+ switch (_context.prev = _context.next) {
705
+ case 0:
706
+ _context.prev = 0;
707
+ _context.next = 3;
708
+ return (_window$ApplePaySessi = window.ApplePaySession) === null || _window$ApplePaySessi === void 0 ? void 0 : _window$ApplePaySessi.applePayCapabilities();
709
+
710
+ case 3:
711
+ capabilities = _context.sent;
712
+ unsupported = (capabilities === null || capabilities === void 0 ? void 0 : capabilities.paymentCredentialStatus) === 'applePayUnsupported';
713
+
714
+ if (!unsupported) {
715
+ _context.next = 7;
716
+ break;
717
+ }
718
+
719
+ throw new Error('Apple Pay is not supported on this device');
720
+
721
+ case 7:
722
+ _context.next = 15;
723
+ break;
724
+
725
+ case 9:
726
+ _context.prev = 9;
727
+ _context.t0 = _context["catch"](0);
728
+
729
+ if (!(_context.t0.message === 'Apple Pay is not supported on this device')) {
730
+ _context.next = 13;
731
+ break;
732
+ }
733
+
734
+ throw _context.t0;
735
+
736
+ case 13:
737
+ 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)) {
738
+ _context.next = 15;
739
+ break;
740
+ }
741
+
742
+ throw new Error('Apple Pay is not supported on this device');
743
+
744
+ case 15:
745
+ mountApplePayButton(container, {
746
+ styles: parseApplePayCustomStyles(styles.applePay),
747
+ theme: styles.theme
748
+ });
749
+ mountedElements.applePay = true;
750
+ resolve(mountedElements);
751
+
752
+ case 18:
753
+ case "end":
754
+ return _context.stop();
790
755
  }
791
756
  }
792
-
793
- mountApplePayButton(container, {
794
- styles: parseApplePayCustomStyles(styles.applePay),
795
- theme: styles.theme
796
- });
797
- mountedElements.applePay = true;
798
- resolve(mountedElements);
799
- }).catch(function () {
800
- // if the loading of the apple pay SDK fails, that means using the apple-pay-button web component won't work
801
- // 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
802
- mountApplePayFallbackButton(container, {
803
- styles: parseApplePayCustomStyles(styles.applePay),
804
- theme: styles.theme
805
- });
806
- mountedElements.applePay = true;
807
- resolve(mountedElements);
757
+ }, _callee, null, [[0, 9]]);
758
+ }))).catch(function () {
759
+ mountApplePayFallbackButton(container, {
760
+ styles: parseApplePayCustomStyles(styles.applePay),
761
+ theme: styles.theme
808
762
  });
809
- } else {
810
- reject('No wallet payment method is available on this device');
811
- }
763
+ mountedElements.applePay = true;
764
+ resolve(mountedElements);
765
+ });
812
766
  } else {
813
767
  reject('Container to mount elements was not provided');
814
768
  }
@@ -892,8 +846,8 @@ function vaultPreCheckoutModalView(container) {
892
846
  }
893
847
  }
894
848
 
895
- function defaultPreCheckoutModalView(container, _ref5) {
896
- var hasOtherPaymentMethods = _ref5.hasOtherPaymentMethods;
849
+ function defaultPreCheckoutModalView(container, _ref6) {
850
+ var hasOtherPaymentMethods = _ref6.hasOtherPaymentMethods;
897
851
  var applePayIcon = document.createElement('div');
898
852
  applePayIcon.innerHTML = applePayMarkLight;
899
853
  container.appendChild(applePayIcon);
@@ -936,14 +890,14 @@ function mountPreCheckoutModal(id, transaction) {
936
890
  content.classList.add('pre-checkout-modal__content');
937
891
  modal.appendChild(content);
938
892
 
939
- var _ref6 = transaction || {},
940
- merchantLogo = _ref6.merchant_logo,
941
- merchantName = _ref6.merchant_name,
942
- email = _ref6.email,
943
- amount = _ref6.amount,
944
- currency = _ref6.currency,
945
- label = _ref6.label,
946
- channels = _ref6.channels;
893
+ var _ref7 = transaction || {},
894
+ merchantLogo = _ref7.merchant_logo,
895
+ merchantName = _ref7.merchant_name,
896
+ email = _ref7.email,
897
+ amount = _ref7.amount,
898
+ currency = _ref7.currency,
899
+ label = _ref7.label,
900
+ channels = _ref7.channels;
947
901
 
948
902
  var formattedAmount = new Intl.NumberFormat('en', {
949
903
  style: 'currency',
@@ -1440,17 +1394,6 @@ var isIOS = function isIOS() {
1440
1394
  return iOSDevices.includes(devicePlatform) || // iPAD os safari detection. iPad OS uses the same version of safari as Mac OS
1441
1395
  userAgent.includes('Mac') && 'ontouchend' in document;
1442
1396
  };
1443
- var isAppleOS = function isAppleOS() {
1444
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1445
- platform = _ref2.platform,
1446
- _ref2$userAgent = _ref2.userAgent,
1447
- userAgent = _ref2$userAgent === void 0 ? window && window.navigator && window.navigator.userAgent : _ref2$userAgent;
1448
-
1449
- var devicePlatform = platform || DEVICE_PLATFORM;
1450
- var isSafari = userAgent && !!userAgent.match(/Version\/[\d.]+.*Safari/);
1451
- var isMAC = devicePlatform && /(Mac)/i.test(devicePlatform);
1452
- return isIOS() || isMAC && isSafari;
1453
- };
1454
1397
 
1455
1398
  /* eslint-env browser */
1456
1399
  var AnalyticsAPI = {
@@ -1767,6 +1710,116 @@ var InlineTransaction = /*#__PURE__*/function () {
1767
1710
  return InlineTransaction;
1768
1711
  }();
1769
1712
 
1713
+ var amountSubunitToBase = function amountSubunitToBase() {
1714
+ var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1715
+ return Number(parseFloat(amount / 100).toFixed(2));
1716
+ };
1717
+
1718
+ var requestConfig = {
1719
+ headers: {
1720
+ accept: 'application/json, text/plain, */*',
1721
+ 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
1722
+ 'content-type': 'application/x-www-form-urlencoded',
1723
+ 'sec-ch-ua-mobile': '?0',
1724
+ 'sec-fetch-dest': 'empty',
1725
+ 'sec-fetch-mode': 'cors',
1726
+ 'sec-fetch-site': 'cross-site'
1727
+ },
1728
+ referrerPolicy: 'no-referrer-when-downgrade',
1729
+ method: 'POST',
1730
+ mode: 'cors',
1731
+ credentials: 'omit'
1732
+ };
1733
+ function createFormBody(params) {
1734
+ var formBody = Object.keys(params).reduce(function (formBodyArray, key) {
1735
+ var encodedKey = encodeURIComponent(key);
1736
+ var encodedValue = encodeURIComponent(params[key]);
1737
+ var encodedFormBody = "".concat(encodedKey, "=").concat(encodedValue);
1738
+ return [].concat(_toConsumableArray(formBodyArray), [encodedFormBody]);
1739
+ }, []);
1740
+ return formBody.join('&');
1741
+ }
1742
+
1743
+ var formatIntervalString = function formatIntervalString(interval) {
1744
+ var plans = {
1745
+ biannually: 'BIANNUAL PLAN',
1746
+ annually: 'ANNUAL PLAN'
1747
+ };
1748
+ return plans[interval] || "".concat(interval.toUpperCase(), " PLAN");
1749
+ };
1750
+
1751
+ var generateApplePaymentRequestObject = function generateApplePaymentRequestObject(_ref) {
1752
+ var currency = _ref.currency,
1753
+ amount = _ref.amount,
1754
+ merchantName = _ref.merchantName,
1755
+ interval = _ref.interval;
1756
+ return _objectSpread2({
1757
+ countryCode: 'NG',
1758
+ currencyCode: currency,
1759
+ merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
1760
+ supportedNetworks: ['visa', 'masterCard'],
1761
+ requiredBillingContactFields: ['postalAddress', 'name', 'phone', 'email'],
1762
+ total: {
1763
+ label: "".concat(merchantName, " - Paystack"),
1764
+ type: 'final',
1765
+ amount: String(amountSubunitToBase(amount))
1766
+ }
1767
+ }, typeof interval === 'string' && interval.trim() !== '' && {
1768
+ lineItems: [{
1769
+ label: formatIntervalString(interval),
1770
+ amount: String(amountSubunitToBase(amount))
1771
+ }]
1772
+ });
1773
+ };
1774
+ var validateApplePaySession = function validateApplePaySession(_ref2) {
1775
+ var transactionId = _ref2.transactionId,
1776
+ validationURL = _ref2.validationURL,
1777
+ merchantName = _ref2.merchantName,
1778
+ _ref2$domainName = _ref2.domainName,
1779
+ domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
1780
+ var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
1781
+ var params = {
1782
+ transaction: transactionId,
1783
+ sessionUrl: validationURL,
1784
+ displayName: merchantName,
1785
+ domainName: domainName
1786
+ };
1787
+ var formBody = createFormBody(params);
1788
+ var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
1789
+ body: formBody
1790
+ })).then(function (response) {
1791
+ return response.json();
1792
+ });
1793
+ return validateSession;
1794
+ };
1795
+ var chargeApplePay = function chargeApplePay(_ref3) {
1796
+ var transactionId = _ref3.transactionId,
1797
+ payment = _ref3.payment;
1798
+ var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
1799
+ var params = {
1800
+ transaction: transactionId,
1801
+ paymentObject: JSON.stringify(payment)
1802
+ };
1803
+ var formBody = createFormBody(params);
1804
+ var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
1805
+ body: formBody
1806
+ })).then(function (response) {
1807
+ return response.json();
1808
+ });
1809
+ return charge;
1810
+ };
1811
+ var deviceSupportsApplePay = function deviceSupportsApplePay() {
1812
+ try {
1813
+ return window.location && window.location.protocol === 'https:' && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
1814
+ } catch (error) {
1815
+ return false;
1816
+ }
1817
+ };
1818
+ var canUseApplePay = function canUseApplePay() {
1819
+ var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1820
+ return deviceSupportsApplePay() && channels.includes('apple_pay');
1821
+ };
1822
+
1770
1823
  var canUseVault = function canUseVault() {
1771
1824
  var _transaction$link_con, _transaction$link_con2;
1772
1825
 
@@ -1890,7 +1943,7 @@ var Inline = /*#__PURE__*/function () {
1890
1943
  var transaction = resumableTransaction || new InlineTransaction(params);
1891
1944
  return new Promise(function (resolve, reject) {
1892
1945
  transaction.requestInline().then(function (response) {
1893
- var canPayWithApplePay = isAppleOS() && canUseApplePay(response.channels);
1946
+ var canPayWithApplePay = response.channels.includes('apple_pay');
1894
1947
  var canPayWithVault = canUseVault(response);
1895
1948
  var shouldLoadPreCheckoutModal = canPayWithVault || canPayWithApplePay;
1896
1949
 
@@ -1921,9 +1974,9 @@ var Inline = /*#__PURE__*/function () {
1921
1974
  styles: {
1922
1975
  applePay: {
1923
1976
  width: '100%',
1924
- type: 'pay',
1977
+ type: 'plain',
1925
1978
  height: '42px',
1926
- padding: '15px',
1979
+ padding: '0px',
1927
1980
  borderRadius: '5px'
1928
1981
  }
1929
1982
  }