@paydock/client-sdk 1.10.76-beta → 1.10.79-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
 
@@ -4972,7 +4972,7 @@ Interface of Shipping Options for PayPal
4972
4972
  <a name="WalletButtons" id="WalletButtons"></a>
4973
4973
 
4974
4974
  ## WalletButtons
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
+ Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)
4976
4976
 
4977
4977
  **Kind**: global class
4978
4978
 
package/api.js ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/api';
@@ -5606,10 +5606,11 @@
5606
5606
  });
5607
5607
  };
5608
5608
  _this.onShippingMethodSelected = function (event) {
5609
+ var _a, _b;
5609
5610
  _this.latestShippingData.shippingMethod = event.shippingMethod;
5610
5611
  var update = {
5611
5612
  newTotal: {
5612
- label: _this.meta.amount_label,
5613
+ 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),
5613
5614
  amount: _this.meta.amount.toString(),
5614
5615
  type: "final"
5615
5616
  }
@@ -5659,6 +5660,30 @@
5659
5660
  var _a, _b, _c;
5660
5661
  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) || '';
5661
5662
  }
5663
+ }, {
5664
+ key: "getMetaStyles",
5665
+ value: function getMetaStyles() {
5666
+ var _a, _b, _c;
5667
+ 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') {
5668
+ var metaStyles = JSON.parse(JSON.stringify((_c = this.meta) === null || _c === void 0 ? void 0 : _c.style));
5669
+ if ('google' in metaStyles) metaStyles === null || metaStyles === void 0 ? true : delete metaStyles.google; // to offer backward compatibility
5670
+ if ('apple' in metaStyles) return metaStyles === null || metaStyles === void 0 ? void 0 : metaStyles.apple;else return metaStyles; // to offer backward compatibility
5671
+ } else {
5672
+ return null;
5673
+ }
5674
+ }
5675
+ }, {
5676
+ key: "getMetaRawDataInitialization",
5677
+ value: function getMetaRawDataInitialization() {
5678
+ var _a, _b, _c, _d;
5679
+ 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') {
5680
+ var metaRawDataInit = JSON.parse(JSON.stringify((_d = this.meta) === null || _d === void 0 ? void 0 : _d.raw_data_initialization));
5681
+ if ('google' in metaRawDataInit) metaRawDataInit === null || metaRawDataInit === void 0 ? true : delete metaRawDataInit.google; // to offer backward compatibility
5682
+ if ('apple' in metaRawDataInit) return metaRawDataInit === null || metaRawDataInit === void 0 ? void 0 : metaRawDataInit.apple;else return metaRawDataInit; // to offer backward compatibility
5683
+ } else {
5684
+ return null;
5685
+ }
5686
+ }
5662
5687
  }, {
5663
5688
  key: "isShippingRequired",
5664
5689
  value: function isShippingRequired() {
@@ -5766,11 +5791,13 @@
5766
5791
  value: function createRequest() {
5767
5792
  // In case Merchants decide to use other values they should provide all ApplePayPaymentRequest fields at "meta.raw_data_initialization".
5768
5793
  // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest
5769
- if (this.meta.raw_data_initialization) {
5770
- this.meta.raw_data_initialization.total.amount = this.meta.amount.toString();
5771
- if (this.isShippingRequired() && this.hasShippingOptions()) this.meta.raw_data_initialization.shippingMethods = this.formatShippingOptions(this.meta.shipping_options);
5794
+ var _a;
5795
+ var rawDataInitialization = this.getMetaRawDataInitialization();
5796
+ if (rawDataInitialization && (typeof rawDataInitialization === "undefined" ? "undefined" : _typeof(rawDataInitialization)) === 'object') {
5797
+ 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() };
5798
+ if (this.isShippingRequired() && this.hasShippingOptions()) rawDataInitialization.shippingMethods = this.formatShippingOptions(this.meta.shipping_options);
5772
5799
  }
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() && {
5800
+ 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() && {
5774
5801
  shippingMethods: this.formatShippingOptions(this.meta.shipping_options)
5775
5802
  })), { total: {
5776
5803
  label: this.meta.amount_label,
@@ -5798,8 +5825,8 @@
5798
5825
  }, {
5799
5826
  key: "createButtonStyle",
5800
5827
  value: function createButtonStyle() {
5801
- var _a, _b, _c, _d;
5802
- 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 ";
5828
+ var _a, _b;
5829
+ 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 ";
5803
5830
  }
5804
5831
  }]);
5805
5832
  return AppleWalletService;
@@ -5858,6 +5885,18 @@
5858
5885
  var _a, _b, _c;
5859
5886
  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
5887
  }
5888
+ }, {
5889
+ key: "getMetaStyles",
5890
+ value: function getMetaStyles() {
5891
+ var _a, _b, _c, _d;
5892
+ 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;
5893
+ }
5894
+ }, {
5895
+ key: "getMetaRawDataInitialization",
5896
+ value: function getMetaRawDataInitialization() {
5897
+ var _a, _b, _c, _d, _e;
5898
+ 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;
5899
+ }
5861
5900
  }, {
5862
5901
  key: "isShippingRequired",
5863
5902
  value: function isShippingRequired() {
@@ -5956,11 +5995,14 @@
5956
5995
  value: function mount(container) {
5957
5996
  var _this3 = this;
5958
5997
 
5998
+ var _a, _b, _c;
5959
5999
  container.getElement().appendChild(this.paymentsClient.createButton({
5960
- buttonSizeMode: "fill",
5961
6000
  onClick: function onClick() {
5962
6001
  return _this3.loadPaymentData();
5963
- }
6002
+ },
6003
+ buttonType: ((_a = this.getMetaStyles()) === null || _a === void 0 ? void 0 : _a.button_type) || 'pay',
6004
+ buttonSizeMode: ((_b = this.getMetaStyles()) === null || _b === void 0 ? void 0 : _b.button_size_mode) || "fill",
6005
+ buttonColor: ((_c = this.getMetaStyles()) === null || _c === void 0 ? void 0 : _c.button_color) || "default"
5964
6006
  }));
5965
6007
  }
5966
6008
  }, {
@@ -6033,7 +6075,8 @@
6033
6075
  return {
6034
6076
  apiVersion: 2,
6035
6077
  apiVersionMinor: 0,
6036
- allowedPaymentMethods: [this.createCardData()]
6078
+ allowedPaymentMethods: [this.createCardData()],
6079
+ existingPaymentMethodRequired: true
6037
6080
  };
6038
6081
  }
6039
6082
  }, {
@@ -6069,8 +6112,8 @@
6069
6112
  }, {
6070
6113
  key: "createCardData",
6071
6114
  value: function createCardData() {
6072
- return {
6073
- // TODO: Add raw_data_initialization as in ApplePay
6115
+ var rawDataInitialization = this.getMetaRawDataInitialization();
6116
+ return rawDataInitialization || {
6074
6117
  type: "CARD",
6075
6118
  parameters: {
6076
6119
  allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
@@ -6404,7 +6447,7 @@
6404
6447
  * @param {string} [type] Type of the Shipping Option. Values can be 'SHIPPING' or 'PICKUP'. Required.
6405
6448
  */
6406
6449
  /**
6407
- * Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)
6450
+ * Class WalletButtons to work with different E-Wallets within html (currently supports Apple Pay, Google Pay and Apple Pay via Stripe, Flypay, Paypal)
6408
6451
  * @constructor
6409
6452
  *
6410
6453
  * @example