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