@paydock/client-sdk 1.10.74-beta → 1.10.78-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 CHANGED
@@ -4872,7 +4872,7 @@ The final method to beginning, the load process of widget to html
4872
4872
 
4873
4873
  <dl>
4874
4874
  <dt><a href="#WalletButtons">WalletButtons</a></dt>
4875
- <dd><p>Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)</p>
4875
+ <dd><p>Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)</p>
4876
4876
  </dd>
4877
4877
  </dl>
4878
4878
 
@@ -4913,6 +4913,7 @@ Interface of data used by the wallet checkout and payment proccess.
4913
4913
  | [amount_label] | <code>string</code> | Label shown next to the total amount to be paid. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal]. |
4914
4914
  | [country] | <code>string</code> | Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal]. |
4915
4915
  | [pay_later] | <code>string</code> | Used to enable Pay Later feature in PayPal Smart Checkout WalletButton integration when available. Optional for [PayPal]. N/A for other wallets. |
4916
+ | [show_billing_address] | <code>boolean</code> | 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. |
4916
4917
  | [request_payer_name] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
4917
4918
  | [request_payer_email] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
4918
4919
  | [request_payer_phone] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
@@ -4971,7 +4972,7 @@ Interface of Shipping Options for PayPal
4971
4972
  <a name="WalletButtons" id="WalletButtons"></a>
4972
4973
 
4973
4974
  ## WalletButtons
4974
- Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)
4975
+ Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)
4975
4976
 
4976
4977
  **Kind**: global class
4977
4978
 
@@ -5670,10 +5670,11 @@
5670
5670
  });
5671
5671
  };
5672
5672
  _this.onShippingMethodSelected = function (event) {
5673
+ var _a, _b;
5673
5674
  _this.latestShippingData.shippingMethod = event.shippingMethod;
5674
5675
  var update = {
5675
5676
  newTotal: {
5676
- label: _this.meta.amount_label,
5677
+ label: _this.meta.amount_label || ((_b = (_a = _this.getMetaRawDataInitialization()) === null || _a === void 0 ? void 0 : _a.total) === null || _b === void 0 ? void 0 : _b.label),
5677
5678
  amount: _this.meta.amount.toString(),
5678
5679
  type: "final"
5679
5680
  }
@@ -5723,6 +5724,30 @@
5723
5724
  var _a, _b, _c;
5724
5725
  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) || '';
5725
5726
  }
