@paydock/client-sdk 1.84.9 → 1.86.5-beta
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 +2 -2
- package/bundles/widget.umd.js +119 -64
- package/bundles/widget.umd.min.js +1 -1
- package/lib/checkout-button/zipmoney/zipmoney-redirect.runner.js +19 -12
- package/lib/checkout-button/zipmoney/zipmoney-redirect.runner.js.map +1 -1
- package/lib/components/iframe-event.d.ts +3 -0
- package/lib/components/iframe-event.js +5 -0
- package/lib/components/iframe-event.js.map +1 -1
- package/lib/components/storage-dispatcher.d.ts +12 -2
- package/lib/components/storage-dispatcher.js +30 -7
- package/lib/components/storage-dispatcher.js.map +1 -1
- package/lib/wallet-buttons/afterpay.wallet-service.js +34 -29
- package/lib/wallet-buttons/afterpay.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/google.wallet-service.js +10 -7
- package/lib/wallet-buttons/google.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/paypal.wallet-service.d.ts +2 -1
- package/lib/wallet-buttons/paypal.wallet-service.js +18 -8
- package/lib/wallet-buttons/paypal.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/wallet-buttons.d.ts +1 -1
- package/lib/wallet-buttons/wallet-buttons.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5477,7 +5477,7 @@ Also, for **ApplePay via MPGS** you can initialize the `ApplePayPaymentRequest`
|
|
|
5477
5477
|
|
|
5478
5478
|
<dl>
|
|
5479
5479
|
<dt><a href="#WalletButtons">WalletButtons</a></dt>
|
|
5480
|
-
<dd><p>Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal)</p>
|
|
5480
|
+
<dd><p>Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal, Afterpay)</p>
|
|
5481
5481
|
</dd>
|
|
5482
5482
|
</dl>
|
|
5483
5483
|
|
|
@@ -5578,7 +5578,7 @@ Interface of Shipping Options for PayPal
|
|
|
5578
5578
|
<a name="WalletButtons" id="WalletButtons" href="#WalletButtons"> </a>
|
|
5579
5579
|
|
|
5580
5580
|
## WalletButtons
|
|
5581
|
-
Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal)
|
|
5581
|
+
Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal, Afterpay)
|
|
5582
5582
|
|
|
5583
5583
|
**Kind**: global class
|
|
5584
5584
|
|
package/bundles/widget.umd.js
CHANGED
|
@@ -1643,7 +1643,9 @@
|
|
|
1643
1643
|
CHARGE_AUTH_CANCELLED: 'chargeAuthCancelled',
|
|
1644
1644
|
ADDITIONAL_DATA_SUCCESS: 'additionalDataCollectSuccess',
|
|
1645
1645
|
ADDITIONAL_DATA_REJECT: 'additionalDataCollectReject',
|
|
1646
|
-
CHARGE_AUTH: 'chargeAuth'
|
|
1646
|
+
CHARGE_AUTH: 'chargeAuth',
|
|
1647
|
+
DISPATCH_SUCCESS: 'dispatchSuccess',
|
|
1648
|
+
DISPATCH_ERROR: 'dispatchError'
|
|
1647
1649
|
};
|
|
1648
1650
|
var IFrameEvent = function () {
|
|
1649
1651
|
function IFrameEvent(subject) {
|
|
@@ -1685,6 +1687,11 @@
|
|
|
1685
1687
|
}
|
|
1686
1688
|
}
|
|
1687
1689
|
}
|
|
1690
|
+
}, {
|
|
1691
|
+
key: 'clear',
|
|
1692
|
+
value: function clear() {
|
|
1693
|
+
this.listeners = [];
|
|
1694
|
+
}
|
|
1688
1695
|
}, {
|
|
1689
1696
|
key: 'subscribe',
|
|
1690
1697
|
value: function subscribe(subject, listener) {
|
|
@@ -4485,17 +4492,18 @@
|
|
|
4485
4492
|
};
|
|
4486
4493
|
this.env = new Env(WIDGET_URL);
|
|
4487
4494
|
this.defaultPayload.source = messageSource;
|
|
4495
|
+
this.iframeEvent = new IFrameEvent(window);
|
|
4488
4496
|
}
|
|
4489
4497
|
|
|
4490
4498
|
createClass(StorageDispatcher, [{
|
|
4491
4499
|
key: 'create',
|
|
4492
|
-
value: function create() {
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
if (this.dispatcherFrame && !reset) return this.dispatcherFrame;
|
|
4500
|
+
value: function create(onLoadCallback) {
|
|
4501
|
+
this.onLoadCallback = onLoadCallback;
|
|
4496
4502
|
if (this.dispatcherFrame) this.destroy();
|
|
4503
|
+
this.widgetId = Uuid.generate();
|
|
4504
|
+
this.setupIframeEventListeners();
|
|
4497
4505
|
var iFrame = document.createElement('iframe');
|
|
4498
|
-
iFrame.setAttribute('src', this.env.getConf().url + STORAGE_DISPATCHER_URI);
|
|
4506
|
+
iFrame.setAttribute('src', this.env.getConf().url + STORAGE_DISPATCHER_URI + ('?widgetId=' + this.widgetId));
|
|
4499
4507
|
iFrame.setAttribute('id', STORAGE_DISPATCHER_ID);
|
|
4500
4508
|
iFrame.style.display = 'none';
|
|
4501
4509
|
document.body.appendChild(iFrame);
|
|
@@ -4508,13 +4516,16 @@
|
|
|
4508
4516
|
value: function destroy() {
|
|
4509
4517
|
if (this.dispatcherFrame && this.dispatcherFrame.parentNode) {
|
|
4510
4518
|
this.dispatcherFrame.parentNode.removeChild(this.dispatcherFrame);
|
|
4511
|
-
this.dispatcherFrame = undefined;
|
|
4512
4519
|
}
|
|
4520
|
+
this.iframeEvent.clear();
|
|
4521
|
+
this.widgetId = undefined;
|
|
4522
|
+
this.dispatcherFrame = undefined;
|
|
4513
4523
|
}
|
|
4514
4524
|
}, {
|
|
4515
4525
|
key: 'push',
|
|
4516
|
-
value: function push(payload) {
|
|
4526
|
+
value: function push(payload, pushCallbacks) {
|
|
4517
4527
|
var _a;
|
|
4528
|
+
this.pushCallbacks = pushCallbacks;
|
|
4518
4529
|
if (!this.dispatcherFrame) {
|
|
4519
4530
|
console.error(LOG_PREFIX$1 + ' dispatcher is not initialized.');
|
|
4520
4531
|
return;
|
|
@@ -4526,7 +4537,26 @@
|
|
|
4526
4537
|
key: 'setEnv',
|
|
4527
4538
|
value: function setEnv(env, alias) {
|
|
4528
4539
|
this.env.setEnv(env, alias);
|
|
4529
|
-
this.create(
|
|
4540
|
+
this.create(this.onLoadCallback);
|
|
4541
|
+
}
|
|
4542
|
+
}, {
|
|
4543
|
+
key: 'setupIframeEventListeners',
|
|
4544
|
+
value: function setupIframeEventListeners() {
|
|
4545
|
+
var _this = this;
|
|
4546
|
+
|
|
4547
|
+
if (!this.widgetId) return;
|
|
4548
|
+
this.iframeEvent.on(EVENT.AFTER_LOAD, this.widgetId, function (_event) {
|
|
4549
|
+
var _a;
|
|
4550
|
+
(_a = _this.onLoadCallback) === null || _a === void 0 ? void 0 : _a.call(_this);
|
|
4551
|
+
});
|
|
4552
|
+
this.iframeEvent.on(EVENT.DISPATCH_SUCCESS, this.widgetId, function (_event) {
|
|
4553
|
+
var _a, _b;
|
|
4554
|
+
(_b = (_a = _this.pushCallbacks) === null || _a === void 0 ? void 0 : _a.onSuccess) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4555
|
+
});
|
|
4556
|
+
this.iframeEvent.on(EVENT.DISPATCH_ERROR, this.widgetId, function (_event) {
|
|
4557
|
+
var _a, _b;
|
|
4558
|
+
(_b = (_a = _this.pushCallbacks) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4559
|
+
});
|
|
4530
4560
|
}
|
|
4531
4561
|
}]);
|
|
4532
4562
|
return StorageDispatcher;
|
|
@@ -4552,18 +4582,27 @@
|
|
|
4552
4582
|
}, {
|
|
4553
4583
|
key: 'next',
|
|
4554
4584
|
value: function next(checkout, params) {
|
|
4555
|
-
this
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4585
|
+
var _this2 = this;
|
|
4586
|
+
|
|
4587
|
+
this.storageDispatcher.create(function () {
|
|
4588
|
+
var widgetSessionData = {
|
|
4589
|
+
merchant_redirect_url: _this2.getRedirectUrl(),
|
|
4590
|
+
checkout_token: checkout.token,
|
|
4591
|
+
public_key: params.public_key,
|
|
4592
|
+
gateway_id: params.gateway_id
|
|
4593
|
+
};
|
|
4594
|
+
_this2.storageDispatcher.push({ intent: StorageDataIntent.WIDGET_SESSION, data: widgetSessionData }, {
|
|
4595
|
+
onSuccess: function onSuccess() {
|
|
4596
|
+
var checkoutUri = _this2.getCheckoutUri(checkout.link);
|
|
4597
|
+
Zip.Checkout.init({
|
|
4598
|
+
checkoutUri: checkoutUri,
|
|
4599
|
+
redirect: true
|
|
4600
|
+
});
|
|
4601
|
+
},
|
|
4602
|
+
onError: function onError() {
|
|
4603
|
+
console.error('Error initializing Zip Checkout');
|
|
4604
|
+
}
|
|
4605
|
+
});
|
|
4567
4606
|
});
|
|
4568
4607
|
}
|
|
4569
4608
|
// for backward compatibility
|
|
@@ -5627,12 +5666,13 @@
|
|
|
5627
5666
|
value: function load(container) {
|
|
5628
5667
|
var _this2 = this;
|
|
5629
5668
|
|
|
5669
|
+
var _a;
|
|
5630
5670
|
if (!window.Promise) {
|
|
5631
5671
|
// Given that this library does not rely in any polyfill for promises, and this integration depends on them, we early return if Promises are not supported for the browser (like I.E. 11).
|
|
5632
5672
|
this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, null);
|
|
5633
|
-
return;
|
|
5673
|
+
return Promise.resolve();
|
|
5634
5674
|
}
|
|
5635
|
-
var buttonId = container.getElement().id || '';
|
|
5675
|
+
var buttonId = ((_a = container.getElement()) === null || _a === void 0 ? void 0 : _a.id) || '';
|
|
5636
5676
|
var paypalScript = document.createElement("script");
|
|
5637
5677
|
paypalScript.src = "https://www.paypal.com/sdk/js?client-id=" + this.publicKey + "¤cy=" + this.meta.currency + (this.meta.pay_later === true ? '&enable-funding=paylater&disable-funding=card' : "&disable-funding=credit,card") + (!this.meta.capture ? "&intent=authorize" : '');
|
|
5638
5678
|
paypalScript.async = true;
|
|
@@ -5660,17 +5700,20 @@
|
|
|
5660
5700
|
_this2.eventEmitter.emit(WALLET_EVENT.UPDATE, parsedCallbackData);
|
|
5661
5701
|
});
|
|
5662
5702
|
}, onApprove: function onApprove(data) {
|
|
5663
|
-
|
|
5703
|
+
_this2.pendingApprovalPromise = _this2.pendingApprovalPromise || new Promise(function (resolve, reject) {
|
|
5664
5704
|
return _this2.eventEmitter.emit(WALLET_EVENT.PAYMENT_METHOD_SELECTED, {
|
|
5665
5705
|
data: { payment_method_id: data.orderID, customer: { payment_source: { external_payer_id: data.payerID } } },
|
|
5666
5706
|
onSuccess: function onSuccess() {
|
|
5667
|
-
|
|
5707
|
+
_this2.pendingApprovalPromise = undefined;
|
|
5708
|
+
resolve(true);
|
|
5668
5709
|
},
|
|
5669
5710
|
onError: function onError(err) {
|
|
5670
|
-
|
|
5711
|
+
_this2.pendingApprovalPromise = undefined;
|
|
5712
|
+
reject(err);
|
|
5671
5713
|
}
|
|
5672
5714
|
});
|
|
5673
5715
|
});
|
|
5716
|
+
return _this2.pendingApprovalPromise;
|
|
5674
5717
|
}, onError: function onError(err) {
|
|
5675
5718
|
// Error handling so that paypal does not throw an uncaught error
|
|
5676
5719
|
// We're already handling errors and notifying Merchants at "wallet-buttons.ts"
|
|
@@ -5680,7 +5723,7 @@
|
|
|
5680
5723
|
}
|
|
5681
5724
|
};
|
|
5682
5725
|
document.head.appendChild(paypalScript);
|
|
5683
|
-
return;
|
|
5726
|
+
return Promise.resolve();
|
|
5684
5727
|
}
|
|
5685
5728
|
}, {
|
|
5686
5729
|
key: "update",
|
|
@@ -6500,25 +6543,28 @@
|
|
|
6500
6543
|
value: function onPaymentAuthorized(paymentData) {
|
|
6501
6544
|
var _this4 = this;
|
|
6502
6545
|
|
|
6503
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
6546
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
6504
6547
|
var billingAddressLine1 = (_c = (_b = (_a = paymentData.paymentMethodData) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.billingAddress) === null || _c === void 0 ? void 0 : _c.address1;
|
|
6505
6548
|
var billingAddressLine2 = (_f = (_e = (_d = paymentData.paymentMethodData) === null || _d === void 0 ? void 0 : _d.info) === null || _e === void 0 ? void 0 : _e.billingAddress) === null || _f === void 0 ? void 0 : _f.address2;
|
|
6506
6549
|
var shippingAddressLine1 = (_g = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _g === void 0 ? void 0 : _g.address1;
|
|
6507
6550
|
var shippingAddressLine2 = (_h = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _h === void 0 ? void 0 : _h.address2;
|
|
6508
6551
|
var shippingOptionMethod = (_j = this.selectedShippingOption) === null || _j === void 0 ? void 0 : _j.type;
|
|
6552
|
+
var shippingAddressCountry = (_k = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _k === void 0 ? void 0 : _k.countryCode;
|
|
6553
|
+
var shippingAddressCity = (_l = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _l === void 0 ? void 0 : _l.locality;
|
|
6554
|
+
var shippingAddressPostCode = (_m = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _m === void 0 ? void 0 : _m.postalCode;
|
|
6555
|
+
var shippingAddressState = (_o = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _o === void 0 ? void 0 : _o.administrativeArea;
|
|
6556
|
+
var shippingContactFirstName = (_p = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _p === void 0 ? void 0 : _p.name;
|
|
6557
|
+
var shippingContactEmail = paymentData === null || paymentData === void 0 ? void 0 : paymentData.email;
|
|
6558
|
+
var shippingContactPhone = (_q = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _q === void 0 ? void 0 : _q.phoneNumber;
|
|
6509
6559
|
return new Promise(function (resolve) {
|
|
6510
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p
|
|
6560
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
6511
6561
|
return _this4.eventEmitter.emit(WALLET_EVENT.PAYMENT_METHOD_SELECTED, {
|
|
6512
6562
|
data: _extends({ customer: {
|
|
6513
6563
|
payment_source: _extends(_extends(_extends(_extends({ wallet_type: WALLET_TYPE.GOOGLE,
|
|
6514
6564
|
// card_name: paymentData.shippingAddress?.name, // TODO: Do we want to use this value? Point 2 at https://paydock.atlassian.net/browse/P2-7209?focusedCommentId=60202
|
|
6515
6565
|
type: paymentData.paymentMethodData.type, card_scheme: (_b = (_a = paymentData.paymentMethodData) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.cardNetwork }, billingAddressLine1 && { address_line1: billingAddressLine1 }), billingAddressLine2 && { address_line2: billingAddressLine2 }), billingAddressLine2 && { address_line2: billingAddressLine2 }), { address_country: (_e = (_d = (_c = paymentData.paymentMethodData) === null || _c === void 0 ? void 0 : _c.info) === null || _d === void 0 ? void 0 : _d.billingAddress) === null || _e === void 0 ? void 0 : _e.countryCode, address_city: (_h = (_g = (_f = paymentData.paymentMethodData) === null || _f === void 0 ? void 0 : _f.info) === null || _g === void 0 ? void 0 : _g.billingAddress) === null || _h === void 0 ? void 0 : _h.locality, address_postcode: (_l = (_k = (_j = paymentData.paymentMethodData) === null || _j === void 0 ? void 0 : _j.info) === null || _k === void 0 ? void 0 : _k.billingAddress) === null || _l === void 0 ? void 0 : _l.postalCode, address_state: (_p = (_o = (_m = paymentData.paymentMethodData) === null || _m === void 0 ? void 0 : _m.info) === null || _o === void 0 ? void 0 : _o.billingAddress) === null || _p === void 0 ? void 0 : _p.administrativeArea, ref_token: paymentData.paymentMethodData.tokenizationData.token })
|
|
6516
6566
|
} }, _this4.isShippingRequired() && {
|
|
6517
|
-
shipping: _extends(_extends(_extends(_extends(_extends({}, shippingOptionMethod && { method: shippingOptionMethod }), _this4.hasShippingOptions() && { options: _this4.meta.shipping_options }), shippingAddressLine1 && { address_line1: shippingAddressLine1 }), shippingAddressLine2 && { address_line2: shippingAddressLine2 }), { address_country:
|
|
6518
|
-
first_name: (_u = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _u === void 0 ? void 0 : _u.name,
|
|
6519
|
-
email: paymentData === null || paymentData === void 0 ? void 0 : paymentData.email,
|
|
6520
|
-
phone: (_v = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _v === void 0 ? void 0 : _v.phoneNumber
|
|
6521
|
-
} })
|
|
6567
|
+
shipping: _extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends({}, shippingOptionMethod && { method: shippingOptionMethod }), _this4.hasShippingOptions() && { options: _this4.meta.shipping_options }), shippingAddressLine1 && { address_line1: shippingAddressLine1 }), shippingAddressLine2 && { address_line2: shippingAddressLine2 }), shippingAddressCountry && { address_country: shippingAddressCountry }), shippingAddressCity && { address_city: shippingAddressCity }), shippingAddressPostCode && { address_postcode: shippingAddressPostCode }), shippingAddressState && { address_state: shippingAddressState }), { contact: _extends(_extends(_extends({}, shippingContactFirstName && { first_name: shippingContactFirstName }), shippingContactEmail && { email: shippingContactEmail }), shippingContactPhone && { phone: shippingContactPhone }) })
|
|
6522
6568
|
}),
|
|
6523
6569
|
onSuccess: function onSuccess() {
|
|
6524
6570
|
return resolve({ transactionState: 'SUCCESS' });
|
|
@@ -6864,8 +6910,11 @@
|
|
|
6864
6910
|
createClass(AfterPayWalletService, [{
|
|
6865
6911
|
key: 'load',
|
|
6866
6912
|
value: function load(container) {
|
|
6867
|
-
this
|
|
6868
|
-
|
|
6913
|
+
var _this2 = this;
|
|
6914
|
+
|
|
6915
|
+
this.storageDispatcher.create(function () {
|
|
6916
|
+
return _this2.mount(container);
|
|
6917
|
+
});
|
|
6869
6918
|
}
|
|
6870
6919
|
}, {
|
|
6871
6920
|
key: 'setEnv',
|
|
@@ -6877,14 +6926,14 @@
|
|
|
6877
6926
|
}, {
|
|
6878
6927
|
key: 'mount',
|
|
6879
6928
|
value: function mount(container) {
|
|
6880
|
-
var
|
|
6929
|
+
var _this3 = this;
|
|
6881
6930
|
|
|
6882
6931
|
var _a, _b, _c, _d;
|
|
6883
6932
|
var customStyles = {};
|
|
6884
6933
|
if (((_a = this.meta) === null || _a === void 0 ? void 0 : _a.style) && _typeof((_b = this.meta) === null || _b === void 0 ? void 0 : _b.style) === 'object') customStyles = JSON.parse(JSON.stringify(((_c = this.meta) === null || _c === void 0 ? void 0 : _c.style['afterpay']) || ((_d = this.meta) === null || _d === void 0 ? void 0 : _d.style)));
|
|
6885
6934
|
var afterpayButton = this.getButton(customStyles);
|
|
6886
6935
|
afterpayButton.onclick = function () {
|
|
6887
|
-
return
|
|
6936
|
+
return _this3.onAfterPayButtonClicked();
|
|
6888
6937
|
};
|
|
6889
6938
|
var buttonWalletStyle = this.getButtonStyle(customStyles);
|
|
6890
6939
|
container.getElement().appendChild(afterpayButton);
|
|
@@ -6893,40 +6942,46 @@
|
|
|
6893
6942
|
}, {
|
|
6894
6943
|
key: 'onAfterPayButtonClicked',
|
|
6895
6944
|
value: function onAfterPayButtonClicked() {
|
|
6896
|
-
var
|
|
6945
|
+
var _this4 = this;
|
|
6897
6946
|
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6947
|
+
var _a, _b;
|
|
6948
|
+
var afterpayJS = document.createElement('script');
|
|
6949
|
+
var countryCode = (_a = this.meta) === null || _a === void 0 ? void 0 : _a.country;
|
|
6950
|
+
afterpayJS.type = 'text/javascript';
|
|
6951
|
+
afterpayJS.src = ((_b = this.meta) === null || _b === void 0 ? void 0 : _b.gateway_mode) === 'live' ? 'https://portal.afterpay.com/afterpay.js' : 'https://portal.sandbox.afterpay.com/afterpay.js';
|
|
6952
|
+
afterpayJS.async = true;
|
|
6953
|
+
afterpayJS.defer = true;
|
|
6954
|
+
afterpayJS.onload = function () {
|
|
6955
|
+
window.AfterPay.initialize({ countryCode: countryCode });
|
|
6956
|
+
_this4.storageDispatcher.push({ intent: StorageDataIntent.WIDGET_SESSION, data: { token: _this4.token } }, {
|
|
6957
|
+
onSuccess: function onSuccess() {
|
|
6958
|
+
_this4.getCheckoutSession().then(function (response) {
|
|
6959
|
+
window.AfterPay.redirect({
|
|
6960
|
+
token: response.ref_token
|
|
6961
|
+
});
|
|
6962
|
+
}).catch(function (err) {
|
|
6963
|
+
window.AfterPay.close();
|
|
6964
|
+
_this4.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {
|
|
6965
|
+
err: err
|
|
6966
|
+
});
|
|
6912
6967
|
});
|
|
6913
|
-
}
|
|
6968
|
+
},
|
|
6969
|
+
onError: function onError() {
|
|
6970
|
+
console.error('Error initializing Afterpay wallet');
|
|
6914
6971
|
window.AfterPay.close();
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
document.head.appendChild(afterpayJS);
|
|
6921
|
-
});
|
|
6972
|
+
_this4.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {});
|
|
6973
|
+
}
|
|
6974
|
+
});
|
|
6975
|
+
};
|
|
6976
|
+
document.head.appendChild(afterpayJS);
|
|
6922
6977
|
}
|
|
6923
6978
|
}, {
|
|
6924
6979
|
key: 'getCheckoutSession',
|
|
6925
6980
|
value: function getCheckoutSession() {
|
|
6926
|
-
var
|
|
6981
|
+
var _this5 = this;
|
|
6927
6982
|
|
|
6928
6983
|
return new Promise(function (resolve, reject) {
|
|
6929
|
-
return
|
|
6984
|
+
return _this5.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
|
|
6930
6985
|
data: {
|
|
6931
6986
|
request_type: 'CREATE_SESSION',
|
|
6932
6987
|
wallet_type: WALLET_TYPE.AFTERPAY
|
|
@@ -7053,7 +7108,7 @@
|
|
|
7053
7108
|
* @param {string} [type] Type of the Shipping Option. Values can be 'SHIPPING' or 'PICKUP'. Required.
|
|
7054
7109
|
*/
|
|
7055
7110
|
/**
|
|
7056
|
-
* Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal)
|
|
7111
|
+
* Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay, Google Pay™ and Apple Pay via Stripe, Flypay, Paypal, Afterpay)
|
|
7057
7112
|
* @constructor
|
|
7058
7113
|
*
|
|
7059
7114
|
* @example
|