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