5727
+ }, {
5728
+ key: "getMetaStyles",
5729
+ value: function getMetaStyles() {
5730
+ var _a, _b, _c;
5731
+ if (((_a = this.meta) === null || _a === void 0 ? void 0 : _a.style) && _typeof((_b = this.meta) === null || _b === void 0 ? void 0 : _b.style) === 'object') {
5732
+ var metaStyles = JSON.parse(JSON.stringify((_c = this.meta) === null || _c === void 0 ? void 0 : _c.style));
5733
+ if ('google' in metaStyles) metaStyles === null || metaStyles === void 0 ? true : delete metaStyles.google; // to offer backward compatibility
5734
+ if ('apple' in metaStyles) return metaStyles === null || metaStyles === void 0 ? void 0 : metaStyles.apple;else return metaStyles; // to offer backward compatibility
5735
+ } else {
5736
+ return null;
5737
+ }
5738
+ }
5739
+ }, {
5740
+ key: "getMetaRawDataInitialization",
5741
+ value: function getMetaRawDataInitialization() {
5742
+ var _a, _b, _c, _d;
5743
+ if (((_a = this.meta) === null || _a === void 0 ? void 0 : _a.raw_data_initialization) && ((_b = this.meta) === null || _b === void 0 ? void 0 : _b.raw_data_initialization) && _typeof((_c = this.meta) === null || _c === void 0 ? void 0 : _c.raw_data_initialization) === 'object') {
5744
+ var metaRawDataInit = JSON.parse(JSON.stringify((_d = this.meta) === null || _d === void 0 ? void 0 : _d.raw_data_initialization));
5745
+ if ('google' in metaRawDataInit) metaRawDataInit === null || metaRawDataInit === void 0 ? true : delete metaRawDataInit.google; // to offer backward compatibility
5746
+ if ('apple' in metaRawDataInit) return metaRawDataInit === null || metaRawDataInit === void 0 ? void 0 : metaRawDataInit.apple;else return metaRawDataInit; // to offer backward compatibility
5747
+ } else {
5748
+ return null;
5749
+ }
5750
+ }
5726
5751
  }, {
5727
5752
  key: "isShippingRequired",
5728
5753
  value: function isShippingRequired() {
@@ -5830,11 +5855,13 @@
5830
5855
  value: function createRequest() {
5831
5856
  // In case Merchants decide to use other values they should provide all ApplePayPaymentRequest fields at "meta.raw_data_initialization".
5832
5857
  // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest
5833
- if (this.meta.raw_data_initialization) {
5834
- this.meta.raw_data_initialization.total.amount = this.meta.amount.toString();
5835
- if (this.isShippingRequired() && this.hasShippingOptions()) this.meta.raw_data_initialization.shippingMethods = this.formatShippingOptions(this.meta.shipping_options);
5858
+ var _a;
5859
+ var rawDataInitialization = this.getMetaRawDataInitialization();
5860
+ if (rawDataInitialization && (typeof rawDataInitialization === "undefined" ? "undefined" : _typeof(rawDataInitialization)) === 'object') {
5861
+ if (_typeof(rawDataInitialization.total) === 'object') rawDataInitialization.total.amount = this.meta.amount.toString();else rawDataInitialization.total = { label: ((_a = this.meta) === null || _a === void 0 ? void 0 : _a.amount_label) || '', amount: this.meta.amount.toString() };
5862
+ if (this.isShippingRequired() && this.hasShippingOptions()) rawDataInitialization.shippingMethods = this.formatShippingOptions(this.meta.shipping_options);
5836
5863
  }
5837
- 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() && {
5864
+ return rawDataInitialization || _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() && {
5838
5865
  shippingMethods: this.formatShippingOptions(this.meta.shipping_options)
5839
5866
  })), { total: {
5840
5867
  label: this.meta.amount_label,
@@ -5862,8 +5889,8 @@
5862
5889
  }, {
5863
5890
  key: "createButtonStyle",
5864
5891
  value: function createButtonStyle() {
5865
- var _a, _b, _c, _d;
5866
- return "\n .paydock-apple-container {\n width: 100%;\n height: 40px;\n }\n\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: " + (((_b = (_a = this.meta) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.button_type) || 'plain') + "\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n -apple-pay-button-type: " + (((_d = (_c = this.meta) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.button_type) || 'plain') + "\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n ";
5892
+ var _a, _b;
5893
+ return "\n .paydock-apple-container {\n width: 100%;\n height: 40px;\n }\n\n @supports (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: " + (((_a = this.getMetaStyles()) === null || _a === void 0 ? void 0 : _a.button_type) || 'plain') + "\n }\n .apple-pay-button-black {\n -apple-pay-button-style: black;\n }\n .apple-pay-button-white {\n -apple-pay-button-style: white;\n }\n .apple-pay-button-white-with-line {\n -apple-pay-button-style: white-outline;\n }\n }\n\n @supports not (-webkit-appearance: -apple-pay-button) {\n .apple-pay-button {\n display: inline-block;\n background-size: 100% 60%;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n border-radius: 5px;\n padding: 0px;\n box-sizing: border-box;\n min-width: 200px;\n min-height: 32px;\n max-height: 64px;\n -apple-pay-button-type: " + (((_b = this.getMetaStyles()) === null || _b === void 0 ? void 0 : _b.button_type) || 'plain') + "\n }\n .apple-pay-button-black {\n background-image: -webkit-named-image(apple-pay-logo-white);\n background-color: black;\n }\n .apple-pay-button-white {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n }\n .apple-pay-button-white-with-line {\n background-image: -webkit-named-image(apple-pay-logo-black);\n background-color: white;\n border: .5px solid black;\n }\n }\n ";
5867
5894
  }
5868
5895
  }]);
5869
5896
  return AppleWalletService;
@@ -5922,6 +5949,18 @@
5922
5949
  var _a, _b, _c;
5923
5950
  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;
5924
5951
  }
5952
+ }, {
5953
+ key: "getMetaStyles",
5954
+ value: function getMetaStyles() {
5955
+ var _a, _b, _c, _d;
5956
+ if (_typeof((_a = this.meta) === null || _a === void 0 ? void 0 : _a.style) === 'object' && 'google' in ((_b = this.meta) === null || _b === void 0 ? void 0 : _b.style)) return (_d = (_c = this.meta) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.google;else return null;
5957
+ }
5958
+ }, {
5959
+ key: "getMetaRawDataInitialization",
5960
+ value: function getMetaRawDataInitialization() {
5961
+ var _a, _b, _c, _d, _e;
5962
+ if (((_a = this.meta) === null || _a === void 0 ? void 0 : _a.raw_data_initialization) && _typeof((_b = this.meta) === null || _b === void 0 ? void 0 : _b.raw_data_initialization) === 'object' && 'google' in ((_c = this.meta) === null || _c === void 0 ? void 0 : _c.raw_data_initialization)) return (_e = (_d = this.meta) === null || _d === void 0 ? void 0 : _d.raw_data_initialization) === null || _e === void 0 ? void 0 : _e.google;else return null;
5963
+ }
5925
5964
  }, {
5926
5965
  key: "isShippingRequired",
5927
5966
  value: function isShippingRequired() {
@@ -6020,11 +6059,14 @@
6020
6059
  value: function mount(container) {
6021
6060
  var _this3 = this;
6022
6061
 
6062
+ var _a, _b, _c;
6023
6063
  container.getElement().appendChild(this.paymentsClient.createButton({
6024
- buttonSizeMode: "fill",
6025
6064
  onClick: function onClick() {
6026
6065
  return _this3.loadPaymentData();
6027
- }
6066
+ },
6067
+ buttonType: ((_a = this.getMetaStyles()) === null || _a === void 0 ? void 0 : _a.button_type) || 'pay',
6068
+ buttonSizeMode: ((_b = this.getMetaStyles()) === null || _b === void 0 ? void 0 : _b.button_size_mode) || "fill",
6069
+ buttonColor: ((_c = this.getMetaStyles()) === null || _c === void 0 ? void 0 : _c.button_color) || "default"
6028
6070
  }));
6029
6071
  }
6030
6072
  }, {
@@ -6097,7 +6139,8 @@
6097
6139
  return {
6098
6140
  apiVersion: 2,
6099
6141
  apiVersionMinor: 0,
6100
- allowedPaymentMethods: [this.createCardData()]
6142
+ allowedPaymentMethods: [this.createCardData()],
6143
+ existingPaymentMethodRequired: true
6101
6144
  };
6102
6145
  }
6103
6146
  }, {
@@ -6133,12 +6176,13 @@
6133
6176
  }, {
6134
6177
  key: "createCardData",
6135
6178
  value: function createCardData() {
6136
- return {
6137
- // TODO: Add raw_data_initialization as in ApplePay
6179
+ var rawDataInitialization = this.getMetaRawDataInitialization();
6180
+ return rawDataInitialization || {
6138
6181
  type: "CARD",
6139
6182
  parameters: {
6140
6183
  allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
6141
- allowedCardNetworks: ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"]
6184
+ allowedCardNetworks: ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"],
6185
+ billingAddressRequired: !!this.meta.show_billing_address
6142
6186
  }
6143
6187
  };
6144
6188
  }
@@ -6373,6 +6417,7 @@
6373
6417
  * @param {string} [amount_label] Label shown next to the total amount to be paid. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal].
6374
6418
  * @param {string} [country] Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal].
6375
6419
  * @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.
6420
+ * @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.
6376
6421
  * @param {boolean} [request_payer_name] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
6377
6422
  * @param {boolean} [request_payer_email] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
6378
6423
  * @param {boolean} [request_payer_phone] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
@@ -6417,7 +6462,7 @@
6417
6462
  * @param {string} [type] Type of the Shipping Option. Values can be 'SHIPPING' or 'PICKUP'. Required.
6418
6463
  */
6419
6464
  /**
6420
- * Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)
6465
+ * Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)
6421
6466
  * @constructor
6422
6467
  *
6423
6468
  * @example