@paydock/client-sdk 1.10.39-beta → 1.10.43-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 +151 -5
- package/bundles/widget.umd.js +135 -36
- package/bundles/widget.umd.min.js +1 -1
- package/lib/api/api-charge-internal.d.ts +2 -1
- package/lib/components/param.d.ts +2 -0
- package/lib/wallet-buttons/apple.wallet-service.d.ts +7 -1
- package/lib/wallet-buttons/apple.wallet-service.js +86 -33
- package/lib/wallet-buttons/apple.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/mastercard.wallet-service.d.ts +2 -1
- package/lib/wallet-buttons/mastercard.wallet-service.js +3 -0
- package/lib/wallet-buttons/mastercard.wallet-service.js.map +1 -1
- package/lib/wallet-buttons/wallet-buttons.d.ts +38 -1
- package/lib/wallet-buttons/wallet-buttons.js +38 -1
- package/lib/wallet-buttons/wallet-buttons.js.map +1 -1
- package/lib/wallet-buttons/wallet-service.d.ts +27 -2
- package/lib/wallet-buttons/wallet-service.js.map +1 -1
- package/package.json +1 -1
- package/slate.md +112 -4
package/README.md
CHANGED
|
@@ -4825,6 +4825,8 @@ Interface of data used by the wallet checkout and payment proccess.
|
|
|
4825
4825
|
| [request_payer_email] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
|
|
4826
4826
|
| [request_payer_phone] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
|
|
4827
4827
|
| [request_shipping] | <code>boolean</code> | 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]. |
|
|
4828
|
+
| [shipping_options] | <code>array</code> | Used to provide available shipping options. Optional for [ApplePay]. N/A for the other wallets. |
|
|
4829
|
+
| [raw_data_initialization] | <code>object</code> | Used to provide values to initialize wallet with raw data. Optional for [ApplePay]. N/A for the other wallets. |
|
|
4828
4830
|
| [style] | <code>object</code> | 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]. |
|
|
4829
4831
|
| [style.button_type] | <code>object</code> | 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. |
|
|
4830
4832
|
| [wallets] | <code>array</code> | 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. |
|
|
@@ -4886,7 +4888,7 @@ var button = new WalletButtons(
|
|
|
4886
4888
|
|
|
4887
4889
|
### walletButtons.update()
|
|
4888
4890
|
Triggers the update process of the wallet, if available.
|
|
4889
|
-
Currently supported by Flypay and
|
|
4891
|
+
Currently supported by Flypay, Paypal and ApplePay via MPGS Wallets.
|
|
4890
4892
|
|
|
4891
4893
|
**Kind**: instance method of [<code>WalletButtons</code>](#WalletButtons)
|
|
4892
4894
|
**Example**
|
|
@@ -4904,6 +4906,42 @@ var button = new WalletButtons(
|
|
|
4904
4906
|
button.update({ success: true });
|
|
4905
4907
|
});
|
|
4906
4908
|
```
|
|
4909
|
+
**Example**
|
|
4910
|
+
```js
|
|
4911
|
+
// ApplePay via MPGS example:
|
|
4912
|
+
var button = new WalletButtons(
|
|
4913
|
+
'#buttons',
|
|
4914
|
+
token,
|
|
4915
|
+
{
|
|
4916
|
+
amount_label: 'Total',
|
|
4917
|
+
country: 'AU',
|
|
4918
|
+
...
|
|
4919
|
+
}
|
|
4920
|
+
);
|
|
4921
|
+
button.on('update', (data) => {
|
|
4922
|
+
updateChargeAmountInBackend(data);
|
|
4923
|
+
button.update({
|
|
4924
|
+
success: true,
|
|
4925
|
+
body: {
|
|
4926
|
+
amount: 15,
|
|
4927
|
+
shipping_options: [
|
|
4928
|
+
{
|
|
4929
|
+
id: "NEW-FreeShip",
|
|
4930
|
+
label: "NEW - Free Shipping",
|
|
4931
|
+
detail: "Arrives in 3 to 5 days",
|
|
4932
|
+
amount: "0.00"
|
|
4933
|
+
},
|
|
4934
|
+
{
|
|
4935
|
+
id: "NEW - FastShip",
|
|
4936
|
+
label: "NEW - Fast Shipping",
|
|
4937
|
+
detail: "Arrives in less than 1 day",
|
|
4938
|
+
amount: "10.00"
|
|
4939
|
+
}
|
|
4940
|
+
]
|
|
4941
|
+
}
|
|
4942
|
+
});
|
|
4943
|
+
});
|
|
4944
|
+
```
|
|
4907
4945
|
<a name="WalletButtons+setEnv" id="WalletButtons+setEnv"></a>
|
|
4908
4946
|
|
|
4909
4947
|
### walletButtons.setEnv(env, [alias])
|
|
@@ -5210,7 +5248,7 @@ button.close();
|
|
|
5210
5248
|
|
|
5211
5249
|
### Performing actions when shipping info is updated
|
|
5212
5250
|
|
|
5213
|
-
In Flypay and
|
|
5251
|
+
In Flypay, Paypal and ApplePay via MPGS integrations after each shipping info update the `onUpdate(data)` will be called with the selected shipping address information (plus selected shipping method for Paypal). Merchants should handle this callback, recalculate shipping costs in their server by analyzing the new data, and submit a backend to backend request to `POST charges/:id` with the new total amount and shipping amount (you can find the documentation of this call in the PayDock API documentation).
|
|
5214
5252
|
|
|
5215
5253
|
For Paypal integration specifically, if shipping is enabled for the wallet button and different shipping methods were provided in the create wallet charge call, Merchants must ensure that the posted `shipping.amount` to `POST charges/:id` matches the selected shipping option amount (value sent in when initializing the wallet charge). In other words, when providing shipping methods the shipping amount is bound to being one of the provided shipping method amount necessarily. Bear in mind that the total charge amount must include the `shipping.amount`, since it represents the full amount to be charged to the customer.
|
|
5216
5254
|
|
|
@@ -5224,6 +5262,35 @@ button.onUpdate((data) => {
|
|
|
5224
5262
|
});
|
|
5225
5263
|
```
|
|
5226
5264
|
|
|
5265
|
+
For ApplePay via MPGS integration specifically, you must return the new `amount` and new `shipping_options` If new options are needed based on the updated shipping data. Before the user authorizes the transaction with Touch ID, Face ID, or passcode, you receive redacted address information (address_country, address_city, address_state, address_postcode), this data can be used to recalculate the amount and new shipping options. (https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment/1916097-shippingcontact)
|
|
5266
|
+
|
|
5267
|
+
```javascript
|
|
5268
|
+
button.onUpdate((data) => {
|
|
5269
|
+
console.log("Updating amount via a backend to backend call to POST charges/:id");
|
|
5270
|
+
// call `POST charges/:id` to modify charge
|
|
5271
|
+
button.update({
|
|
5272
|
+
success: true,
|
|
5273
|
+
body: {
|
|
5274
|
+
amount: 15,
|
|
5275
|
+
shipping_options: [
|
|
5276
|
+
{
|
|
5277
|
+
id: "NEW-FreeShip",
|
|
5278
|
+
label: "NEW - Free Shipping",
|
|
5279
|
+
detail: "Arrives in 3 to 5 days",
|
|
5280
|
+
amount: "0.00"
|
|
5281
|
+
},
|
|
5282
|
+
{
|
|
5283
|
+
id: "NEW - FastShip",
|
|
5284
|
+
label: "NEW - Fast Shipping",
|
|
5285
|
+
detail: "Arrives in less than 1 day",
|
|
5286
|
+
amount: "10.00"
|
|
5287
|
+
}
|
|
5288
|
+
]
|
|
5289
|
+
}
|
|
5290
|
+
});
|
|
5291
|
+
});
|
|
5292
|
+
```
|
|
5293
|
+
|
|
5227
5294
|
### Performing actions after the payment is completed
|
|
5228
5295
|
|
|
5229
5296
|
After the payment is completed, the onPaymentSuccessful(data) will be called if the payment was successful. If the payment was not successful, the function onPaymentError(data) will be called. If fraud check is active for the gateway, a fraud body was sent in the wallet charge initialize call and the fraud service left the charge in review, then the onPaymentInReview(data) will be called.
|
|
@@ -5371,7 +5438,7 @@ _(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_l
|
|
|
5371
5438
|
```
|
|
5372
5439
|
|
|
5373
5440
|
This example shows how to use these functions for **ApplePay via MPGS**:
|
|
5374
|
-
_(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `request_shipping`, `style.button_type`)_
|
|
5441
|
+
_(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `raw_data_initialization`, `request_shipping`, `style.button_type`)_
|
|
5375
5442
|
### Full example
|
|
5376
5443
|
|
|
5377
5444
|
```html
|
|
@@ -5393,10 +5460,89 @@ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `re
|
|
|
5393
5460
|
{
|
|
5394
5461
|
amount_label: "Total",
|
|
5395
5462
|
country: 'DE',
|
|
5396
|
-
request_shipping:
|
|
5463
|
+
request_shipping: true,
|
|
5397
5464
|
style: {
|
|
5398
5465
|
button_type: 'buy',
|
|
5399
|
-
}
|
|
5466
|
+
},
|
|
5467
|
+
shipping_options: [
|
|
5468
|
+
{
|
|
5469
|
+
id: "FreeShip",
|
|
5470
|
+
label: "Free Shipping",
|
|
5471
|
+
detail: "Arrives in 5 to 7 days",
|
|
5472
|
+
amount: "0.00"
|
|
5473
|
+
},
|
|
5474
|
+
{
|
|
5475
|
+
id: "FastShip",
|
|
5476
|
+
label: "Fast Shipping",
|
|
5477
|
+
detail: "Arrives in 1 day",
|
|
5478
|
+
amount: "10.00"
|
|
5479
|
+
}
|
|
5480
|
+
]
|
|
5481
|
+
}
|
|
5482
|
+
);
|
|
5483
|
+
button.setEnv('sandbox');
|
|
5484
|
+
button.onUnavailable(() => console.log("No wallet buttons available"));
|
|
5485
|
+
button.onPaymentSuccessful((data) => console.log("The payment was successful"));
|
|
5486
|
+
button.onPaymentError((data) => console.log("The payment was not successful"));
|
|
5487
|
+
button.load();
|
|
5488
|
+
</script>
|
|
5489
|
+
</html>
|
|
5490
|
+
```
|
|
5491
|
+
|
|
5492
|
+
Also, for **ApplePay via MPGS** you can initialize the `ApplePayPaymentRequest` with your own values instead of using the default ones. Below you can see an example on how to initialize the `ApplePayPaymentRequest` with the `raw_data_initialization` meta field:
|
|
5493
|
+
|
|
5494
|
+
### Raw data initialization example
|
|
5495
|
+
|
|
5496
|
+
```html
|
|
5497
|
+
<!DOCTYPE html>
|
|
5498
|
+
<html lang="en">
|
|
5499
|
+
<head>
|
|
5500
|
+
<meta charset="UTF-8">
|
|
5501
|
+
<title>Title</title>
|
|
5502
|
+
</head>
|
|
5503
|
+
<body>
|
|
5504
|
+
<h2>Payment using PayDock Wallet Button!</h2>
|
|
5505
|
+
<div id="widget"></div>
|
|
5506
|
+
</body>
|
|
5507
|
+
<script src="https://app-sandbox.paydock.com/v1/widget.umd.js" ></script>
|
|
5508
|
+
<script>
|
|
5509
|
+
let button = new paydock.WalletButtons(
|
|
5510
|
+
"#widget",
|
|
5511
|
+
charge_token,
|
|
5512
|
+
{
|
|
5513
|
+
raw_data_initialization: {
|
|
5514
|
+
countryCode: "AU",
|
|
5515
|
+
currencyCode: "AUD",
|
|
5516
|
+
merchantCapabilities: ["supports3DS","supportsCredit","supportsDebit"],
|
|
5517
|
+
supportedNetworks: ["visa","masterCard","amex","discover"],
|
|
5518
|
+
requiredBillingContactFields: ["name","postalAddress"],
|
|
5519
|
+
requiredShippingContactFields:["postalAddress","name","phone","email" ],
|
|
5520
|
+
total: {
|
|
5521
|
+
label: "Total",
|
|
5522
|
+
amount: "10",
|
|
5523
|
+
type: "final",
|
|
5524
|
+
}
|
|
5525
|
+
},
|
|
5526
|
+
amount_label: "Total",
|
|
5527
|
+
country: 'DE',
|
|
5528
|
+
request_shipping: true,
|
|
5529
|
+
style: {
|
|
5530
|
+
button_type: 'buy',
|
|
5531
|
+
},
|
|
5532
|
+
shipping_options: [
|
|
5533
|
+
{
|
|
5534
|
+
id: "FreeShip",
|
|
5535
|
+
label: "Free Shipping",
|
|
5536
|
+
detail: "Arrives in 5 to 7 days",
|
|
5537
|
+
amount: "0.00"
|
|
5538
|
+
},
|
|
5539
|
+
{
|
|
5540
|
+
id: "FastShip",
|
|
5541
|
+
label: "Fast Shipping",
|
|
5542
|
+
detail: "Arrives in 1 day",
|
|
5543
|
+
amount: "10.00"
|
|
5544
|
+
}
|
|
5545
|
+
]
|
|
5400
5546
|
}
|
|
5401
5547
|
);
|
|
5402
5548
|
button.setEnv('sandbox');
|
package/bundles/widget.umd.js
CHANGED
|
@@ -5536,12 +5536,11 @@
|
|
|
5536
5536
|
_this.onPaymentAuthorized = function (event) {
|
|
5537
5537
|
var _event$payment = event.payment,
|
|
5538
5538
|
token = _event$payment.token,
|
|
5539
|
-
billingContact = _event$payment.billingContact
|
|
5539
|
+
billingContact = _event$payment.billingContact,
|
|
5540
|
+
shippingContact = _event$payment.shippingContact;
|
|
5540
5541
|
|
|
5541
5542
|
_this.eventEmitter.emit(WALLET_EVENT.PAYMENT_METHOD_SELECTED, {
|
|
5542
|
-
data: {
|
|
5543
|
-
payment_method_id: token.paymentData ? JSON.stringify(token.paymentData) : '',
|
|
5544
|
-
customer: {
|
|
5543
|
+
data: _extends({ customer: {
|
|
5545
5544
|
payment_source: {
|
|
5546
5545
|
card_name: token.paymentMethod.displayName,
|
|
5547
5546
|
type: token.paymentMethod.type,
|
|
@@ -5551,10 +5550,27 @@
|
|
|
5551
5550
|
address_country: billingContact === null || billingContact === void 0 ? void 0 : billingContact.countryCode,
|
|
5552
5551
|
address_city: billingContact === null || billingContact === void 0 ? void 0 : billingContact.locality,
|
|
5553
5552
|
address_postcode: billingContact === null || billingContact === void 0 ? void 0 : billingContact.postalCode,
|
|
5554
|
-
address_state: billingContact === null || billingContact === void 0 ? void 0 : billingContact.administrativeArea
|
|
5553
|
+
address_state: billingContact === null || billingContact === void 0 ? void 0 : billingContact.administrativeArea,
|
|
5554
|
+
ref_token: token.paymentData ? JSON.stringify(token.paymentData) : ''
|
|
5555
|
+
}
|
|
5556
|
+
} }, _this.meta.request_shipping && shippingContact && {
|
|
5557
|
+
shipping: {
|
|
5558
|
+
method: _this.selectedShippingMethodId,
|
|
5559
|
+
options: _this.meta.shipping_options,
|
|
5560
|
+
address_line1: shippingContact.addressLines[0],
|
|
5561
|
+
address_line2: shippingContact.addressLines[1],
|
|
5562
|
+
address_country: shippingContact.countryCode,
|
|
5563
|
+
address_city: shippingContact.locality,
|
|
5564
|
+
address_postcode: shippingContact.postalCode,
|
|
5565
|
+
address_state: shippingContact.administrativeArea,
|
|
5566
|
+
contact: {
|
|
5567
|
+
first_name: shippingContact.givenName,
|
|
5568
|
+
last_name: shippingContact.familyName,
|
|
5569
|
+
email: shippingContact.emailAddress,
|
|
5570
|
+
phone: shippingContact.phoneNumber
|
|
5555
5571
|
}
|
|
5556
5572
|
}
|
|
5557
|
-
},
|
|
5573
|
+
}),
|
|
5558
5574
|
onSuccess: function onSuccess() {
|
|
5559
5575
|
return _this.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS);
|
|
5560
5576
|
},
|
|
@@ -5563,6 +5579,51 @@
|
|
|
5563
5579
|
}
|
|
5564
5580
|
});
|
|
5565
5581
|
};
|
|
5582
|
+
_this.onShippingContactSelected = function (event) {
|
|
5583
|
+
var parsedCallbackData = _this.parseUpdateData(event.shippingContact);
|
|
5584
|
+
_this.eventEmitter.emit(WALLET_EVENT.UPDATE, parsedCallbackData);
|
|
5585
|
+
var update = _extends({ newTotal: {
|
|
5586
|
+
label: _this.meta.amount_label,
|
|
5587
|
+
amount: _this.meta.amount.toString(),
|
|
5588
|
+
type: "final"
|
|
5589
|
+
} }, _this.meta.request_shipping && _this.meta.shipping_options && {
|
|
5590
|
+
newShippingMethods: _this.formatShippingOptions(_this.meta.shipping_options)
|
|
5591
|
+
});
|
|
5592
|
+
_this.paymentSession.completeShippingContactSelection(update);
|
|
5593
|
+
};
|
|
5594
|
+
_this.onShippingMethodSelected = function (event) {
|
|
5595
|
+
_this.selectedShippingMethodId = event.shippingMethod.identifier;
|
|
5596
|
+
var update = {
|
|
5597
|
+
newTotal: {
|
|
5598
|
+
label: _this.meta.amount_label,
|
|
5599
|
+
amount: _this.meta.amount.toString(),
|
|
5600
|
+
type: "final"
|
|
5601
|
+
}
|
|
5602
|
+
};
|
|
5603
|
+
_this.paymentSession.completeShippingMethodSelection(update);
|
|
5604
|
+
};
|
|
5605
|
+
_this.parseUpdateData = function (data) {
|
|
5606
|
+
// From Apple docs (https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment/1916097-shippingcontact):
|
|
5607
|
+
// Before the user authorizes the transaction with Touch ID, Face ID, or passcode, you receive redacted address information
|
|
5608
|
+
return {
|
|
5609
|
+
shipping: {
|
|
5610
|
+
address_city: data.locality,
|
|
5611
|
+
address_state: data.administrativeArea,
|
|
5612
|
+
address_postcode: data.postalCode,
|
|
5613
|
+
address_country: data.countryCode
|
|
5614
|
+
}
|
|
5615
|
+
};
|
|
5616
|
+
};
|
|
5617
|
+
_this.formatShippingOptions = function (shipping_options) {
|
|
5618
|
+
return shipping_options.map(function (o) {
|
|
5619
|
+
return {
|
|
5620
|
+
identifier: o.id,
|
|
5621
|
+
label: o.label,
|
|
5622
|
+
detail: (o === null || o === void 0 ? void 0 : o.detail) || '',
|
|
5623
|
+
amount: o.amount
|
|
5624
|
+
};
|
|
5625
|
+
});
|
|
5626
|
+
};
|
|
5566
5627
|
_this.eventEmitter = eventEmitter;
|
|
5567
5628
|
return _this;
|
|
5568
5629
|
}
|
|
@@ -5589,17 +5650,25 @@
|
|
|
5589
5650
|
return;
|
|
5590
5651
|
}
|
|
5591
5652
|
return this.checkAvailability().then(function (available) {
|
|
5653
|
+
var _a;
|
|
5592
5654
|
if (!available) {
|
|
5593
5655
|
_this2.eventEmitter.emit(WALLET_EVENT.UNAVAILABLE, { event: WALLET_EVENT.UNAVAILABLE, data: { wallet: WALLET_TYPE.APPLE } });
|
|
5594
5656
|
return;
|
|
5595
5657
|
}
|
|
5658
|
+
// Store default shipping option
|
|
5659
|
+
if (_this2.meta.request_shipping && _this2.meta.shipping_options) _this2.selectedShippingMethodId = (_a = _this2.meta.shipping_options[0]) === null || _a === void 0 ? void 0 : _a.id;
|
|
5596
5660
|
_this2.mount(container);
|
|
5597
5661
|
}).catch(function (err) {
|
|
5598
5662
|
return console.error("Error checking ApplePay availability", err);
|
|
5599
5663
|
});
|
|
5600
5664
|
}
|
|
5601
|
-
|
|
5602
|
-
|
|
5665
|
+
}, {
|
|
5666
|
+
key: "update",
|
|
5667
|
+
value: function update(data) {
|
|
5668
|
+
var _a, _b;
|
|
5669
|
+
if ((_a = data === null || data === void 0 ? void 0 : data.body) === null || _a === void 0 ? void 0 : _a.amount) this.meta.amount = data.body.amount;
|
|
5670
|
+
if ((_b = data === null || data === void 0 ? void 0 : data.body) === null || _b === void 0 ? void 0 : _b.shipping_options) this.meta.shipping_options = data.body.shipping_options;
|
|
5671
|
+
}
|
|
5603
5672
|
}, {
|
|
5604
5673
|
key: "checkAvailability",
|
|
5605
5674
|
value: function checkAvailability() {
|
|
@@ -5637,36 +5706,26 @@
|
|
|
5637
5706
|
this.paymentSession = new ApplePaySession(3, this.createRequest());
|
|
5638
5707
|
this.paymentSession.onvalidatemerchant = this.onValidateMerchant;
|
|
5639
5708
|
this.paymentSession.onpaymentauthorized = this.onPaymentAuthorized;
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
// this.paymentSession.onshippingmethodselected = this.onShippingMethodSelected;
|
|
5709
|
+
this.paymentSession.onshippingcontactselected = this.onShippingContactSelected;
|
|
5710
|
+
this.paymentSession.onshippingmethodselected = this.onShippingMethodSelected;
|
|
5643
5711
|
this.paymentSession.begin();
|
|
5644
5712
|
}
|
|
5645
5713
|
}, {
|
|
5646
5714
|
key: "createRequest",
|
|
5647
5715
|
value: function createRequest() {
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
// shippingMethods: this.meta.shipping_options.map(o => ({
|
|
5658
|
-
// identifier: o.id,
|
|
5659
|
-
// label: o.label,
|
|
5660
|
-
// detail: o?.detail || '',
|
|
5661
|
-
// amount: o.amount,
|
|
5662
|
-
// }))
|
|
5663
|
-
// }),
|
|
5664
|
-
total: {
|
|
5716
|
+
// In case Merchants decide to use other values they should provide all ApplePayPaymentRequest fields at "meta.raw_data_initialization".
|
|
5717
|
+
// https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest
|
|
5718
|
+
if (this.meta.raw_data_initialization) {
|
|
5719
|
+
this.meta.raw_data_initialization.total.amount = this.meta.amount.toString();
|
|
5720
|
+
if (this.meta.request_shipping && this.meta.shipping_options) this.meta.raw_data_initialization.shippingMethods = this.formatShippingOptions(this.meta.shipping_options);
|
|
5721
|
+
}
|
|
5722
|
+
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.meta.request_shipping && _extends({ requiredShippingContactFields: ["postalAddress", "name", "phone", "email"] }, this.meta.shipping_options && {
|
|
5723
|
+
shippingMethods: this.formatShippingOptions(this.meta.shipping_options)
|
|
5724
|
+
})), { total: {
|
|
5665
5725
|
label: this.meta.amount_label,
|
|
5666
5726
|
amount: this.meta.amount.toString(),
|
|
5667
5727
|
type: "final"
|
|
5668
|
-
}
|
|
5669
|
-
};
|
|
5728
|
+
} });
|
|
5670
5729
|
}
|
|
5671
5730
|
}, {
|
|
5672
5731
|
key: "getMerchantSession",
|
|
@@ -5675,11 +5734,7 @@
|
|
|
5675
5734
|
|
|
5676
5735
|
return new Promise(function (resolve, reject) {
|
|
5677
5736
|
return _this5.eventEmitter.emit(WALLET_EVENT.CALLBACK, {
|
|
5678
|
-
data: {
|
|
5679
|
-
request_type: "CREATE_SESSION",
|
|
5680
|
-
wallet_type: WALLET_TYPE.APPLE,
|
|
5681
|
-
session_id: window.location.hostname
|
|
5682
|
-
},
|
|
5737
|
+
data: _extends({ request_type: "CREATE_SESSION", wallet_type: WALLET_TYPE.APPLE, session_id: window.location.hostname }, _this5.meta.request_shipping && { request_shipping: _this5.meta.request_shipping }),
|
|
5683
5738
|
onSuccess: function onSuccess(res) {
|
|
5684
5739
|
return resolve(res);
|
|
5685
5740
|
},
|
|
@@ -5718,6 +5773,13 @@
|
|
|
5718
5773
|
value: function getGatewayName() {
|
|
5719
5774
|
return WALLET_GATEWAY.MASTERCARD;
|
|
5720
5775
|
}
|
|
5776
|
+
}, {
|
|
5777
|
+
key: "update",
|
|
5778
|
+
value: function update(data) {
|
|
5779
|
+
this.childWallets.forEach(function (child) {
|
|
5780
|
+
return child.update(data);
|
|
5781
|
+
});
|
|
5782
|
+
}
|
|
5721
5783
|
}]);
|
|
5722
5784
|
return MastercardWalletService;
|
|
5723
5785
|
}(WalletService);
|
|
@@ -5947,6 +6009,8 @@
|
|
|
5947
6009
|
* @param {boolean} [request_payer_email] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
|
|
5948
6010
|
* @param {boolean} [request_payer_phone] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
|
|
5949
6011
|
* @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].
|
|
6012
|
+
* @param {array} [shipping_options] Used to provide available shipping options. Optional for [ApplePay]. N/A for the other wallets.
|
|
6013
|
+
* @param {object} [raw_data_initialization] Used to provide values to initialize wallet with raw data. Optional for [ApplePay]. N/A for the other wallets.
|
|
5950
6014
|
* @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].
|
|
5951
6015
|
* @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.
|
|
5952
6016
|
* @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.
|
|
@@ -6018,7 +6082,7 @@
|
|
|
6018
6082
|
}
|
|
6019
6083
|
/**
|
|
6020
6084
|
* Triggers the update process of the wallet, if available.
|
|
6021
|
-
* Currently supported by Flypay and
|
|
6085
|
+
* Currently supported by Flypay, Paypal and ApplePay via MPGS Wallets.
|
|
6022
6086
|
*
|
|
6023
6087
|
* @example
|
|
6024
6088
|
* var button = new WalletButtons(
|
|
@@ -6033,6 +6097,41 @@
|
|
|
6033
6097
|
* updateChargeAmountInBackend(data);
|
|
6034
6098
|
* button.update({ success: true });
|
|
6035
6099
|
* });
|
|
6100
|
+
*
|
|
6101
|
+
* @example
|
|
6102
|
+
* // ApplePay via MPGS example:
|
|
6103
|
+
* var button = new WalletButtons(
|
|
6104
|
+
* '#buttons',
|
|
6105
|
+
* token,
|
|
6106
|
+
* {
|
|
6107
|
+
* amount_label: 'Total',
|
|
6108
|
+
* country: 'AU',
|
|
6109
|
+
* ...
|
|
6110
|
+
* }
|
|
6111
|
+
* );
|
|
6112
|
+
* button.on('update', (data) => {
|
|
6113
|
+
* updateChargeAmountInBackend(data);
|
|
6114
|
+
* button.update({
|
|
6115
|
+
* success: true,
|
|
6116
|
+
* body: {
|
|
6117
|
+
* amount: 15,
|
|
6118
|
+
* shipping_options: [
|
|
6119
|
+
* {
|
|
6120
|
+
* id: "NEW-FreeShip",
|
|
6121
|
+
* label: "NEW - Free Shipping",
|
|
6122
|
+
* detail: "Arrives in 3 to 5 days",
|
|
6123
|
+
* amount: "0.00"
|
|
6124
|
+
* },
|
|
6125
|
+
* {
|
|
6126
|
+
* id: "NEW - FastShip",
|
|
6127
|
+
* label: "NEW - Fast Shipping",
|
|
6128
|
+
* detail: "Arrives in less than 1 day",
|
|
6129
|
+
* amount: "10.00"
|
|
6130
|
+
* }
|
|
6131
|
+
* ]
|
|
6132
|
+
* }
|
|
6133
|
+
* });
|
|
6134
|
+
* });
|
|
6036
6135
|
*/
|
|
6037
6136
|
|
|
6038
6137
|
}, {
|