@paydock/client-sdk 1.10.72-beta → 1.10.76-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.
Files changed (29) hide show
  1. package/README.md +90 -17
  2. package/bundles/widget.umd.js +414 -61
  3. package/bundles/widget.umd.min.js +1 -1
  4. package/lib/components/param.d.ts +20 -3
  5. package/lib/components/param.js +2 -0
  6. package/lib/components/param.js.map +1 -1
  7. package/lib/wallet-buttons/apple.wallet-service.d.ts +13 -1
  8. package/lib/wallet-buttons/apple.wallet-service.js +67 -41
  9. package/lib/wallet-buttons/apple.wallet-service.js.map +1 -1
  10. package/lib/wallet-buttons/flypay.wallet-service.js +1 -4
  11. package/lib/wallet-buttons/flypay.wallet-service.js.map +1 -1
  12. package/lib/wallet-buttons/google.wallet-service.d.ts +29 -0
  13. package/lib/wallet-buttons/google.wallet-service.js +241 -0
  14. package/lib/wallet-buttons/google.wallet-service.js.map +1 -0
  15. package/lib/wallet-buttons/interfaces.d.ts +4 -1
  16. package/lib/wallet-buttons/mastercard.wallet-service.js +7 -1
  17. package/lib/wallet-buttons/mastercard.wallet-service.js.map +1 -1
  18. package/lib/wallet-buttons/paypal.wallet-service.js +3 -3
  19. package/lib/wallet-buttons/paypal.wallet-service.js.map +1 -1
  20. package/lib/wallet-buttons/stripe.wallet-service.d.ts +1 -0
  21. package/lib/wallet-buttons/stripe.wallet-service.js +9 -3
  22. package/lib/wallet-buttons/stripe.wallet-service.js.map +1 -1
  23. package/lib/wallet-buttons/wallet-buttons.d.ts +45 -13
  24. package/lib/wallet-buttons/wallet-buttons.js +38 -12
  25. package/lib/wallet-buttons/wallet-buttons.js.map +1 -1
  26. package/lib/wallet-buttons/wallet-service.d.ts +2 -1
  27. package/lib/wallet-buttons/wallet-service.js.map +1 -1
  28. package/package.json +2 -1
  29. package/slate.md +36 -4
@@ -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, { event: WALLET_EVENT.UNAVAILABLE, data: null });
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, { event: WALLET_EVENT.UNAVAILABLE, data: null });
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: ((_a = data.selected_shipping_option) === null || _a === void 0 ? void 0 : _a.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, { event: WALLET_EVENT.UNAVAILABLE, data: null });
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: (_a = card === null || card === void 0 ? void 0 : card.wallet) === null || _a === void 0 ? void 0 : _a.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
- var parsedCallbackData = _this.parseUpdateData(event.shippingContact);
5600
+ _this.latestShippingData.shippingContact = event.shippingContact;
5601
+ var parsedCallbackData = _this.parseUpdateData(_this.latestShippingData);
5590
5602
  _this.eventEmitter.emit(WALLET_EVENT.UPDATE, parsedCallbackData);
