@paystack/inline-js 2.27.0-dev.1 → 2.27.0-dev.3

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/es/inline.js CHANGED
@@ -224,8 +224,9 @@ function similarObjects(o1, o2) {
224
224
  return equalKeys && equalValues;
225
225
  }
226
226
 
227
- var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js';
228
- var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-z/6BVHCcSypLSykOVpaT1PQWHOOgU45uOOlMkgi/bElX4yFqmChNMb7qiv80wFav';
227
+ var APPLE_PAY_SDK_SOURCE = 'https://applepay.cdn-apple.com/jsapi/v1.3.8/apple-pay-sdk.js';
228
+ var APPLE_PAY_SDK_INTEGRITY_HASH = 'sha384-u/9mOkmShCO0v+dqCAZFhiutJuORfzvuyM5i+676iy7mLSWS6rlllHrIt15f/mqH';
229
+ var APPLE_PAY_TIMEOUT_MS = 10000;
229
230
  var GOOGLE_PAY_SDK_SOURCE = 'https://pay.google.com/gp/p/js/pay.js';
230
231
  var PAYMENT_REQUEST_BUTTON_HEIGHT = '50px';
231
232
  var GOOGLE_PAY_BUTTON_RADIUS = 3;
@@ -466,6 +467,78 @@ var loadScript = function loadScript(url) {
466
467
  });
467
468
  };
468
469
 
