@paydock/client-sdk 1.10.60-beta → 1.10.73
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 +136 -13
- package/bundles/widget.umd.js +689 -68
- package/bundles/widget.umd.min.js +1 -1
- package/lib/api/api-charge-internal.d.ts +52 -0
- package/lib/api/api-charge-internal.js +12 -1
- package/lib/api/api-charge-internal.js.map +1 -1
- package/lib/canvas-3ds/canvas-3ds.d.ts +17 -1
- package/lib/canvas-3ds/canvas-3ds.js +30 -4
- package/lib/canvas-3ds/canvas-3ds.js.map +1 -1
- package/lib/canvas-3ds/services/gpayments-service.d.ts +42 -0
- package/lib/canvas-3ds/services/gpayments-service.js +162 -0
- package/lib/canvas-3ds/services/gpayments-service.js.map +1 -0
- package/lib/canvas-3ds/services/index.d.ts +1 -0
- package/lib/canvas-3ds/services/index.js +2 -0
- package/lib/canvas-3ds/services/index.js.map +1 -0
- package/lib/canvas-3ds/services/standalone3ds-service.d.ts +21 -0
- package/lib/canvas-3ds/services/standalone3ds-service.js +32 -0
- package/lib/canvas-3ds/services/standalone3ds-service.js.map +1 -0
- package/lib/components/param.d.ts +19 -3
- package/lib/components/param.js +2 -0
- package/lib/components/param.js.map +1 -1
- package/lib/helper/access-token.d.ts +1 -0
- package/lib/helper/access-token.js +8 -0
- package/lib/helper/access-token.js.map +1 -1
- package/lib/wallet-buttons/apple.wallet-service.d.ts +13 -1
- package/lib/wallet-buttons/apple.wallet-service.js +67 -41
- package/lib/wallet-buttons/apple.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/flypay.wallet-service.js +1 -4
- package/lib/wallet-buttons/flypay.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/google.wallet-service.d.ts +29 -0
- package/lib/wallet-buttons/google.wallet-service.js +240 -0
- package/lib/wallet-buttons/google.wallet-service.js.map +1 -0
- package/lib/wallet-buttons/interfaces.d.ts +4 -1
- package/lib/wallet-buttons/mastercard.wallet-service.js +7 -1
- package/lib/wallet-buttons/mastercard.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/paypal.wallet-service.js +3 -3
- package/lib/wallet-buttons/paypal.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/stripe.wallet-service.d.ts +1 -0
- package/lib/wallet-buttons/stripe.wallet-service.js +9 -3
- package/lib/wallet-buttons/stripe.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/wallet-buttons.d.ts +44 -13
- package/lib/wallet-buttons/wallet-buttons.js +37 -12
- package/lib/wallet-buttons/wallet-buttons.js.map +1 -1
- package/lib/wallet-buttons/wallet-service.d.ts +2 -1
- package/lib/wallet-buttons/wallet-service.js.map +1 -1
- package/package.json +2 -1
- package/slate.md +83 -0
package/bundles/widget.umd.js
CHANGED
|
@@ -150,6 +150,16 @@
|
|
|
150
150
|
};
|
|
151
151
|
}();
|
|
152
152
|
|
|
153
|
+
var toConsumableArray = function (arr) {
|
|
154
|
+
if (Array.isArray(arr)) {
|
|
155
|
+
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
|
156
|
+
|
|
157
|
+
return arr2;
|
|
158
|
+
} else {
|
|
159
|
+
return Array.from(arr);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
153
163
|
var ENV = {
|
|
154
164
|
SANDBOX: 'sandbox',
|
|
155
165
|
SANDBOX_KOVENA: 'sandbox-kovena',
|
|
@@ -437,6 +447,8 @@
|
|
|
437
447
|
(function (WALLET_TYPE) {
|
|
438
448
|
WALLET_TYPE["GOOGLE"] = "google";
|
|
439
449
|
WALLET_TYPE["APPLE"] = "apple";
|
|
450
|
+
WALLET_TYPE["FLYPAY"] = "flypay";
|
|
451
|
+
WALLET_TYPE["PAYPAL"] = "paypal";
|
|
440
452
|
})(WALLET_TYPE || (WALLET_TYPE = {}));
|
|
441
453
|
|
|
442
454
|
/**
|
|
@@ -5043,10 +5055,7 @@
|
|
|
5043
5055
|
var _this3 = this;
|
|
5044
5056
|
|
|
5045
5057
|
this.event.on(FLYPAY_EVENT.UNAVAILABLE, widgetId, function (_data) {
|
|
5046
|
-
return _this3.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE,
|
|
5047
|
-
event: WALLET_EVENT.UNAVAILABLE,
|
|
5048
|
-
data: null
|
|
5049
|
-
});
|
|
5058
|
+
return _this3.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, null);
|
|
5050
5059
|
});
|
|
5051
5060
|
this.event.on(FLYPAY_EVENT.START_LOADING, widgetId, function (_data) {
|
|
5052
5061
|
return _this3.background.initControl();
|
|
@@ -5131,7 +5140,7 @@
|
|
|
5131
5140
|
|
|
5132
5141
|
if (!window.Promise) {
|
|
5133
5142
|
// 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).
|
|
5134
|
-
this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE,
|
|
5143
|
+
this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, null);
|
|
5135
5144
|
return;
|
|
5136
5145
|
}
|
|
5137
5146
|
var buttonId = container.getElement().id || '';
|
|
@@ -5178,7 +5187,7 @@
|
|
|
5178
5187
|
// We're already handling errors and notifying Merchants at "wallet-buttons.ts"
|
|
5179
5188
|
} })).render("#" + buttonId);
|
|
5180
5189
|
} else {
|
|
5181
|
-
_this2.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE,
|
|
5190
|
+
_this2.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, null);
|
|
5182
5191
|
}
|
|
5183
5192
|
};
|
|
5184
5193
|
document.head.appendChild(paypalScript);
|
|
@@ -5220,7 +5229,7 @@
|
|
|
5220
5229
|
label: data.selected_shipping_option.label,
|
|
5221
5230
|
amount: data.selected_shipping_option.amount.value,
|
|
5222
5231
|
currency: data.selected_shipping_option.amount.currency_code,
|
|
5223
|
-
type: (
|
|
5232
|
+
type: (_a = data.selected_shipping_option) === null || _a === void 0 ? void 0 : _a.type
|
|
5224
5233
|
}
|
|
5225
5234
|
});
|
|
5226
5235
|
}
|
|
@@ -5468,7 +5477,7 @@
|
|
|
5468
5477
|
}, {
|
|
5469
5478
|
key: "mount",
|
|
5470
5479
|
value: function mount(container, availability) {
|
|
5471
|
-
if (!availability || !availability.apple_pay && !availability.google_pay) return this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE,
|
|
5480
|
+
if (!availability || !availability.apple_pay && !availability.google_pay) return this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, null);
|
|
5472
5481
|
this.createWalletButton().mount(container.getElement());
|
|
5473
5482
|
}
|
|
5474
5483
|
}, {
|
|
@@ -5477,7 +5486,7 @@
|
|
|
5477
5486
|
var _this4 = this;
|
|
5478
5487
|
|
|
5479
5488
|
this.paymentRequest.on("paymentmethod", function (event) {
|
|
5480
|
-
var _a;
|
|
5489
|
+
var _a, _b;
|
|
5481
5490
|
var _event$paymentMethod = event.paymentMethod,
|
|
5482
5491
|
id = _event$paymentMethod.id,
|
|
5483
5492
|
card = _event$paymentMethod.card,
|
|
@@ -5492,8 +5501,9 @@
|
|
|
5492
5501
|
payer_email: event.payerEmail,
|
|
5493
5502
|
payer_phone: event.payerPhone,
|
|
5494
5503
|
payment_source: {
|
|
5504
|
+
wallet_type: _this4.getWalletType((_a = card === null || card === void 0 ? void 0 : card.wallet) === null || _a === void 0 ? void 0 : _a.type),
|
|
5495
5505
|
card_name: name,
|
|
5496
|
-
type: (
|
|
5506
|
+
type: (_b = card === null || card === void 0 ? void 0 : card.wallet) === null || _b === void 0 ? void 0 : _b.type,
|
|
5497
5507
|
card_scheme: card === null || card === void 0 ? void 0 : card.brand,
|
|
5498
5508
|
card_number_last4: card === null || card === void 0 ? void 0 : card.last4,
|
|
5499
5509
|
expire_month: card === null || card === void 0 ? void 0 : card.exp_month,
|
|
@@ -5518,6 +5528,12 @@
|
|
|
5518
5528
|
});
|
|
5519
5529
|
});
|
|
5520
5530
|
}
|
|
5531
|
+
}, {
|
|
5532
|
+
key: "getWalletType",
|
|
5533
|
+
value: function getWalletType(type) {
|
|
5534
|
+
if (!type) return null;
|
|
5535
|
+
return type === 'google_pay' ? WALLET_TYPE.GOOGLE : WALLET_TYPE.APPLE;
|
|
5536
|
+
}
|
|
5521
5537
|
}]);
|
|
5522
5538
|
return StripeWalletService;
|
|
5523
5539
|
}(WalletService);
|
|
@@ -5532,6 +5548,7 @@
|
|
|
5532
5548
|
|
|
5533
5549
|
_this.gatewayName = gatewayName;
|
|
5534
5550
|
_this.eventEmitter = eventEmitter;
|
|
5551
|
+
_this.latestShippingData = {};
|
|
5535
5552
|
_this.onValidateMerchant = function (event) {
|
|
5536
5553
|
_this.getMerchantSession().then(function (merchantSession) {
|
|
5537
5554
|
_this.paymentSession.completeMerchantValidation(merchantSession);
|
|
@@ -5540,14 +5557,18 @@
|
|
|
5540
5557
|
});
|
|
5541
5558
|
};
|
|
5542
5559
|
_this.onPaymentAuthorized = function (event) {
|
|
5560
|
+
var _a;
|
|
5543
5561
|
var _event$payment = event.payment,
|
|
5544
5562
|
token = _event$payment.token,
|
|
5545
5563
|
billingContact = _event$payment.billingContact,
|
|
5546
5564
|
shippingContact = _event$payment.shippingContact;
|
|
5547
5565
|
|
|
5566
|
+
_this.latestShippingData.shippingContact = shippingContact;
|
|
5567
|
+
var shippingOptionMethod = (_a = _this.selectedShippingOption) === null || _a === void 0 ? void 0 : _a.type;
|
|
5548
5568
|
_this.eventEmitter.emit(WALLET_EVENT.PAYMENT_METHOD_SELECTED, {
|
|
5549
5569
|
data: _extends({ customer: {
|
|
5550
5570
|
payment_source: {
|
|
5571
|
+
wallet_type: WALLET_TYPE.APPLE,
|
|
5551
5572
|
card_name: token.paymentMethod.displayName,
|
|
5552
5573
|
type: token.paymentMethod.type,
|
|
5553
5574
|
card_scheme: token.paymentMethod.network,
|
|
@@ -5560,22 +5581,12 @@
|
|
|
5560
5581
|
ref_token: token.paymentData ? JSON.stringify(token.paymentData) : ''
|
|
5561
5582
|
}
|
|
5562
5583
|
} }, _this.meta.request_shipping && shippingContact && {
|
|
5563
|
-
shipping: {
|
|
5564
|
-
method: _this.selectedShippingMethodId,
|
|
5565
|
-
options: _this.meta.shipping_options,
|
|
5566
|
-
address_line1: shippingContact.addressLines[0],
|
|
5567
|
-
address_line2: shippingContact.addressLines[1],
|
|
5568
|
-
address_country: shippingContact.countryCode,
|
|
5569
|
-
address_city: shippingContact.locality,
|
|
5570
|
-
address_postcode: shippingContact.postalCode,
|
|
5571
|
-
address_state: shippingContact.administrativeArea,
|
|
5572
|
-
contact: {
|
|
5584
|
+
shipping: _extends(_extends(_extends({}, shippingOptionMethod && { method: shippingOptionMethod }), _this.hasShippingOptions() && { options: _this.meta.shipping_options }), { address_line1: shippingContact.addressLines[0], address_line2: shippingContact.addressLines[1], address_country: shippingContact.countryCode, address_city: shippingContact.locality, address_postcode: shippingContact.postalCode, address_state: shippingContact.administrativeArea, contact: {
|
|
5573
5585
|
first_name: shippingContact.givenName,
|
|
5574
5586
|
last_name: shippingContact.familyName,
|
|
5575
5587
|
email: shippingContact.emailAddress,
|
|
5576
5588
|
phone: shippingContact.phoneNumber
|
|
5577
|
-
}
|
|
5578
|
-
}
|
|
5589
|
+
} })
|
|
5579
5590
|
}),
|
|
5580
5591
|
onSuccess: function onSuccess() {
|
|
5581
5592
|
return _this.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS);
|
|
@@ -5586,19 +5597,16 @@
|
|
|
5586
5597
|
});
|
|
5587
5598
|
};
|
|
5588
5599
|
_this.onShippingContactSelected = function (event) {
|
|
5589
|
-
|
|
5600
|
+
_this.latestShippingData.shippingContact = event.shippingContact;
|
|
5601
|
+
var parsedCallbackData = _this.parseUpdateData(_this.latestShippingData);
|
|
5590
5602
|
_this.eventEmitter.emit(WALLET_EVENT.UPDATE, parsedCallbackData);
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
type: "final"
|
|
5595
|
-
} }, _this.meta.request_shipping && _this.meta.shipping_options && {
|
|
5596
|
-
newShippingMethods: _this.formatShippingOptions(_this.meta.shipping_options)
|
|
5603
|
+
return new Promise(function (res, rej) {
|
|
5604
|
+
_this.latestShippingChangePromiseResolve = res;
|
|
5605
|
+
_this.latestShippingChangePromiseReject = rej;
|
|
5597
5606
|
});
|
|
5598
|
-
_this.paymentSession.completeShippingContactSelection(update);
|
|
5599
5607
|
};
|
|
5600
5608
|
_this.onShippingMethodSelected = function (event) {
|
|
5601
|
-
_this.
|
|
5609
|
+
_this.latestShippingData.shippingMethod = event.shippingMethod;
|
|
5602
5610
|
var update = {
|
|
5603
5611
|
newTotal: {
|
|
5604
5612
|
label: _this.meta.amount_label,
|
|
@@ -5609,16 +5617,22 @@
|
|
|
5609
5617
|
_this.paymentSession.completeShippingMethodSelection(update);
|
|
5610
5618
|
};
|
|
5611
5619
|
_this.parseUpdateData = function (data) {
|
|
5620
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5612
5621
|
// From Apple docs (https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment/1916097-shippingcontact):
|
|
5613
5622
|
// Before the user authorizes the transaction with Touch ID, Face ID, or passcode, you receive redacted address information
|
|
5614
|
-
return {
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5623
|
+
return _extends({ shipping: {
|
|
5624
|
+
address_city: (_a = data === null || data === void 0 ? void 0 : data.shippingContact) === null || _a === void 0 ? void 0 : _a.locality,
|
|
5625
|
+
address_state: (_b = data === null || data === void 0 ? void 0 : data.shippingContact) === null || _b === void 0 ? void 0 : _b.administrativeArea,
|
|
5626
|
+
address_postcode: (_c = data === null || data === void 0 ? void 0 : data.shippingContact) === null || _c === void 0 ? void 0 : _c.postalCode,
|
|
5627
|
+
address_country: (_d = data === null || data === void 0 ? void 0 : data.shippingContact) === null || _d === void 0 ? void 0 : _d.countryCode
|
|
5628
|
+
} }, (data === null || data === void 0 ? void 0 : data.shippingMethod) && {
|
|
5629
|
+
selected_shipping_option: {
|
|
5630
|
+
id: (_e = data === null || data === void 0 ? void 0 : data.shippingMethod) === null || _e === void 0 ? void 0 : _e.identifier,
|
|
5631
|
+
label: (_f = data === null || data === void 0 ? void 0 : data.shippingMethod) === null || _f === void 0 ? void 0 : _f.label,
|
|
5632
|
+
detail: (_g = data === null || data === void 0 ? void 0 : data.shippingMethod) === null || _g === void 0 ? void 0 : _g.detail,
|
|
5633
|
+
amount: (_h = data === null || data === void 0 ? void 0 : data.shippingMethod) === null || _h === void 0 ? void 0 : _h.amount
|
|
5620
5634
|
}
|
|
5621
|
-
};
|
|
5635
|
+
});
|
|
5622
5636
|
};
|
|
5623
5637
|
_this.formatShippingOptions = function (shipping_options) {
|
|
5624
5638
|
return shipping_options.map(function (o) {
|
|
@@ -5645,6 +5659,18 @@
|
|
|
5645
5659
|
var _a, _b, _c;
|
|
5646
5660
|
return ((_c = (_b = (_a = this.meta) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b[WALLET_TYPE.APPLE]) === null || _c === void 0 ? void 0 : _c.merchant) || '';
|
|
5647
5661
|
}
|
|
5662
|
+
}, {
|
|
5663
|
+
key: "isShippingRequired",
|
|
5664
|
+
value: function isShippingRequired() {
|
|
5665
|
+
var _a;
|
|
5666
|
+
return (_a = this.meta) === null || _a === void 0 ? void 0 : _a.request_shipping;
|
|
5667
|
+
}
|
|
5668
|
+
}, {
|
|
5669
|
+
key: "hasShippingOptions",
|
|
5670
|
+
value: function hasShippingOptions() {
|
|
5671
|
+
var _a, _b;
|
|
5672
|
+
return ((_a = this.meta) === null || _a === void 0 ? void 0 : _a.request_shipping) && !!((_b = this.meta) === null || _b === void 0 ? void 0 : _b.shipping_options);
|
|
5673
|
+
}
|
|
5648
5674
|
}, {
|
|
5649
5675
|
key: "load",
|
|
5650
5676
|
value: function load(container) {
|
|
@@ -5652,17 +5678,20 @@
|
|
|
5652
5678
|
|
|
5653
5679
|
if (!window.Promise) {
|
|
5654
5680
|
// 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).
|
|
5655
|
-
this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {
|
|
5681
|
+
this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, { wallet: WALLET_TYPE.APPLE });
|
|
5656
5682
|
return;
|
|
5657
5683
|
}
|
|
5658
5684
|
return this.checkAvailability().then(function (available) {
|
|
5659
5685
|
var _a;
|
|
5660
5686
|
if (!available) {
|
|
5661
|
-
_this2.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, {
|
|
5687
|
+
_this2.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, { wallet: WALLET_TYPE.APPLE });
|
|
5662
5688
|
return;
|
|
5663
5689
|
}
|
|
5664
5690
|
// Store default shipping option
|
|
5665
|
-
if (_this2.
|
|
5691
|
+
if (_this2.isShippingRequired() && _this2.hasShippingOptions()) {
|
|
5692
|
+
_this2.selectedShippingOption = (_a = _this2.meta) === null || _a === void 0 ? void 0 : _a.shipping_options[0];
|
|
5693
|
+
_this2.latestShippingData.shippingMethod = _this2.formatShippingOptions([_this2.selectedShippingOption])[0];
|
|
5694
|
+
}
|
|
5666
5695
|
_this2.mount(container);
|
|
5667
5696
|
}).catch(function (err) {
|
|
5668
5697
|
return console.error("Error checking ApplePay availability", err);
|
|
@@ -5671,9 +5700,25 @@
|
|
|
5671
5700
|
}, {
|
|
5672
5701
|
key: "update",
|
|
5673
5702
|
value: function update(data) {
|
|
5674
|
-
var _a, _b;
|
|
5675
|
-
if (
|
|
5676
|
-
if (
|
|
5703
|
+
var _a, _b, _c;
|
|
5704
|
+
if (!this.latestShippingChangePromiseResolve || !this.latestShippingChangePromiseReject) return;
|
|
5705
|
+
if (!data.success || !data.body) return this.latestShippingChangePromiseReject(); // TODO: check how to handle Error messages from Merchant at update() callback response
|
|
5706
|
+
var newAmount = (_a = data === null || data === void 0 ? void 0 : data.body) === null || _a === void 0 ? void 0 : _a.amount;
|
|
5707
|
+
var newShippingOptions = (_b = data === null || data === void 0 ? void 0 : data.body) === null || _b === void 0 ? void 0 : _b.shipping_options;
|
|
5708
|
+
if (newAmount) this.meta.amount = newAmount;
|
|
5709
|
+
if (newShippingOptions) {
|
|
5710
|
+
this.meta.shipping_options = newShippingOptions;
|
|
5711
|
+
this.selectedShippingOption = newShippingOptions ? newShippingOptions[0] : undefined;
|
|
5712
|
+
}
|
|
5713
|
+
var update = _extends({ newTotal: {
|
|
5714
|
+
label: (_c = this.meta) === null || _c === void 0 ? void 0 : _c.amount_label,
|
|
5715
|
+
amount: this.meta.amount.toString(),
|
|
5716
|
+
type: "final"
|
|
5717
|
+
} }, this.isShippingRequired() && this.hasShippingOptions() && {
|
|
5718
|
+
newShippingMethods: this.formatShippingOptions(this.meta.shipping_options)
|
|
5719
|
+
});
|
|
5720
|
+
this.paymentSession.completeShippingContactSelection(update);
|
|
5721
|
+
this.latestShippingChangePromiseResolve({});
|
|
5677
5722
|
}
|
|
5678
5723
|
}, {
|
|
5679
5724
|
key: "checkAvailability",
|
|
@@ -5723,9 +5768,9 @@
|
|
|
5723
5768
|
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest
|
|
5724
5769
|
if (this.meta.raw_data_initialization) {
|
|
5725
5770
|
this.meta.raw_data_initialization.total.amount = this.meta.amount.toString();
|
|
5726
|
-
if (this.
|
|
5771
|
+
if (this.isShippingRequired() && this.hasShippingOptions()) this.meta.raw_data_initialization.shippingMethods = this.formatShippingOptions(this.meta.shipping_options);
|
|
5727
5772
|
}
|
|
5728
|
-
return this.meta.raw_data_initialization ? this.meta.raw_data_initialization : _extends(_extends({ countryCode: this.meta.country.toUpperCase(), currencyCode: this.meta.currency.toUpperCase(), merchantCapabilities: ["supports3DS", "supportsCredit", "supportsDebit"], supportedNetworks: ["visa", "masterCard", "amex", "discover"], requiredBillingContactFields: ["name", "postalAddress"] }, this.
|
|
5773
|
+
return this.meta.raw_data_initialization ? this.meta.raw_data_initialization : _extends(_extends({ countryCode: this.meta.country.toUpperCase(), currencyCode: this.meta.currency.toUpperCase(), merchantCapabilities: ["supports3DS", "supportsCredit", "supportsDebit"], supportedNetworks: ["visa", "masterCard", "amex", "discover"], requiredBillingContactFields: ["name", "postalAddress"] }, this.isShippingRequired() && _extends({ requiredShippingContactFields: ["postalAddress", "name", "phone", "email"] }, this.hasShippingOptions() && {
|
|
5729
5774
|
shippingMethods: this.formatShippingOptions(this.meta.shipping_options)
|
|
5730
5775
|
})), { total: {
|
|
5731
5776
|
label: this.meta.amount_label,
|
|
@@ -5740,7 +5785,7 @@
|
|
|
5740
5785
|
|
|
5741
5786
|
return new Promise(function (resolve, reject) {
|
|
5742
5787
|
return _this5.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
|
|
5743
|
-
data: _extends({ request_type: "CREATE_SESSION", wallet_type: WALLET_TYPE.APPLE, session_id: window.location.hostname }, _this5.
|
|
5788
|
+
data: _extends({ request_type: "CREATE_SESSION", wallet_type: WALLET_TYPE.APPLE, session_id: window.location.hostname }, _this5.isShippingRequired() && { request_shipping: _this5.meta.request_shipping }),
|
|
5744
5789
|
onSuccess: function onSuccess(res) {
|
|
5745
5790
|
return resolve(res);
|
|
5746
5791
|
},
|
|
@@ -5760,6 +5805,283 @@
|
|
|
5760
5805
|
return AppleWalletService;
|
|
5761
5806
|
}(WalletService);
|
|
5762
5807
|
|
|
5808
|
+
var GoogleWalletService = function (_WalletService) {
|
|
5809
|
+
inherits(GoogleWalletService, _WalletService);
|
|
5810
|
+
|
|
5811
|
+
function GoogleWalletService(publicKey, meta, gatewayName, eventEmitter) {
|
|
5812
|
+
classCallCheck(this, GoogleWalletService);
|
|
5813
|
+
|
|
5814
|
+
var _this = possibleConstructorReturn(this, (GoogleWalletService.__proto__ || Object.getPrototypeOf(GoogleWalletService)).call(this, publicKey, meta));
|
|
5815
|
+
|
|
5816
|
+
_this.gatewayName = gatewayName;
|
|
5817
|
+
_this.eventEmitter = eventEmitter;
|
|
5818
|
+
_this.parseUpdateData = function (data) {
|
|
5819
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5820
|
+
var shippingOption = (_b = (_a = _this.meta) === null || _a === void 0 ? void 0 : _a.shipping_options) === null || _b === void 0 ? void 0 : _b.find(function (o) {
|
|
5821
|
+
var _a;return o.id === ((_a = data === null || data === void 0 ? void 0 : data.shippingOptionData) === null || _a === void 0 ? void 0 : _a.id);
|
|
5822
|
+
});
|
|
5823
|
+
return _extends({ shipping: {
|
|
5824
|
+
address_city: (_c = data.shippingAddress) === null || _c === void 0 ? void 0 : _c.locality,
|
|
5825
|
+
address_state: (_d = data.shippingAddress) === null || _d === void 0 ? void 0 : _d.administrativeArea,
|
|
5826
|
+
address_postcode: (_e = data === null || data === void 0 ? void 0 : data.shippingAddress) === null || _e === void 0 ? void 0 : _e.postalCode,
|
|
5827
|
+
address_country: (_f = data === null || data === void 0 ? void 0 : data.shippingAddress) === null || _f === void 0 ? void 0 : _f.countryCode
|
|
5828
|
+
} }, shippingOption && {
|
|
5829
|
+
selected_shipping_option: {
|
|
5830
|
+
id: shippingOption === null || shippingOption === void 0 ? void 0 : shippingOption.id,
|
|
5831
|
+
label: shippingOption === null || shippingOption === void 0 ? void 0 : shippingOption.label,
|
|
5832
|
+
detail: shippingOption === null || shippingOption === void 0 ? void 0 : shippingOption.detail,
|
|
5833
|
+
type: shippingOption === null || shippingOption === void 0 ? void 0 : shippingOption.type
|
|
5834
|
+
}
|
|
5835
|
+
});
|
|
5836
|
+
};
|
|
5837
|
+
_this.formatShippingOptions = function (shipping_options) {
|
|
5838
|
+
return shipping_options.map(function (option) {
|
|
5839
|
+
return {
|
|
5840
|
+
id: option.id,
|
|
5841
|
+
label: option.label,
|
|
5842
|
+
description: (option === null || option === void 0 ? void 0 : option.detail) || ''
|
|
5843
|
+
};
|
|
5844
|
+
});
|
|
5845
|
+
};
|
|
5846
|
+
_this.eventEmitter = eventEmitter;
|
|
5847
|
+
return _this;
|
|
5848
|
+
}
|
|
5849
|
+
|
|
5850
|
+
createClass(GoogleWalletService, [{
|
|
5851
|
+
key: "getGatewayName",
|
|
5852
|
+
value: function getGatewayName() {
|
|
5853
|
+
return this.gatewayName;
|
|
5854
|
+
}
|
|
5855
|
+
}, {
|
|
5856
|
+
key: "getMerchantId",
|
|
5857
|
+
value: function getMerchantId() {
|
|
5858
|
+
var _a, _b, _c;
|
|
5859
|
+
return (_c = (_b = (_a = this.meta) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b[WALLET_TYPE.GOOGLE]) === null || _c === void 0 ? void 0 : _c.merchant;
|
|
5860
|
+
}
|
|
5861
|
+
}, {
|
|
5862
|
+
key: "isShippingRequired",
|
|
5863
|
+
value: function isShippingRequired() {
|
|
5864
|
+
return this.meta.request_shipping;
|
|
5865
|
+
}
|
|
5866
|
+
}, {
|
|
5867
|
+
key: "hasShippingOptions",
|
|
5868
|
+
value: function hasShippingOptions() {
|
|
5869
|
+
return this.meta.request_shipping && !!this.meta.shipping_options;
|
|
5870
|
+
}
|
|
5871
|
+
}, {
|
|
5872
|
+
key: "load",
|
|
5873
|
+
value: function load(container) {
|
|
5874
|
+
var _this2 = this;
|
|
5875
|
+
|
|
5876
|
+
if (!window.Promise) {
|
|
5877
|
+
// 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).
|
|
5878
|
+
this.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, { wallet: WALLET_TYPE.GOOGLE });
|
|
5879
|
+
return;
|
|
5880
|
+
}
|
|
5881
|
+
return new Promise(function (resolve, reject) {
|
|
5882
|
+
var googlePayJs = document.createElement("script");
|
|
5883
|
+
googlePayJs.type = "text/javascript";
|
|
5884
|
+
googlePayJs.src = "https://pay.google.com/gp/p/js/pay.js";
|
|
5885
|
+
googlePayJs.async = true;
|
|
5886
|
+
googlePayJs.onload = function () {
|
|
5887
|
+
var _a, _b, _c;
|
|
5888
|
+
if (!window.google) {
|
|
5889
|
+
_this2.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, { wallet: WALLET_TYPE.GOOGLE });
|
|
5890
|
+
reject();
|
|
5891
|
+
return;
|
|
5892
|
+
}
|
|
5893
|
+
// Store default shipping option
|
|
5894
|
+
if (_this2.isShippingRequired() && _this2.hasShippingOptions()) {
|
|
5895
|
+
_this2.selectedShippingOption = (_a = _this2.meta) === null || _a === void 0 ? void 0 : _a.shipping_options[0];
|
|
5896
|
+
}
|
|
5897
|
+
_this2.paymentsClient = new google.payments.api.PaymentsClient(_extends({ merchantInfo: _extends(_extends({}, ((_b = _this2.meta) === null || _b === void 0 ? void 0 : _b.merchant_name) ? { merchantName: (_c = _this2.meta) === null || _c === void 0 ? void 0 : _c.merchant_name } : {}), { merchantId: _this2.getMerchantId() }), paymentDataCallbacks: _extends({ onPaymentAuthorized: function onPaymentAuthorized(paymentData) {
|
|
5898
|
+
return _this2.onPaymentAuthorized(paymentData);
|
|
5899
|
+
} }, _this2.isShippingRequired() && {
|
|
5900
|
+
onPaymentDataChanged: function onPaymentDataChanged(intermediatePaymentData) {
|
|
5901
|
+
return _this2.onPaymentDataChanged(intermediatePaymentData);
|
|
5902
|
+
}
|
|
5903
|
+
}) }, _this2.env !== ENV.PROD ? { environment: "TEST" } : { environment: "PRODUCTION" }));
|
|
5904
|
+
_this2.checkAvailability().then(function (available) {
|
|
5905
|
+
if (!available) {
|
|
5906
|
+
_this2.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, { wallet: WALLET_TYPE.GOOGLE });
|
|
5907
|
+
reject();
|
|
5908
|
+
return;
|
|
5909
|
+
}
|
|
5910
|
+
_this2.mount(container);
|
|
5911
|
+
resolve();
|
|
5912
|
+
});
|
|
5913
|
+
};
|
|
5914
|
+
document.head.appendChild(googlePayJs);
|
|
5915
|
+
});
|
|
5916
|
+
}
|
|
5917
|
+
}, {
|
|
5918
|
+
key: "update",
|
|
5919
|
+
value: function update(data) {
|
|
5920
|
+
var _a, _b, _c, _d;
|
|
5921
|
+
if (!this.latestShippingChangePromiseResolve || !this.latestShippingChangePromiseReject) return;
|
|
5922
|
+
if (!data.success) return this.latestShippingChangePromiseReject(); // TODO: check how to handle Error messages from Merchant at update() callback response
|
|
5923
|
+
var newAmount = ((_a = data === null || data === void 0 ? void 0 : data.body) === null || _a === void 0 ? void 0 : _a.amount) || this.meta.amount;
|
|
5924
|
+
var newShippingOptions = ((_b = data === null || data === void 0 ? void 0 : data.body) === null || _b === void 0 ? void 0 : _b.shipping_options) || this.meta.shipping_options;
|
|
5925
|
+
if (newAmount) this.meta.amount = newAmount;
|
|
5926
|
+
if (newShippingOptions) {
|
|
5927
|
+
this.meta.shipping_options = newShippingOptions;
|
|
5928
|
+
this.selectedShippingOption = newShippingOptions ? newShippingOptions[0] : undefined;
|
|
5929
|
+
}
|
|
5930
|
+
var paymentDataRequestUpdate = _extends({ newTransactionInfo: {
|
|
5931
|
+
totalPriceStatus: "FINAL",
|
|
5932
|
+
totalPriceLabel: this.meta.amount_label,
|
|
5933
|
+
totalPrice: (_c = this.meta.amount) === null || _c === void 0 ? void 0 : _c.toString(),
|
|
5934
|
+
currencyCode: this.meta.currency.toUpperCase(),
|
|
5935
|
+
countryCode: this.meta.country.toUpperCase()
|
|
5936
|
+
} }, this.isShippingRequired() && this.hasShippingOptions() && {
|
|
5937
|
+
newShippingOptionParameters: {
|
|
5938
|
+
defaultSelectedOptionId: (_d = this.selectedShippingOption) === null || _d === void 0 ? void 0 : _d.id,
|
|
5939
|
+
shippingOptions: this.formatShippingOptions(this.meta.shipping_options)
|
|
5940
|
+
}
|
|
5941
|
+
});
|
|
5942
|
+
this.latestShippingChangePromiseResolve(paymentDataRequestUpdate);
|
|
5943
|
+
}
|
|
5944
|
+
}, {
|
|
5945
|
+
key: "checkAvailability",
|
|
5946
|
+
value: function checkAvailability() {
|
|
5947
|
+
return this.paymentsClient.isReadyToPay(this.createRequest()).then(function (response) {
|
|
5948
|
+
return !!response.result;
|
|
5949
|
+
}).catch(function (err) {
|
|
5950
|
+
console.error("Error checking GooglePay availability", err);
|
|
5951
|
+
return false;
|
|
5952
|
+
});
|
|
5953
|
+
}
|
|
5954
|
+
}, {
|
|
5955
|
+
key: "mount",
|
|
5956
|
+
value: function mount(container) {
|
|
5957
|
+
var _this3 = this;
|
|
5958
|
+
|
|
5959
|
+
container.getElement().appendChild(this.paymentsClient.createButton({
|
|
5960
|
+
buttonSizeMode: "fill",
|
|
5961
|
+
onClick: function onClick() {
|
|
5962
|
+
return _this3.loadPaymentData();
|
|
5963
|
+
}
|
|
5964
|
+
}));
|
|
5965
|
+
}
|
|
5966
|
+
}, {
|
|
5967
|
+
key: "loadPaymentData",
|
|
5968
|
+
value: function loadPaymentData() {
|
|
5969
|
+
this.paymentsClient.loadPaymentData(this.createPaymentDataRequest())
|
|
5970
|
+
// .then((paymentData) => {
|
|
5971
|
+
// // if using gateway tokenization, pass this token without modification
|
|
5972
|
+
// // this.paymentToken = paymentData.paymentMethodData.tokenizationData.token;
|
|
5973
|
+
// })
|
|
5974
|
+
.catch(function () {
|
|
5975
|
+
console.error('Error while loading payment data');
|
|
5976
|
+
});
|
|
5977
|
+
}
|
|
5978
|
+
}, {
|
|
5979
|
+
key: "onPaymentAuthorized",
|
|
5980
|
+
value: function onPaymentAuthorized(paymentData) {
|
|
5981
|
+
var _this4 = this;
|
|
5982
|
+
|
|
5983
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
5984
|
+
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;
|
|
5985
|
+
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;
|
|
5986
|
+
var shippingAddressLine1 = (_g = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _g === void 0 ? void 0 : _g.address1;
|
|
5987
|
+
var shippingAddressLine2 = (_h = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _h === void 0 ? void 0 : _h.address2;
|
|
5988
|
+
var shippingOptionMethod = (_j = this.selectedShippingOption) === null || _j === void 0 ? void 0 : _j.type;
|
|
5989
|
+
return new Promise(function (resolve) {
|
|
5990
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
5991
|
+
return _this4.eventEmitter.emit(WALLET_EVENT.PAYMENT_METHOD_SELECTED, {
|
|
5992
|
+
data: _extends({ customer: {
|
|
5993
|
+
payment_source: _extends(_extends(_extends(_extends({ wallet_type: WALLET_TYPE.GOOGLE, card_name: (_a = paymentData.paymentMethodData) === null || _a === void 0 ? void 0 : _a.description, type: paymentData.paymentMethodData.type, card_scheme: (_c = (_b = paymentData.paymentMethodData) === null || _b === void 0 ? void 0 : _b.info) === null || _c === void 0 ? void 0 : _c.cardNetwork }, billingAddressLine1 && { address_line1: billingAddressLine1 }), billingAddressLine2 && { address_line2: billingAddressLine2 }), billingAddressLine2 && { address_line2: billingAddressLine2 }), { address_country: (_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.countryCode, address_city: (_j = (_h = (_g = paymentData.paymentMethodData) === null || _g === void 0 ? void 0 : _g.info) === null || _h === void 0 ? void 0 : _h.billingAddress) === null || _j === void 0 ? void 0 : _j.locality, address_postcode: (_m = (_l = (_k = paymentData.paymentMethodData) === null || _k === void 0 ? void 0 : _k.info) === null || _l === void 0 ? void 0 : _l.billingAddress) === null || _m === void 0 ? void 0 : _m.postalCode, address_state: (_q = (_p = (_o = paymentData.paymentMethodData) === null || _o === void 0 ? void 0 : _o.info) === null || _p === void 0 ? void 0 : _p.billingAddress) === null || _q === void 0 ? void 0 : _q.administrativeArea, ref_token: paymentData.paymentMethodData.tokenizationData.token })
|
|
5994
|
+
} }, _this4.isShippingRequired() && {
|
|
5995
|
+
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: (_r = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _r === void 0 ? void 0 : _r.countryCode, address_city: (_s = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _s === void 0 ? void 0 : _s.locality, address_postcode: (_t = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _t === void 0 ? void 0 : _t.postalCode, address_state: (_u = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _u === void 0 ? void 0 : _u.administrativeArea, contact: {
|
|
5996
|
+
first_name: (_v = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _v === void 0 ? void 0 : _v.name,
|
|
5997
|
+
email: paymentData === null || paymentData === void 0 ? void 0 : paymentData.email,
|
|
5998
|
+
phone: (_w = paymentData === null || paymentData === void 0 ? void 0 : paymentData.shippingAddress) === null || _w === void 0 ? void 0 : _w.phoneNumber
|
|
5999
|
+
} })
|
|
6000
|
+
}),
|
|
6001
|
+
onSuccess: function onSuccess() {
|
|
6002
|
+
return resolve({ transactionState: 'SUCCESS' });
|
|
6003
|
+
},
|
|
6004
|
+
onError: function onError(message) {
|
|
6005
|
+
return resolve({
|
|
6006
|
+
transactionState: 'ERROR',
|
|
6007
|
+
error: {
|
|
6008
|
+
intent: 'PAYMENT_AUTHORIZATION',
|
|
6009
|
+
message: message,
|
|
6010
|
+
reason: 'PAYMENT_DATA_INVALID'
|
|
6011
|
+
}
|
|
6012
|
+
});
|
|
6013
|
+
}
|
|
6014
|
+
});
|
|
6015
|
+
});
|
|
6016
|
+
}
|
|
6017
|
+
}, {
|
|
6018
|
+
key: "onPaymentDataChanged",
|
|
6019
|
+
value: function onPaymentDataChanged(intermediatePaymentData) {
|
|
6020
|
+
var _this5 = this;
|
|
6021
|
+
|
|
6022
|
+
if (!this.isShippingRequired()) return;
|
|
6023
|
+
var parsedUpdateData = this.parseUpdateData(intermediatePaymentData);
|
|
6024
|
+
this.eventEmitter.emit(WALLET_EVENT.UPDATE, parsedUpdateData);
|
|
6025
|
+
return new Promise(function (res, rej) {
|
|
6026
|
+
_this5.latestShippingChangePromiseResolve = res;
|
|
6027
|
+
_this5.latestShippingChangePromiseReject = rej;
|
|
6028
|
+
});
|
|
6029
|
+
}
|
|
6030
|
+
}, {
|
|
6031
|
+
key: "createRequest",
|
|
6032
|
+
value: function createRequest() {
|
|
6033
|
+
return {
|
|
6034
|
+
apiVersion: 2,
|
|
6035
|
+
apiVersionMinor: 0,
|
|
6036
|
+
allowedPaymentMethods: [this.createCardData()]
|
|
6037
|
+
};
|
|
6038
|
+
}
|
|
6039
|
+
}, {
|
|
6040
|
+
key: "createPaymentDataRequest",
|
|
6041
|
+
value: function createPaymentDataRequest() {
|
|
6042
|
+
var _a, _b, _c, _d;
|
|
6043
|
+
// Store default shipping option
|
|
6044
|
+
if (this.isShippingRequired() && this.hasShippingOptions()) {
|
|
6045
|
+
this.selectedShippingOption = (_a = this.meta) === null || _a === void 0 ? void 0 : _a.shipping_options[0];
|
|
6046
|
+
}
|
|
6047
|
+
var gateway = 'paydock';
|
|
6048
|
+
var gatewayMerchantId = this.getMerchantId();
|
|
6049
|
+
return _extends({ apiVersion: 2, apiVersionMinor: 0, allowedPaymentMethods: [_extends(_extends({}, this.createCardData()), { tokenizationSpecification: {
|
|
6050
|
+
type: "PAYMENT_GATEWAY",
|
|
6051
|
+
parameters: {
|
|
6052
|
+
gateway: gateway,
|
|
6053
|
+
gatewayMerchantId: gatewayMerchantId
|
|
6054
|
+
}
|
|
6055
|
+
} })], transactionInfo: {
|
|
6056
|
+
totalPriceStatus: "FINAL",
|
|
6057
|
+
totalPriceLabel: this.meta.amount_label,
|
|
6058
|
+
totalPrice: this.meta.amount.toString(),
|
|
6059
|
+
currencyCode: this.meta.currency.toUpperCase(),
|
|
6060
|
+
countryCode: this.meta.country.toUpperCase()
|
|
6061
|
+
}, merchantInfo: _extends(_extends({}, ((_b = this.meta) === null || _b === void 0 ? void 0 : _b.merchant_name) ? { merchantName: (_c = this.meta) === null || _c === void 0 ? void 0 : _c.merchant_name } : {}), { merchantId: gatewayMerchantId }), callbackIntents: ["PAYMENT_AUTHORIZATION"].concat(toConsumableArray(this.isShippingRequired() ? ["SHIPPING_ADDRESS"] : []), toConsumableArray(this.hasShippingOptions() ? ["SHIPPING_OPTION"] : [])) }, this.isShippingRequired() && _extends({ shippingAddressRequired: true }, this.hasShippingOptions() && {
|
|
6062
|
+
shippingOptionRequired: true,
|
|
6063
|
+
shippingOptionParameters: {
|
|
6064
|
+
defaultSelectedOptionId: (_d = this.selectedShippingOption) === null || _d === void 0 ? void 0 : _d.id,
|
|
6065
|
+
shippingOptions: this.formatShippingOptions(this.meta.shipping_options)
|
|
6066
|
+
}
|
|
6067
|
+
}));
|
|
6068
|
+
}
|
|
6069
|
+
}, {
|
|
6070
|
+
key: "createCardData",
|
|
6071
|
+
value: function createCardData() {
|
|
6072
|
+
return {
|
|
6073
|
+
// TODO: Add raw_data_initialization as in ApplePay
|
|
6074
|
+
type: "CARD",
|
|
6075
|
+
parameters: {
|
|
6076
|
+
allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
|
|
6077
|
+
allowedCardNetworks: ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"]
|
|
6078
|
+
}
|
|
6079
|
+
};
|
|
6080
|
+
}
|
|
6081
|
+
}]);
|
|
6082
|
+
return GoogleWalletService;
|
|
6083
|
+
}(WalletService);
|
|
6084
|
+
|
|
5763
6085
|
var MastercardWalletService = function (_WalletService) {
|
|
5764
6086
|
inherits(MastercardWalletService, _WalletService);
|
|
5765
6087
|
|
|
@@ -5771,8 +6093,12 @@
|
|
|
5771
6093
|
createClass(MastercardWalletService, [{
|
|
5772
6094
|
key: "initializeChildWallets",
|
|
5773
6095
|
value: function initializeChildWallets() {
|
|
6096
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5774
6097
|
this.childWallets = [];
|
|
5775
|
-
|
|
6098
|
+
var hasAppleCredentials = !!((_c = (_b = (_a = this.meta) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b.apple) === null || _c === void 0 ? void 0 : _c.merchant);
|
|
6099
|
+
var hasGoogleCredentials = !!((_f = (_e = (_d = this.meta) === null || _d === void 0 ? void 0 : _d.credentials) === null || _e === void 0 ? void 0 : _e.google) === null || _f === void 0 ? void 0 : _f.merchant);
|
|
6100
|
+
if (hasAppleCredentials && (!this.meta.wallets || this.meta.wallets.includes(WALLET_TYPE.APPLE))) this.childWallets.push(new AppleWalletService(this.publicKey, this.meta, this.getGatewayName(), this.eventEmitter));
|
|
6101
|
+
if (hasGoogleCredentials && (!this.meta.wallets || this.meta.wallets.includes(WALLET_TYPE.GOOGLE))) this.childWallets.push(new GoogleWalletService(this.publicKey, this.meta, this.getGatewayName(), this.eventEmitter));
|
|
5776
6102
|
}
|
|
5777
6103
|
}, {
|
|
5778
6104
|
key: "getGatewayName",
|
|
@@ -5814,6 +6140,15 @@
|
|
|
5814
6140
|
return null;
|
|
5815
6141
|
}
|
|
5816
6142
|
}
|
|
6143
|
+
}, {
|
|
6144
|
+
key: "extractData",
|
|
6145
|
+
value: function extractData(body) {
|
|
6146
|
+
try {
|
|
6147
|
+
return JSON.parse(atob(body.meta));
|
|
6148
|
+
} catch (_a) {
|
|
6149
|
+
return null;
|
|
6150
|
+
}
|
|
6151
|
+
}
|
|
5817
6152
|
}, {
|
|
5818
6153
|
key: "extractMeta",
|
|
5819
6154
|
value: function extractMeta(body) {
|
|
@@ -5948,6 +6283,8 @@
|
|
|
5948
6283
|
|
|
5949
6284
|
var WALLET_CAPTURE_LINK = '/v1/charges/wallet/capture';
|
|
5950
6285
|
var WALLET_CALLBACK_LINK = '/v1/charges/wallet/callback';
|
|
6286
|
+
var STANDALONE_3DS_PROCESS_LINK = '/v1/charges/standalone-3ds/process';
|
|
6287
|
+
var STANDALONE_3DS_HANDLE_LINK = '/v1/charges/standalone-3ds/handle';
|
|
5951
6288
|
var ApiChargeInternal = function () {
|
|
5952
6289
|
function ApiChargeInternal(api) {
|
|
5953
6290
|
classCallCheck(this, ApiChargeInternal);
|
|
@@ -5965,6 +6302,16 @@
|
|
|
5965
6302
|
value: function walletCallback(payload) {
|
|
5966
6303
|
return this.api.getClientPromise('POST', WALLET_CALLBACK_LINK).send(payload);
|
|
5967
6304
|
}
|
|
6305
|
+
}, {
|
|
6306
|
+
key: 'standalone3dsProcess',
|
|
6307
|
+
value: function standalone3dsProcess(payload) {
|
|
6308
|
+
return this.api.getClientPromise('POST', STANDALONE_3DS_PROCESS_LINK).send(payload);
|
|
6309
|
+
}
|
|
6310
|
+
}, {
|
|
6311
|
+
key: 'standalone3dsHandle',
|
|
6312
|
+
value: function standalone3dsHandle() {
|
|
6313
|
+
return this.api.getClientPromise('GET', STANDALONE_3DS_HANDLE_LINK).send(undefined);
|
|
6314
|
+
}
|
|
5968
6315
|
}]);
|
|
5969
6316
|
return ApiChargeInternal;
|
|
5970
6317
|
}();
|
|
@@ -6008,30 +6355,51 @@
|
|
|
6008
6355
|
* @interface IWalletMeta
|
|
6009
6356
|
*
|
|
6010
6357
|
* @type {object}
|
|
6011
|
-
* @param {string} [amount_label] Label shown next to the total amount to be paid. Required for [Stripe, ApplePay]. N/A for [FlyPay, PayPal].
|
|
6012
|
-
* @param {string} [country] Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay]. N/A for [FlyPay, PayPal].
|
|
6358
|
+
* @param {string} [amount_label] Label shown next to the total amount to be paid. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal].
|
|
6359
|
+
* @param {string} [country] Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal].
|
|
6013
6360
|
* @param {string} [pay_later] Used to enable Pay Later feature in PayPal Smart Checkout WalletButton integration when available. Optional for [PayPal]. N/A for other wallets.
|
|
6014
6361
|
* @param {boolean} [request_payer_name] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
|
|
6015
6362
|
* @param {boolean} [request_payer_email] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
|
|
6016
6363
|
* @param {boolean} [request_payer_phone] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
|
|
6017
|
-
* @param {boolean} [request_shipping] Used to request or not shipping address in the Wallet checkout, being able to handle amount changes via the `update` event. Optional for [FlyPay, PayPal, ApplePay]. N/A for [Stripe].
|
|
6018
|
-
* @param {
|
|
6364
|
+
* @param {boolean} [request_shipping] Used to request or not shipping address in the Wallet checkout, being able to handle amount changes via the `update` event. Optional for [FlyPay, PayPal, ApplePay, GooglePay]. N/A for [Stripe].
|
|
6365
|
+
* @param {IApplePayShippingOption[] | IPayPalShippingOption[]} [shipping_options] Used to provide available shipping options.(To use shipping_options the request_shipping flag should be true). Optional for [ApplePay]. N/A for the other wallets.
|
|
6366
|
+
* @param {string} [merchant_name] Merchant Name used for GooglePay integration via MPGS. Required for [GooglePay]. N/A for other wallets.
|
|
6019
6367
|
* @param {object} [raw_data_initialization] Used to provide values to initialize wallet with raw data. Optional for [ApplePay]. N/A for the other wallets.
|
|
6020
6368
|
* @param {object} [style] Used to style PayPal buttons, check possible values at https://developer.paypal.com/docs/business/checkout/reference/style-guide. Also used at ApplePay to select button type. Optional for [PayPal, ApplePay]. N/A for [Stripe, FlyPay].
|
|
6021
6369
|
* @param {object} [style.button_type] Used to select ApplePay button type (e.g: 'buy','donate', etc), check possible values at https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_css. Optional for [ApplePay]. N/A for other wallets.
|
|
6022
|
-
* @param {array} [wallets] By default if this is not sent or empty, we will try to show either Apple Pay or Google Pay buttons. This can be limited sending the following array in this field: ['apple','google]. Optional for [Stripe]. N/A for other wallets.
|
|
6370
|
+
* @param {array} [wallets] By default if this is not sent or empty, we will try to show either Apple Pay or Google Pay buttons. This can be limited sending the following array in this field: ['apple','google]. Optional for [Stripe, ApplePay, GooglePay]. N/A for other wallets.
|
|
6023
6371
|
*/
|
|
6024
6372
|
/**
|
|
6025
|
-
* Interface of Shipping Options
|
|
6026
|
-
* @interface
|
|
6373
|
+
* Interface of Shipping Options for ApplePay
|
|
6374
|
+
* @interface IApplePayShippingOption
|
|
6027
6375
|
*
|
|
6028
6376
|
* @type {object}
|
|
6029
6377
|
* @param {string} [id] Identifier of the Shipping Option. Required.
|
|
6030
6378
|
* @param {string} [label] Identifier of the Shipping Option. Required.
|
|
6031
6379
|
* @param {string} [amount] Amount of the Shipping Option. Required.
|
|
6380
|
+
* @param {string} [detail] Details of the Shipping Option. Required.
|
|
6381
|
+
* @param {string} [type] Type of the Shipping Option. Values can be 'ELECTRONIC', 'GROUND', 'NOT_SHIPPED', 'OVERNIGHT', 'PICKUP', 'PRIORITY', 'SAME_DAY'. Optional.
|
|
6382
|
+
*/
|
|
6383
|
+
/**
|
|
6384
|
+
* Interface of Shipping Options for GooglePay
|
|
6385
|
+
* @interface IGooglePayShippingOption
|
|
6386
|
+
*
|
|
6387
|
+
* @type {object}
|
|
6388
|
+
* @param {string} [id] Identifier of the Shipping Option. Required.
|
|
6389
|
+
* @param {string} [label] Identifier of the Shipping Option. Required.
|
|
6032
6390
|
* @param {string} [detail] Details of the Shipping Option. Optional.
|
|
6033
|
-
* @param {string} [
|
|
6034
|
-
|
|
6391
|
+
* @param {string} [type] Type of the Shipping Option. Values can be 'ELECTRONIC', 'GROUND', 'NOT_SHIPPED', 'OVERNIGHT', 'PICKUP', 'PRIORITY', 'SAME_DAY'. Optional.
|
|
6392
|
+
*/
|
|
6393
|
+
/**
|
|
6394
|
+
* Interface of Shipping Options for PayPal
|
|
6395
|
+
* @interface IPayPalShippingOption
|
|
6396
|
+
*
|
|
6397
|
+
* @type {object}
|
|
6398
|
+
* @param {string} [id] Identifier of the Shipping Option. Required.
|
|
6399
|
+
* @param {string} [label] Identifier of the Shipping Option. Required.
|
|
6400
|
+
* @param {string} [amount] Amount of the Shipping Option. Required.
|
|
6401
|
+
* @param {string} [currency] Currency of the Shipping Option. Required.
|
|
6402
|
+
* @param {string} [type] Type of the Shipping Option. Values can be 'SHIPPING' or 'PICKUP'. Required.
|
|
6035
6403
|
*/
|
|
6036
6404
|
/**
|
|
6037
6405
|
* Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)
|
|
@@ -6094,13 +6462,13 @@
|
|
|
6094
6462
|
this.setupServiceCallbacks();
|
|
6095
6463
|
this.service.load(this.container);
|
|
6096
6464
|
} catch (err) {
|
|
6097
|
-
this.eventEmitter.emit(EVENT$2.UNAVAILABLE,
|
|
6465
|
+
this.eventEmitter.emit(EVENT$2.UNAVAILABLE, null);
|
|
6098
6466
|
throw err;
|
|
6099
6467
|
}
|
|
6100
6468
|
}
|
|
6101
6469
|
/**
|
|
6102
6470
|
* Triggers the update process of the wallet, if available.
|
|
6103
|
-
* Currently supported by Flypay, Paypal and ApplePay via MPGS Wallets.
|
|
6471
|
+
* Currently supported by Flypay, Paypal and ApplePay/GooglePay via MPGS Wallets.
|
|
6104
6472
|
*
|
|
6105
6473
|
* @example
|
|
6106
6474
|
* var button = new WalletButtons(
|
|
@@ -6224,6 +6592,7 @@
|
|
|
6224
6592
|
}
|
|
6225
6593
|
/**
|
|
6226
6594
|
* User to subscribe to the no button available event. This method is used after loading when the button is not available.
|
|
6595
|
+
* For MPGS, since can have more than one wallet button configured (ApplePay/GooglePay) you will receive a body (({ wallet: WALLET_TYPE.GOOGLE }) or ({ wallet: WALLET_TYPE.APPLE })) indicating which button is unavailable
|
|
6227
6596
|
* Important: Do not perform thread blocking operations in callback such as window.alert() calls.
|
|
6228
6597
|
*
|
|
6229
6598
|
* @example
|
|
@@ -6234,6 +6603,9 @@
|
|
|
6234
6603
|
* @example
|
|
6235
6604
|
* button.onUnavailable().then(() => console.log('No wallet buttons available'));
|
|
6236
6605
|
*
|
|
6606
|
+
* @example
|
|
6607
|
+
* button.onUnavailable(function (data) {console.log('data.wallet :: ', data.wallet)});
|
|
6608
|
+
*
|
|
6237
6609
|
* @param {listener} [handler] - Function to be called when no button is available.
|
|
6238
6610
|
*/
|
|
6239
6611
|
|
|
@@ -6375,8 +6747,8 @@
|
|
|
6375
6747
|
value: function setupUnavailableCallback() {
|
|
6376
6748
|
var _this7 = this;
|
|
6377
6749
|
|
|
6378
|
-
this.service.on(WALLET_EVENT.UNAVAILABLE, function () {
|
|
6379
|
-
return _this7.eventEmitter.emit(EVENT$2.UNAVAILABLE, { event: EVENT$2.UNAVAILABLE, data:
|
|
6750
|
+
this.service.on(WALLET_EVENT.UNAVAILABLE, function (eventData) {
|
|
6751
|
+
return _this7.eventEmitter.emit(EVENT$2.UNAVAILABLE, { event: EVENT$2.UNAVAILABLE, data: eventData });
|
|
6380
6752
|
});
|
|
6381
6753
|
}
|
|
6382
6754
|
}, {
|
|
@@ -6826,6 +7198,231 @@
|
|
|
6826
7198
|
return HtmlPaymentSourceWidget;
|
|
6827
7199
|
}(PaymentSourceWidget);
|
|
6828
7200
|
|
|
7201
|
+
var hiddenStyle = {
|
|
7202
|
+
visibility: "hidden",
|
|
7203
|
+
border: "0",
|
|
7204
|
+
width: "0",
|
|
7205
|
+
height: "0"
|
|
7206
|
+
};
|
|
7207
|
+
var PROCESS_STANDALONE_3DS_STATUS;
|
|
7208
|
+
(function (PROCESS_STANDALONE_3DS_STATUS) {
|
|
7209
|
+
PROCESS_STANDALONE_3DS_STATUS["SUCCESS"] = "success";
|
|
7210
|
+
PROCESS_STANDALONE_3DS_STATUS["ERROR"] = "error";
|
|
7211
|
+
PROCESS_STANDALONE_3DS_STATUS["PENDING"] = "pending";
|
|
7212
|
+
})(PROCESS_STANDALONE_3DS_STATUS || (PROCESS_STANDALONE_3DS_STATUS = {}));
|
|
7213
|
+
var GPAYMENTS_EVENT = {
|
|
7214
|
+
AUTH_SUCCESS: 'chargeAuthSuccess',
|
|
7215
|
+
AUTH_ERROR: 'chargeAuthReject',
|
|
7216
|
+
DECOUPLED: 'chargeAuthDecoupled',
|
|
7217
|
+
CHALLENGE: 'chargeAuthChallenge',
|
|
7218
|
+
ERROR: 'error'
|
|
7219
|
+
};
|
|
7220
|
+
var GPaymentsService = function () {
|
|
7221
|
+
function GPaymentsService(container, api, eventEmitter) {
|
|
7222
|
+
classCallCheck(this, GPaymentsService);
|
|
7223
|
+
|
|
7224
|
+
this.container = container;
|
|
7225
|
+
this.api = api;
|
|
7226
|
+
this.eventEmitter = eventEmitter;
|
|
7227
|
+
this.resultRead = false;
|
|
7228
|
+
this.iFrameEvent = new IFrameEvent(window);
|
|
7229
|
+
}
|
|
7230
|
+
|
|
7231
|
+
createClass(GPaymentsService, [{
|
|
7232
|
+
key: "load",
|
|
7233
|
+
value: function load(_ref, title) {
|
|
7234
|
+
var initialization_url = _ref.initialization_url,
|
|
7235
|
+
secondary_url = _ref.secondary_url,
|
|
7236
|
+
charge_3ds_id = _ref.charge_3ds_id;
|
|
7237
|
+
|
|
7238
|
+
try {
|
|
7239
|
+
this.setupIFrameEvents(charge_3ds_id);
|
|
7240
|
+
this.initializeIFrames(initialization_url, secondary_url, title);
|
|
7241
|
+
} catch (err) {
|
|
7242
|
+
this.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, this.parseError(err, charge_3ds_id));
|
|
7243
|
+
}
|
|
7244
|
+
}
|
|
7245
|
+
}, {
|
|
7246
|
+
key: "initializeIFrames",
|
|
7247
|
+
value: function initializeIFrames(initializationUrl, secondaryUrl, title) {
|
|
7248
|
+
var hideAuthorization = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
7249
|
+
|
|
7250
|
+
var divAuthorization = document.createElement("div");
|
|
7251
|
+
divAuthorization.setAttribute("id", "paydock_authorization_iframe");
|
|
7252
|
+
this.container.getElement().appendChild(divAuthorization);
|
|
7253
|
+
this.browserAndChallengeContainer = new Container("#paydock_authorization_iframe");
|
|
7254
|
+
this.iFrameAuthorization = new IFrame(this.browserAndChallengeContainer);
|
|
7255
|
+
this.iFrameAuthorization.load(initializationUrl, { title: title });
|
|
7256
|
+
var divSecondaryURL = document.createElement("div");
|
|
7257
|
+
divSecondaryURL.setAttribute("id", "paydock_secondary_iframe");
|
|
7258
|
+
this.container.getElement().appendChild(divSecondaryURL);
|
|
7259
|
+
this.monitoringContainer = new Container("#paydock_secondary_iframe");
|
|
7260
|
+
this.iFrameSecondaryUrl = new IFrame(this.monitoringContainer);
|
|
7261
|
+
this.iFrameSecondaryUrl.load(secondaryUrl, { title: title });
|
|
7262
|
+
this.hideIframes(hideAuthorization);
|
|
7263
|
+
}
|
|
7264
|
+
}, {
|
|
7265
|
+
key: "hideIframes",
|
|
7266
|
+
value: function hideIframes() {
|
|
7267
|
+
var hideAuthorization = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
7268
|
+
|
|
7269
|
+
for (var prop in hiddenStyle) {
|
|
7270
|
+
if (!hiddenStyle.hasOwnProperty(prop)) continue;
|
|
7271
|
+
if (hideAuthorization) this.iFrameAuthorization.setStyle(prop, hiddenStyle[prop]);
|
|
7272
|
+
this.iFrameSecondaryUrl.setStyle(prop, hiddenStyle[prop]);
|
|
7273
|
+
}
|
|
7274
|
+
}
|
|
7275
|
+
}, {
|
|
7276
|
+
key: "setupIFrameEvents",
|
|
7277
|
+
value: function setupIFrameEvents(widgetId) {
|
|
7278
|
+
var _this = this;
|
|
7279
|
+
|
|
7280
|
+
this.iFrameEvent.on(EVENT.CHARGE_AUTH, widgetId, function (data) {
|
|
7281
|
+
if (data.status === "MethodSkipped" /* SKIPPED */) _this.performAuthentication(data);
|
|
7282
|
+
});
|
|
7283
|
+
this.iFrameEvent.on(EVENT.CHARGE_AUTH_SUCCESS, widgetId, function (data) {
|
|
7284
|
+
_this.processResult(data.charge_3ds_id);
|
|
7285
|
+
});
|
|
7286
|
+
}
|
|
7287
|
+
}, {
|
|
7288
|
+
key: "parseResultData",
|
|
7289
|
+
value: function parseResultData(_ref2, charge3dsId) {
|
|
7290
|
+
var status = _ref2.status;
|
|
7291
|
+
|
|
7292
|
+
return {
|
|
7293
|
+
status: status,
|
|
7294
|
+
charge_3ds_id: charge3dsId
|
|
7295
|
+
};
|
|
7296
|
+
}
|
|
7297
|
+
}, {
|
|
7298
|
+
key: "parseHandleResponse",
|
|
7299
|
+
value: function parseHandleResponse(_ref3, charge3dsId) {
|
|
7300
|
+
var status = _ref3.status,
|
|
7301
|
+
result = _ref3.result;
|
|
7302
|
+
|
|
7303
|
+
return {
|
|
7304
|
+
status: status,
|
|
7305
|
+
charge_3ds_id: charge3dsId,
|
|
7306
|
+
result: {
|
|
7307
|
+
description: result === null || result === void 0 ? void 0 : result.description
|
|
7308
|
+
}
|
|
7309
|
+
};
|
|
7310
|
+
}
|
|
7311
|
+
}, {
|
|
7312
|
+
key: "parseError",
|
|
7313
|
+
value: function parseError(data, charge3dsId) {
|
|
7314
|
+
return { charge_3ds_id: charge3dsId, error: data };
|
|
7315
|
+
}
|
|
7316
|
+
}, {
|
|
7317
|
+
key: "processResult",
|
|
7318
|
+
value: function processResult(charge3dsId) {
|
|
7319
|
+
var _this2 = this;
|
|
7320
|
+
|
|
7321
|
+
if (this.resultRead) return;
|
|
7322
|
+
this.resultRead = true;
|
|
7323
|
+
this.api.charge().standalone3dsHandle().then(function (result) {
|
|
7324
|
+
_this2.iFrameAuthorization.remove();
|
|
7325
|
+
_this2.iFrameSecondaryUrl.remove();
|
|
7326
|
+
if (result.status === PROCESS_STANDALONE_3DS_STATUS.SUCCESS) _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this2.parseResultData(result, charge3dsId));else _this2.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this2.parseResultData(result, charge3dsId));
|
|
7327
|
+
}, function (err) {
|
|
7328
|
+
_this2.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this2.parseError(err, charge3dsId));
|
|
7329
|
+
});
|
|
7330
|
+
}
|
|
7331
|
+
}, {
|
|
7332
|
+
key: "externalAPI",
|
|
7333
|
+
value: function externalAPI(method, url) {
|
|
7334
|
+
var request = new XMLHttpRequest();
|
|
7335
|
+
request.open(method, url, true);
|
|
7336
|
+
return new Promise(function (resolve, reject) {
|
|
7337
|
+
request.onload = function () {
|
|
7338
|
+
try {
|
|
7339
|
+
var body = JSON.parse(request.responseText);
|
|
7340
|
+
resolve(body);
|
|
7341
|
+
} catch (error) {
|
|
7342
|
+
reject(error);
|
|
7343
|
+
}
|
|
7344
|
+
};
|
|
7345
|
+
request.send();
|
|
7346
|
+
});
|
|
7347
|
+
}
|
|
7348
|
+
}, {
|
|
7349
|
+
key: "doPolling",
|
|
7350
|
+
value: function doPolling(url, charge3dsId) {
|
|
7351
|
+
var _this3 = this;
|
|
7352
|
+
|
|
7353
|
+
this.externalAPI("GET", url).then(function (data) {
|
|
7354
|
+
if (!data.event || data.event === "AuthResultNotReady") setTimeout(function () {
|
|
7355
|
+
_this3.doPolling(url, charge3dsId);
|
|
7356
|
+
}, 2000);else if (data.event === 'AuthResultReady') _this3.processResult(charge3dsId);else throw new Error("Event not supported");
|
|
7357
|
+
}).catch(function (err) {
|
|
7358
|
+
return _this3.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this3.parseError(err, charge3dsId));
|
|
7359
|
+
});
|
|
7360
|
+
}
|
|
7361
|
+
}, {
|
|
7362
|
+
key: "performAuthentication",
|
|
7363
|
+
value: function performAuthentication(_ref4) {
|
|
7364
|
+
var _this4 = this;
|
|
7365
|
+
|
|
7366
|
+
var charge_3ds_id = _ref4.charge_3ds_id;
|
|
7367
|
+
|
|
7368
|
+
this.iFrameAuthorization.remove();
|
|
7369
|
+
this.iFrameSecondaryUrl.remove();
|
|
7370
|
+
this.api.charge().standalone3dsProcess({ charge_3ds_id: charge_3ds_id }).then(function (authenticationResult) {
|
|
7371
|
+
var _a, _b;
|
|
7372
|
+
if (authenticationResult.status === "success" /* SUCCESS */) _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));else if (authenticationResult.status === "pending" /* PENDING */) {
|
|
7373
|
+
if ((_a = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _a === void 0 ? void 0 : _a.challenge) {
|
|
7374
|
+
_this4.eventEmitter.emit(GPAYMENTS_EVENT.CHALLENGE, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
|
|
7375
|
+
_this4.initializeIFrames(authenticationResult.result.challenge_url, 'authenticationResult.result.secondary_url', 'Authentication Challenge', false);
|
|
7376
|
+
_this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
|
|
7377
|
+
} else if ((_b = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _b === void 0 ? void 0 : _b.decoupled_challenge) {
|
|
7378
|
+
_this4.eventEmitter.emit(GPAYMENTS_EVENT.DECOUPLED, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
|
|
7379
|
+
_this4.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
|
|
7380
|
+
}
|
|
7381
|
+
} else return _this4.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this4.parseHandleResponse(authenticationResult, charge_3ds_id));
|
|
7382
|
+
}, function (err) {
|
|
7383
|
+
_this4.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this4.parseError(err, charge_3ds_id));
|
|
7384
|
+
});
|
|
7385
|
+
}
|
|
7386
|
+
}]);
|
|
7387
|
+
return GPaymentsService;
|
|
7388
|
+
}();
|
|
7389
|
+
|
|
7390
|
+
var STANDALONE_3DS_GATEWAYS = {
|
|
7391
|
+
GPAYMENTS: "GPayments"
|
|
7392
|
+
};
|
|
7393
|
+
var Standalone3dsService = function () {
|
|
7394
|
+
function Standalone3dsService(container, eventEmitter) {
|
|
7395
|
+
classCallCheck(this, Standalone3dsService);
|
|
7396
|
+
|
|
7397
|
+
this.env = ENV.SANDBOX;
|
|
7398
|
+
this.container = container;
|
|
7399
|
+
this.eventEmitter = eventEmitter;
|
|
7400
|
+
}
|
|
7401
|
+
|
|
7402
|
+
createClass(Standalone3dsService, [{
|
|
7403
|
+
key: "load",
|
|
7404
|
+
value: function load(token, options) {
|
|
7405
|
+
var parsedToken = AccessToken.validateJWT(token);
|
|
7406
|
+
if (!parsedToken) throw new Error("Invalid charge token");
|
|
7407
|
+
var tokenData = AccessToken.extractData(parsedToken.body);
|
|
7408
|
+
var api = new ApiInternal(token, API_AUTH_TYPE.TOKEN);
|
|
7409
|
+
api.setEnv(this.env, this.alias);
|
|
7410
|
+
switch (tokenData.service_type) {
|
|
7411
|
+
case STANDALONE_3DS_GATEWAYS.GPAYMENTS:
|
|
7412
|
+
new GPaymentsService(this.container, api, this.eventEmitter).load(tokenData, options.title);
|
|
7413
|
+
break;
|
|
7414
|
+
}
|
|
7415
|
+
}
|
|
7416
|
+
}, {
|
|
7417
|
+
key: "setEnv",
|
|
7418
|
+
value: function setEnv(env, alias) {
|
|
7419
|
+
this.env = env;
|
|
7420
|
+
this.alias = alias;
|
|
7421
|
+
}
|
|
7422
|
+
}]);
|
|
7423
|
+
return Standalone3dsService;
|
|
7424
|
+
}();
|
|
7425
|
+
|
|
6829
7426
|
/**
|
|
6830
7427
|
* List of available token's content formats
|
|
6831
7428
|
* @enum TOKEN_FORMAT
|
|
@@ -6837,6 +7434,7 @@
|
|
|
6837
7434
|
(function (TOKEN_FORMAT) {
|
|
6838
7435
|
TOKEN_FORMAT["HTML"] = "html";
|
|
6839
7436
|
TOKEN_FORMAT["URL"] = "url";
|
|
7437
|
+
TOKEN_FORMAT["STANDALONE_3DS"] = "standalone_3ds";
|
|
6840
7438
|
})(TOKEN_FORMAT || (TOKEN_FORMAT = {}));
|
|
6841
7439
|
/**
|
|
6842
7440
|
* List of available event's name
|
|
@@ -6849,6 +7447,17 @@
|
|
|
6849
7447
|
* @param {string} ADDITIONAL_DATA_REJECT=additionalDataCollectReject
|
|
6850
7448
|
* @param {string} CHARGE_AUTH=chargeAuth
|
|
6851
7449
|
*/
|
|
7450
|
+
/**
|
|
7451
|
+
* List of available event's name for Standalone 3ds flow
|
|
7452
|
+
* @const STANDALONE_3DS_EVENT
|
|
7453
|
+
*
|
|
7454
|
+
* @type {object}
|
|
7455
|
+
* @param {string} CHARGE_AUTH_SUCCESS=chargeAuthSuccess
|
|
7456
|
+
* @param {string} CHARGE_AUTH_REJECT=chargeAuthReject
|
|
7457
|
+
* @param {string} CHARGE_AUTH_DECOUPLED=chargeAuthDecoupled
|
|
7458
|
+
* @param {string} CHARGE_AUTH_CHALLENGE=chargeAuthChallenge
|
|
7459
|
+
* @param {string} ERROR=error
|
|
7460
|
+
*/
|
|
6852
7461
|
/**
|
|
6853
7462
|
* Class Canvas3ds include method for working on html
|
|
6854
7463
|
* @constructor
|
|
@@ -6870,6 +7479,8 @@
|
|
|
6870
7479
|
this.link.setParams({ ref_id: this.token.charge_3ds_id });
|
|
6871
7480
|
this.container = new Container(selector);
|
|
6872
7481
|
this.iFrame = new IFrame(this.container);
|
|
7482
|
+
this.eventEmitter = new EventEmitter();
|
|
7483
|
+
this.standalone3dsService = new Standalone3dsService(this.container, this.eventEmitter);
|
|
6873
7484
|
this.event = new IFrameEvent(window);
|
|
6874
7485
|
}
|
|
6875
7486
|
|
|
@@ -6881,7 +7492,7 @@
|
|
|
6881
7492
|
*
|
|
6882
7493
|
*/
|
|
6883
7494
|
value: function load() {
|
|
6884
|
-
if (this.token.format === TOKEN_FORMAT.HTML) this.iFrame.loadFromHtml(this.token.content, { title: '3d secure authentication' });else if (this.token.format === TOKEN_FORMAT.URL) this.iFrame.load(this.token.content, { title: '3d secure authentication' });else console.error('Token contain unsupported payload');
|
|
7495
|
+
if (this.token.format === TOKEN_FORMAT.HTML) this.iFrame.loadFromHtml(this.token.content, { title: '3d secure authentication' });else if (this.token.format === TOKEN_FORMAT.URL) this.iFrame.load(this.token.content, { title: '3d secure authentication' });else if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS) this.standalone3dsService.load(this.token.content, { title: '3d secure authentication' });else console.error('Token contain unsupported payload');
|
|
6885
7496
|
}
|
|
6886
7497
|
/**
|
|
6887
7498
|
* Current method can change environment. By default environment = sandbox.
|
|
@@ -6897,6 +7508,7 @@
|
|
|
6897
7508
|
key: 'setEnv',
|
|
6898
7509
|
value: function setEnv(env, alias) {
|
|
6899
7510
|
this.link.setEnv(env, alias);
|
|
7511
|
+
this.standalone3dsService.setEnv(env, alias);
|
|
6900
7512
|
for (var index in this.configs) {
|
|
6901
7513
|
if (!this.configs.hasOwnProperty(index)) continue;
|
|
6902
7514
|
this.configs[index].setEnv(env, alias);
|
|
@@ -6919,7 +7531,7 @@
|
|
|
6919
7531
|
* widget.on('chargeAuthReject').then(function (data) {
|
|
6920
7532
|
* console.log(data);
|
|
6921
7533
|
* });
|
|
6922
|
-
* @param {string} eventName - Available event names [EVENT]{@link EVENT}
|
|
7534
|
+
* @param {string} eventName - Available event names [EVENT]{@link EVENT} [STANDALONE_3DS_EVENT]{@link STANDALONE_3DS_EVENT}
|
|
6923
7535
|
* @param {listener} [cb]
|
|
6924
7536
|
* @return {Promise<IEventData> | void}
|
|
6925
7537
|
*/
|
|
@@ -6929,12 +7541,21 @@
|
|
|
6929
7541
|
value: function on(eventName, cb) {
|
|
6930
7542
|
var _this = this;
|
|
6931
7543
|
|
|
6932
|
-
if (
|
|
6933
|
-
|
|
6934
|
-
return
|
|
6935
|
-
return
|
|
7544
|
+
if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS) {
|
|
7545
|
+
if (typeof cb === 'function') return this.eventEmitter.subscribe(eventName, cb);
|
|
7546
|
+
return new Promise(function (resolve) {
|
|
7547
|
+
return _this.eventEmitter.subscribe(eventName, function (res) {
|
|
7548
|
+
return resolve(res);
|
|
7549
|
+
});
|
|
6936
7550
|
});
|
|
6937
|
-
}
|
|
7551
|
+
} else {
|
|
7552
|
+
if (typeof cb === 'function') return this.event.on(eventName, this.link.getParams().ref_id, cb);
|
|
7553
|
+
return new Promise(function (resolve) {
|
|
7554
|
+
return _this.event.on(eventName, _this.link.getParams().ref_id, function (res) {
|
|
7555
|
+
return resolve(res);
|
|
7556
|
+
});
|
|
7557
|
+
});
|
|
7558
|
+
}
|
|
6938
7559
|
}
|
|
6939
7560
|
/**
|
|
6940
7561
|
* Using this method you can hide widget after load
|