5591
- var update = _extends({ newTotal: {
5592
- label: _this.meta.amount_label,
5593
- amount: _this.meta.amount.toString(),
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.selectedShippingMethodId = event.shippingMethod.identifier;
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
- shipping: {
5616
- address_city: data.locality,
5617
- address_state: data.administrativeArea,
5618
- address_postcode: data.postalCode,
5619
- address_country: data.countryCode
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, { event: WALLET_EVENT.UNAVAILABLE, data: { wallet: WALLET_TYPE.APPLE } });
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, { event: WALLET_EVENT.UNAVAILABLE, data: { wallet: WALLET_TYPE.APPLE } });
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.meta.request_shipping && _this2.meta.shipping_options) _this2.selectedShippingMethodId = (_a = _this2.meta.shipping_options[0]) === null || _a === void 0 ? void 0 : _a.id;
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 ((_a = data === null || data === void 0 ? void 0 : data.body) === null || _a === void 0 ? void 0 : _a.amount) this.meta.amount = data.body.amount;
5676
- 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;
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.meta.request_shipping && this.meta.shipping_options) this.meta.raw_data_initialization.shippingMethods = this.formatShippingOptions(this.meta.shipping_options);
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.meta.request_shipping && _extends({ requiredShippingContactFields: ["postalAddress", "name", "phone", "email"] }, this.meta.shipping_options && {
5773
+ return this.meta.raw_data_initialization ? this.meta.raw_data_initialization : _extends(_extends(_extends({ countryCode: this.meta.country.toUpperCase(), currencyCode: this.meta.currency.toUpperCase(), merchantCapabilities: ["supports3DS", "supportsCredit", "supportsDebit"], supportedNetworks: ["visa", "masterCard", "amex", "discover"] }, this.meta.show_billing_address && { 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.meta.request_shipping && { request_shipping: _this5.meta.request_shipping }),
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,284 @@
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
+ billingAddressRequired: !!this.meta.show_billing_address
6079
+ }
6080
+ };
6081
+ }
6082
+ }]);
6083
+ return GoogleWalletService;
6084
+ }(WalletService);
6085
+
5763
6086
  var MastercardWalletService = function (_WalletService) {
5764
6087
  inherits(MastercardWalletService, _WalletService);
5765
6088
 
@@ -5771,8 +6094,12 @@
5771
6094
  createClass(MastercardWalletService, [{
5772
6095
  key: "initializeChildWallets",
5773
6096
  value: function initializeChildWallets() {
6097
+ var _a, _b, _c, _d, _e, _f;
5774
6098
  this.childWallets = [];
5775
- if (!this.meta.wallets || this.meta.wallets.includes(WALLET_TYPE.APPLE)) this.childWallets.push(new AppleWalletService(this.publicKey, this.meta, this.getGatewayName(), this.eventEmitter));
6099
+ 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);
6100
+ 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);
6101
+ 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));
6102
+ 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
6103
  }
5777
6104
  }, {
5778
6105
  key: "getGatewayName",
@@ -6029,30 +6356,52 @@
6029
6356
  * @interface IWalletMeta
6030
6357
  *
6031
6358
  * @type {object}
6032
- * @param {string} [amount_label] Label shown next to the total amount to be paid. Required for [Stripe, ApplePay]. N/A for [FlyPay, PayPal].
6033
- * @param {string} [country] Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay]. N/A for [FlyPay, PayPal].
6359
+ * @param {string} [amount_label] Label shown next to the total amount to be paid. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal].
6360
+ * @param {string} [country] Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal].
6034
6361
  * @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.
6362
+ * @param {boolean} [show_billing_address] Used to hide/show the billing address on ApplePay and GooglePay popups. Default value is false. Optional for [ApplePay, GooglePay]. N/A for other wallets.
6035
6363
  * @param {boolean} [request_payer_name] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
6036
6364
  * @param {boolean} [request_payer_email] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
6037
6365
  * @param {boolean} [request_payer_phone] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
6038
- * @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].
6039
- * @param {Array.<IShippingOption>} [shipping_options] Used to provide available shipping options. Optional for [ApplePay]. N/A for the other wallets.
6366
+ * @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].
6367
+ * @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.
6368
+ * @param {string} [merchant_name] Merchant Name used for GooglePay integration via MPGS. Required for [GooglePay]. N/A for other wallets.
6040
6369
  * @param {object} [raw_data_initialization] Used to provide values to initialize wallet with raw data. Optional for [ApplePay]. N/A for the other wallets.
6041
6370
  * @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].
6042
6371
  * @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.
6043
- * @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.
6372
+ * @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.
6044
6373
  */