470
+ var withTimeoutDelay = function withTimeoutDelay(work, delayInMilliseconds) {
471
+ var onTimeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
472
+ return null;
473
+ };
474
+ var timeout;
475
+ var delay = new Promise(function (resolve) {
476
+ timeout = setTimeout(function () {
477
+ try {
478
+ resolve(onTimeout());
479
+ } catch (error) {
480
+ resolve(null);
481
+ }
482
+ }, delayInMilliseconds);
483
+ });
484
+ return Promise.race([work, delay]).finally(function () {
485
+ return clearTimeout(timeout);
486
+ });
487
+ };
488
+
489
+ /* eslint-env browser */
490
+
491
+ var iOSDevices = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'];
492
+
493
+ /**
494
+ * navigator.platform is deprecated and will eventually be removed
495
+ * but the recommended alternative `navigator.userAgentData` has limited browser support
496
+ * so it is used as a fallback here.
497
+ */
498
+ var DEVICE_PLATFORM = window && window.navigator && (window.navigator.platform || window.navigator.userAgentData && window.navigator.userAgentData.platform);
499
+ var getDeviceInfo = function getDeviceInfo() {
500
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
501
+ platform = _ref.platform,
502
+ _ref$userAgent = _ref.userAgent,
503
+ userAgent = _ref$userAgent === void 0 ? window && window.navigator && window.navigator.userAgent : _ref$userAgent;
504
+ return {
505
+ devicePlatform: platform || DEVICE_PLATFORM,
506
+ deviceUserAgent: userAgent
507
+ };
508
+ };
509
+ var isIOS = function isIOS() {
510
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
511
+ var _getDeviceInfo = getDeviceInfo(options),
512
+ devicePlatform = _getDeviceInfo.devicePlatform,
513
+ deviceUserAgent = _getDeviceInfo.deviceUserAgent;
514
+ return iOSDevices.includes(devicePlatform) ||
515
+ // iPAD os safari detection. iPad OS uses the same version of safari as Mac OS
516
+ deviceUserAgent.includes('Mac') && 'ontouchend' in document;
517
+ };
518
+ var isSafari = function isSafari() {
519
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
520
+ var _getDeviceInfo2 = getDeviceInfo(options),
521
+ deviceUserAgent = _getDeviceInfo2.deviceUserAgent;
522
+ return Boolean(deviceUserAgent && !/Android/.test(deviceUserAgent) && /Version\/[\d.]+.*Safari/.test(deviceUserAgent));
523
+ };
524
+
525
+ // Safari and third-party iOS browsers both send a `Safari/` token; an embedded WKWebView sends none.
526
+ var isIOSWebView = function isIOSWebView() {
527
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
528
+ var _getDeviceInfo3 = getDeviceInfo(options),
529
+ deviceUserAgent = _getDeviceInfo3.deviceUserAgent;
530
+ return Boolean(deviceUserAgent) && isIOS(options) && !/Safari\//.test(deviceUserAgent);
531
+ };
532
+ var isAppleOS = function isAppleOS() {
533
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
534
+ var _getDeviceInfo4 = getDeviceInfo(options),
535
+ devicePlatform = _getDeviceInfo4.devicePlatform;
536
+ return isIOS(options) || Boolean(devicePlatform && /Mac/i.test(devicePlatform));
537
+ };
538
+
539
+ var APPLE_PAY_UNSUPPORTED = 'applePayUnsupported';
540
+ var hasNativeSupportCache = null;
541
+ var sdkLoad = null;
469
542
  var requestConfig = {
470
543
  headers: {
471
544
  accept: 'application/json, text/plain, */*',
@@ -503,7 +576,7 @@ var generateApplePaymentRequestObject = function generateApplePaymentRequestObje
503
576
  merchantName = _ref.merchantName,
504
577
  interval = _ref.interval;
505
578
  return _objectSpread2({
506
- countryCode: 'NG',
579
+ countryCode: CURRENCY_COUNTRYCODE_MAPPING[currency] || COUNTRYCODE.NIGERIA,
507
580
  currencyCode: currency,
508
581
  merchantCapabilities: ['supports3DS', 'supportsCredit', 'supportsDebit'],
509
582
  supportedNetworks: ['visa', 'masterCard'],
@@ -522,17 +595,26 @@ var generateApplePaymentRequestObject = function generateApplePaymentRequestObje
522
595
  };
523
596
  var validateApplePaySession = function validateApplePaySession(_ref2) {
524
597
  var transactionId = _ref2.transactionId,
598
+ accessCode = _ref2.accessCode,
599
+ publicKey = _ref2.publicKey,
525
600
  validationURL = _ref2.validationURL,
526
601
  merchantName = _ref2.merchantName,
527
602
  _ref2$domainName = _ref2.domainName,
528
603
  domainName = _ref2$domainName === void 0 ? window && window.location && window.location.hostname : _ref2$domainName;
529
604
  var validateSessionUrl = "".concat(config.paymentBaseUrl).concat(config.applePayValidateSessionPath);
530
- var params = {
531
- transaction: transactionId,
605
+
606
+ // createFormBody would send a missing value as the text "undefined"
607
+ var params = _objectSpread2(_objectSpread2(_objectSpread2({
608
+ transaction: transactionId
609
+ }, accessCode && {
610
+ accessCode: accessCode
611
+ }), publicKey && {
612
+ publicKey: publicKey
613
+ }), {}, {
532
614
  sessionUrl: validationURL,
533
615
  displayName: merchantName,
534
616
  domainName: domainName
535
- };
617
+ });
536
618
  var formBody = createFormBody(params);
537
619
  var validateSession = fetch(validateSessionUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
538
620
  body: formBody
@@ -543,12 +625,18 @@ var validateApplePaySession = function validateApplePaySession(_ref2) {
543
625
  };
544
626
  var chargeApplePay = function chargeApplePay(_ref3) {
545
627
  var transactionId = _ref3.transactionId,
628
+ accessCode = _ref3.accessCode,
546
629
  payment = _ref3.payment;
547
630
  var chargeApplePayUrl = "".concat(config.paymentBaseUrl).concat(config.applePayChargePath);
548
- var params = {
549
- transaction: transactionId,
631
+
632
+ // createFormBody would send a missing access code as the text "undefined"
633
+ var params = _objectSpread2(_objectSpread2({
634
+ transaction: transactionId
635
+ }, accessCode && {
636
+ accessCode: accessCode
637
+ }), {}, {
550
638
  paymentObject: JSON.stringify(payment)
551
- };
639
+ });
552
640
  var formBody = createFormBody(params);
553
641
  var charge = fetch(chargeApplePayUrl, _objectSpread2(_objectSpread2({}, requestConfig), {}, {
554
642
  body: formBody
@@ -559,29 +647,134 @@ var chargeApplePay = function chargeApplePay(_ref3) {
559
647
  };
560
648
  var deviceSupportsApplePay = function deviceSupportsApplePay() {
561
649
  try {
562
- return window.isSecureContext && window.ApplePaySession && window.ApplePaySession.supportsVersion(config.applePayVersion);
650
+ return Boolean(isAppleOS() && (isSafari() || isIOSWebView()) && window.isSecureContext && window.ApplePaySession && !window.ApplePaySession.isNotWebkit && window.ApplePaySession.supportsVersion(config.applePayVersion));
563
651
  } catch (error) {
564
652
  return false;
565
653
  }
566
654
  };
567
- var canUseApplePay = function canUseApplePay() {
568
- var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
569
- return deviceSupportsApplePay() && channels.includes(CHANNELS.APPLE_PAY);
655
+
656
+ /**
657
+ * Off WebKit the SDK installs its own `window.ApplePaySession` whose
658
+ * `supportsVersion()` always returns true, so native support is only
659
+ * trustworthy when read before the SDK loads.
660
+ */
661
+ var getNativeSupport = function getNativeSupport() {
662
+ if (hasNativeSupportCache === null) {
663
+ hasNativeSupportCache = deviceSupportsApplePay();
664
+ }
665
+ return hasNativeSupportCache;
666
+ };
667
+
668
+ /**
669
+ * Off WebKit the SDK assigns `window.onbeforeunload` to close its QR-code
670
+ * window, replacing any handler the merchant page set, such as an
671
+ * unsaved-changes guard. Run both, and return the merchant's result because
672
+ * that is what triggers the browser's "Leave site?" prompt.
673
+ */
674
+ var combineSdkAndMerchantBeforeUnload = function combineSdkAndMerchantBeforeUnload(merchantHandler) {
675
+ var sdkHandler = window.onbeforeunload;
676
+ if (sdkHandler === merchantHandler || typeof merchantHandler !== 'function' || typeof sdkHandler !== 'function') {
677
+ return;
678
+ }
679
+ window.onbeforeunload = function combinedBeforeUnload(event) {
680
+ var sdkResult = sdkHandler.call(window, event);
681
+ var merchantResult = merchantHandler.call(window, event);
682
+ return merchantResult !== undefined ? merchantResult : sdkResult;
683
+ };
684
+ };
685
+ var loadApplePaySDK = function loadApplePaySDK() {
686
+ if (!sdkLoad) {
687
+ var merchantBeforeUnload = window.onbeforeunload;
688
+ sdkLoad = loadScript(APPLE_PAY_SDK_SOURCE, {
689
+ integrity: APPLE_PAY_SDK_INTEGRITY_HASH
690
+ }).then(function () {
691
+ combineSdkAndMerchantBeforeUnload(merchantBeforeUnload);
692
+ return true;
693
+ }).catch(function () {
694
+ sdkLoad = null;
695
+ return false;
696
+ });
697
+ }
698
+ return sdkLoad;
570
699
  };
571
- var loadApplePay = function loadApplePay() {
572
- return loadScript(APPLE_PAY_SDK_SOURCE, {
573
- integrity: APPLE_PAY_SDK_INTEGRITY_HASH
574
- }).then(function () {
575
- /**
576
- * The Apple Pay SDK expects `window.webpackJsonp` to be array-like
577
- * but we have seen instances where that is not the case, causing the SDK to throw errors
578
- * so in this scenario, we opt out of using the SDK
579
- */
580
- if (window && !Array.isArray(window.webpackJsonp)) {
581
- throw new Error("Incorrect data type for 'webpackJsonp', expected array, got ".concat(_typeof(window.webpackJsonp), ". Switching to fallback apple pay button"));
700
+ var probeApplePayCapabilities = function probeApplePayCapabilities(merchantId) {
701
+ return Promise.resolve().then(function () {
702
+ if (typeof window.ApplePaySession.applePayCapabilities !== 'function') {
703
+ return null;
582
704
  }
705
+ return window.ApplePaySession.applePayCapabilities(merchantId);
706
+ }).then(function (capabilities) {
707
+ return (capabilities || {}).paymentCredentialStatus || null;
708
+ }).catch(function () {
709
+ return null;
583
710
  });
584
711
  };
712
+ var loadThenProbe = function loadThenProbe(merchantId) {
713
+ return loadApplePaySDK().then(function (sdkLoaded) {
714
+ return (sdkLoaded ? probeApplePayCapabilities(merchantId) : Promise.resolve(null)).then(function (status) {
715
+ return {
716
+ status: status,
717
+ sdkLoaded: sdkLoaded
718
+ };
719
+ });
720
+ });
721
+ };
722
+ var normaliseRegisteredDomain = function normaliseRegisteredDomain(domain) {
723
+ return String(domain).toLowerCase().replace(/\/+$/, '');
724
+ };
725
+ var isPageDomainRegisteredWithApple = function isPageDomainRegisteredWithApple(registeredDomains) {
726
+ var hostname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.hostname;
727
+ return Array.isArray(registeredDomains) && registeredDomains.some(function (domain) {
728
+ return normaliseRegisteredDomain(domain) === hostname.toLowerCase();
729
+ });
730
+ };
731
+ var shouldProbe = function shouldProbe(response, merchantId, hasNativeSupport) {
732
+ var channels = response.channels || [];
733
+ var applePaySettings = response.channel_settings && response.channel_settings.apple_pay || {};
734
+ return channels.includes(CHANNELS.APPLE_PAY) && Boolean(merchantId) && (isPageDomainRegisteredWithApple(applePaySettings.domains) || hasNativeSupport);
735
+ };
736
+ var resolveApplePayStatus = function resolveApplePayStatus(response) {
737
+ try {
738
+ var safeResponse = response || {};
739
+ var hasNativeSupport = getNativeSupport();
740
+ var merchantId = safeResponse.channel_settings && safeResponse.channel_settings.apple_pay && safeResponse.channel_settings.apple_pay.merchant_identifier;
741
+ if (!shouldProbe(safeResponse, merchantId, hasNativeSupport)) {
742
+ return Promise.resolve({
743
+ status: null,
744
+ hasNativeSupport: hasNativeSupport,
745
+ sdkLoaded: false
746
+ });
747
+ }
748
+ return withTimeoutDelay(loadThenProbe(merchantId), APPLE_PAY_TIMEOUT_MS).catch(function () {
749
+ return null;
750
+ }).then(function (result) {
751
+ return {
752
+ status: result && result.status || null,
753
+ hasNativeSupport: hasNativeSupport,
754
+ sdkLoaded: Boolean(result && result.sdkLoaded)
755
+ };
756
+ });
757
+ } catch (error) {
758
+ return Promise.resolve({
759
+ status: null,
760
+ hasNativeSupport: false,
761
+ sdkLoaded: false
762
+ });
763
+ }
764
+ };
765
+ var canUseApplePay = function canUseApplePay() {
766
+ var channels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
767
+ var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
768
+ status = _ref4.status,
769
+ hasNativeSupport = _ref4.hasNativeSupport;
770
+ if (!channels.includes(CHANNELS.APPLE_PAY)) {
771
+ return false;
772
+ }
773
+ if (status && status !== APPLE_PAY_UNSUPPORTED) {
774
+ return true;
775
+ }
776
+ return hasNativeSupport === true;
777
+ };
585
778
 
586
779
  var getChannelAmount = function getChannelAmount(response, channel) {
587
780
  var channelFees = (response && response.channel_fees_and_amount || {})[channel];
@@ -595,25 +788,6 @@ function printDeprecationNotice(oldName, newName, extraMessage) {
595
788
  logWarning("\"".concat(oldName, "\" has been deprecated, please use \"").concat(newName, "\". ").concat(extraMessage || ''));
596
789
  }
597
790
 
598
- var withTimeoutDelay = function withTimeoutDelay(work, delayInMilliseconds) {
599
- var onTimeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
600
- return null;
601
- };
602
- var timeout;
603
- var delay = new Promise(function (resolve) {
604
- timeout = setTimeout(function () {
605
- try {
606
- resolve(onTimeout());
607
- } catch (error) {
608
- resolve(null);
609
- }
610
- }, delayInMilliseconds);
611
- });
612
- return Promise.race([work, delay]).finally(function () {
613
- return clearTimeout(timeout);
614
- });
615
- };
616
-
617
791
  /**
618
792
  * Never advertised here: a `PAN_ONLY` charge comes back needing a 3DS step-up,
619
793
  * and inline-js can't handle it
@@ -1014,12 +1188,24 @@ function getMountedPaymentRequestButtons(container) {
1014
1188
  }
1015
1189
  return [getApplePayButton(container), getGooglePayButton(container)].filter(Boolean);
1016
1190
  }
1017
- function mountPaymentRequestButtons(container, _ref5) {
1018
- var transaction = _ref5.transaction,
1019
- _ref5$styles = _ref5.styles,
1020
- styles = _ref5$styles === void 0 ? {} : _ref5$styles,
1021
- onClickApplePayButton = _ref5.onClickApplePayButton,
1022
- onClickGooglePayButton = _ref5.onClickGooglePayButton;
1191
+ function mountUsableApplePayButton(container, _ref5, options) {
1192
+ var sdkLoaded = _ref5.sdkLoaded,
1193
+ hasNativeSupport = _ref5.hasNativeSupport;
1194
+ if (sdkLoaded) {
1195
+ return mountApplePayButton(container, options);
1196
+ }
1197
+ if (hasNativeSupport) {
1198
+ return mountApplePayFallbackButton(container, options);
1199
+ }
1200
+ logWarning('Apple Pay: the Apple Pay SDK did not load, so no Apple Pay button is shown.');
1201
+ return null;
1202
+ }
1203
+ function mountPaymentRequestButtons(container, _ref6) {
1204
+ var transaction = _ref6.transaction,
1205
+ _ref6$styles = _ref6.styles,
1206
+ styles = _ref6$styles === void 0 ? {} : _ref6$styles,
1207
+ onClickApplePayButton = _ref6.onClickApplePayButton,
1208
+ onClickGooglePayButton = _ref6.onClickGooglePayButton;
1023
1209
  if (!container) {
1024
1210
  return Promise.reject('Container to mount elements was not provided');
1025
1211
  }
@@ -1035,18 +1221,17 @@ function mountPaymentRequestButtons(container, _ref5) {
1035
1221
  onClick: onClickApplePayButton
1036
1222
  };
1037
1223
  var channels = transaction.response && transaction.response.channels || [];
1038
- var applePayButton = Promise.resolve(null);
1039
- if (canUseApplePay(channels)) {
1040
- applePayButton = loadApplePay().then(function () {
1041
- return mountApplePayButton(innerWrapper, applePayOptions);
1042
- }).catch(function () {
1043
- return mountApplePayFallbackButton(innerWrapper, applePayOptions);
1044
- }).catch(function () {
1045
- return null;
1046
- });
1047
- } else if (channels.includes(CHANNELS.APPLE_PAY)) {
1048
- logWarning('Apple Pay: this device or browser cannot pay with Apple Pay. It requires Safari on an Apple device, over HTTPS.');
1049
- }
1224
+ var applePayButton = resolveApplePayStatus(transaction.response).then(function (applePay) {
1225
+ if (canUseApplePay(channels, applePay)) {
1226
+ return mountUsableApplePayButton(innerWrapper, applePay, applePayOptions);
1227
+ }
1228
+ if (channels.includes(CHANNELS.APPLE_PAY)) {
1229
+ logWarning('Apple Pay: this device, browser or page cannot pay with Apple Pay here.');
1230
+ }
1231
+ return null;
1232
+ }).catch(function () {
1233
+ return null;
1234
+ });
1050
1235
  var googlePayButton = loadGooglePay(transaction).then(function (isReadyToPay) {
1051
1236
  if (!isReadyToPay) {
1052
1237
  return null;
@@ -1059,10 +1244,10 @@ function mountPaymentRequestButtons(container, _ref5) {
1059
1244
  }).catch(function () {
1060
1245
  return null;
1061
1246
  });
1062
- return Promise.all([applePayButton, googlePayButton]).then(function (_ref6) {
1063
- var _ref7 = _slicedToArray(_ref6, 2),
1064
- applePay = _ref7[0],
1065
- googlePay = _ref7[1];
1247
+ return Promise.all([applePayButton, googlePayButton]).then(function (_ref7) {
1248
+ var _ref8 = _slicedToArray(_ref7, 2),
1249
+ applePay = _ref8[0],
1250
+ googlePay = _ref8[1];
1066
1251
  if (!applePay && !googlePay) {
1067
1252
  return null;
1068
1253
  }
@@ -1468,27 +1653,6 @@ function buildQuery(parameters) {
1468
1653
  return formattedParameters;
1469
1654
  }
1470
1655
 
1471
- /* eslint-env browser */
1472
-
1473
- var iOSDevices = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'];
1474
-
1475
- /**
1476
- * navigator.platform is deprecated and will eventually be removed
1477
- * but the recommended alternative `navigator.userAgentData` has limited browser support
1478
- * so it is used as a fallback here.
1479
- */
1480
- var DEVICE_PLATFORM = window && window.navigator && (window.navigator.platform || window.navigator.userAgentData && window.navigator.userAgentData.platform);
1481
- var isIOS = function isIOS() {
1482
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1483
- platform = _ref.platform,
1484
- _ref$userAgent = _ref.userAgent,
1485
- userAgent = _ref$userAgent === void 0 ? window && window.navigator && window.navigator.userAgent : _ref$userAgent;
1486
- var devicePlatform = platform || DEVICE_PLATFORM;
1487
- return iOSDevices.includes(devicePlatform) ||
1488
- // iPAD os safari detection. iPad OS uses the same version of safari as Mac OS
1489
- userAgent.includes('Mac') && 'ontouchend' in document;
1490
- };
1491
-
1492
1656
  /* eslint-env browser */
1493
1657
  var AnalyticsAPI = {
1494
1658
  saveLog: function saveLog(transactionId, merchantPublicKey, log) {
@@ -2175,6 +2339,8 @@ var Inline = /*#__PURE__*/function () {
2175
2339
  var validateSession = validateApplePaySession({
2176
2340
  validationURL: validationURL,
2177
2341
  transactionId: transaction.id,
2342
+ accessCode: transaction.accessCode,
2343
+ publicKey: transaction.parameters.key,
2178
2344
  merchantName: transaction.response.merchant_name
2179
2345
  });
2180
2346
  validateSession.then(function (response) {
@@ -2198,19 +2364,20 @@ var Inline = /*#__PURE__*/function () {
2198
2364
  var payment = _ref3.payment;
2199
2365
  var charge = chargeApplePay({
2200
2366
  transactionId: transaction.id,
2367
+ accessCode: transaction.accessCode,
2201
2368
  payment: payment
2202
2369
  });
2203
2370
  charge.then(function (response) {
2204
2371
  transaction.logAPIResponse(response, paymentMethod);
2205
2372
  _this5.isCharging = false;
2206
2373
  if (response.status === TRANSACTION_STATUS.SUCCESS) {
2207
- applePaySession.completePayment(applePaySession.STATUS_SUCCESS);
2374
+ applePaySession.completePayment(window.ApplePaySession.STATUS_SUCCESS);
2208
2375
  transaction.onSuccess(response);
2209
2376
  _this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_COMPLETION, _objectSpread2(_objectSpread2({}, analyticsPayload), {}, {
2210
2377
  timeSpent: transaction.getTimeSpent()
2211
2378
  }));
2212
2379
  } else {
2213
- applePaySession.completePayment(applePaySession.STATUS_FAILURE);
2380
+ applePaySession.completePayment(window.ApplePaySession.STATUS_FAILURE);
2214
2381
  transaction.onSetupError(response);
2215
2382
  _this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2216
2383
  channel: CHANNELS.APPLE_PAY,
@@ -2219,7 +2386,7 @@ var Inline = /*#__PURE__*/function () {
2219
2386
  }
2220
2387
  }).catch(function (error) {
2221
2388
  _this5.isCharging = false;
2222
- applePaySession.completePayment(applePaySession.STATUS_FAILURE);
2389
+ applePaySession.completePayment(window.ApplePaySession.STATUS_FAILURE);
2223
2390
  transaction.onSetupError(error);
2224
2391
  _this5.sendAnalyticsEventToCheckout(analyticsActions.TRACK_PAYMENT_ERROR, {
2225
2392
  channel: CHANNELS.APPLE_PAY,