6045
6374
  /**
6046
- * Interface of Shipping Options.
6047
- * @interface IShippingOption
6375
+ * Interface of Shipping Options for ApplePay
6376
+ * @interface IApplePayShippingOption
6048
6377
  *
6049
6378
  * @type {object}
6050
6379
  * @param {string} [id] Identifier of the Shipping Option. Required.
6051
6380
  * @param {string} [label] Identifier of the Shipping Option. Required.
6052
6381
  * @param {string} [amount] Amount of the Shipping Option. Required.
6382
+ * @param {string} [detail] Details of the Shipping Option. Required.
6383
+ * @param {string} [type] Type of the Shipping Option. Values can be 'ELECTRONIC', 'GROUND', 'NOT_SHIPPED', 'OVERNIGHT', 'PICKUP', 'PRIORITY', 'SAME_DAY'. Optional.
6384
+ */
6385
+ /**
6386
+ * Interface of Shipping Options for GooglePay
6387
+ * @interface IGooglePayShippingOption
6388
+ *
6389
+ * @type {object}
6390
+ * @param {string} [id] Identifier of the Shipping Option. Required.
6391
+ * @param {string} [label] Identifier of the Shipping Option. Required.
6053
6392
  * @param {string} [detail] Details of the Shipping Option. Optional.
6054
- * @param {string} [currency] Currency of the Shipping Option. Optional.
6055
- * @param {string} [type] Type of the Shipping Option. Optional.
6393
+ * @param {string} [type] Type of the Shipping Option. Values can be 'ELECTRONIC', 'GROUND', 'NOT_SHIPPED', 'OVERNIGHT', 'PICKUP', 'PRIORITY', 'SAME_DAY'. Optional.
6394
+ */
6395
+ /**
6396
+ * Interface of Shipping Options for PayPal
6397
+ * @interface IPayPalShippingOption
6398
+ *
6399
+ * @type {object}
6400
+ * @param {string} [id] Identifier of the Shipping Option. Required.
6401
+ * @param {string} [label] Identifier of the Shipping Option. Required.
6402
+ * @param {string} [amount] Amount of the Shipping Option. Required.
6403
+ * @param {string} [currency] Currency of the Shipping Option. Required.
6404
+ * @param {string} [type] Type of the Shipping Option. Values can be 'SHIPPING' or 'PICKUP'. Required.
6056
6405
  */
6057
6406
  /**
6058
6407
  * Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)
@@ -6115,13 +6464,13 @@
6115
6464
  this.setupServiceCallbacks();
6116
6465
  this.service.load(this.container);
6117
6466
  } catch (err) {
6118
- this.eventEmitter.emit(EVENT$2.UNAVAILABLE, { event: EVENT$2.UNAVAILABLE, data: null });
6467
+ this.eventEmitter.emit(EVENT$2.UNAVAILABLE, null);
6119
6468
  throw err;
6120
6469
  }
6121
6470
  }
6122
6471
  /**
6123
6472
  * Triggers the update process of the wallet, if available.
6124
- * Currently supported by Flypay, Paypal and ApplePay via MPGS Wallets.
6473
+ * Currently supported by Flypay, Paypal and ApplePay/GooglePay via MPGS Wallets.
6125
6474
  *
6126
6475
  * @example
6127
6476
  * var button = new WalletButtons(
@@ -6245,6 +6594,7 @@
6245
6594
  }
6246
6595
  /**
6247
6596
  * User to subscribe to the no button available event. This method is used after loading when the button is not available.
6597
+ * 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
6248
6598
  * Important: Do not perform thread blocking operations in callback such as window.alert() calls.
6249
6599
  *
6250
6600
  * @example
@@ -6255,6 +6605,9 @@
6255
6605
  * @example
6256
6606
  * button.onUnavailable().then(() => console.log('No wallet buttons available'));
6257
6607
  *
6608
+ * @example
6609
+ * button.onUnavailable(function (data) {console.log('data.wallet :: ', data.wallet)});
6610
+ *
6258
6611
  * @param {listener} [handler] - Function to be called when no button is available.
6259
6612
  */
6260
6613
 
@@ -6396,8 +6749,8 @@
6396
6749
  value: function setupUnavailableCallback() {
6397
6750
  var _this7 = this;
6398
6751
 
6399
- this.service.on(WALLET_EVENT.UNAVAILABLE, function () {
6400
- return _this7.eventEmitter.emit(EVENT$2.UNAVAILABLE, { event: EVENT$2.UNAVAILABLE, data: null });
6752
+ this.service.on(WALLET_EVENT.UNAVAILABLE, function (eventData) {
6753
+ return _this7.eventEmitter.emit(EVENT$2.UNAVAILABLE, { event: EVENT$2.UNAVAILABLE, data: eventData });
6401
6754
  });
6402
6755
  }
6403
6756
  }, {