@paydock/client-sdk 1.10.73-beta → 1.10.77-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
@@ -4603,10 +4603,42 @@ After you initialized the 3ds charge via `v1/charges/standalone-3ds` API endpoin
4603
4603
  </html>
4604
4604
  ```
4605
4605
 
4606
- **The chargeAuthSuccess event is executed both for frictionless flow, or for challenge flow after the customer has correctly authenticated with the bank using whatever challenge imposed.**
4607
- **The chargeAuthChallenge event is sent before starting a challenge flow (i.e. opening an IFrame for the customer to complete a challenge with ther bank)**
4608
- **The chargeAuthDecoupled event is sent when the flow is a decoupled challenge, alongside a `data.result.description` field that you must show to the customer, indicating the method the user must use to authenticate. For example this may happen by having the cardholder authenticating directly with their banking app through biometrics. Once the end customer does this, the Canvas3ds will be able to recognize the challenge result is ready and will either produce a chargeAuthSuccess or chargeAuthReject event**
4609
- **The error event is sent if an unexpected issue with the client library occurs. In such scenarios, you should consider the autentication process as interrupted**
4606
+ The chargeAuthSuccess event is executed both for frictionless flow, or for challenge flow after the customer has correctly authenticated with the bank using whatever challenge imposed.
4607
+ The chargeAuthChallenge event is sent before starting a challenge flow (i.e. opening an IFrame for the customer to complete a challenge with ther bank)
4608
+ The chargeAuthDecoupled event is sent when the flow is a decoupled challenge, alongside a `data.result.description` field that you must show to the customer, indicating the method the user must use to authenticate. For example this may happen by having the cardholder authenticating directly with their banking app through biometrics. Once the end customer does this, the Canvas3ds will be able to recognize the challenge result is ready and will either produce a chargeAuthSuccess or chargeAuthReject event
4609
+ The error event is sent if an unexpected issue with the client library occurs. In such scenarios, you should consider the autentication process as interrupted
4610
+
4611
+ ### Event and Values
4612
+
4613
+ | Event Value | Type | Description |
4614
+ | ------------------- | ------------------- | -------------------------------------------------------------- |
4615
+ | chargeAuthSuccess | <code>object</code> | Instance of [ChargeEventResponse](#cb_chargeEventResponse) |
4616
+ | chargeAuthReject | <code>object</code> | Instance of [ChargeEventResponse](#cb_chargeEventResponse) |
4617
+ | chargeAuthChallenge | <code>object</code> | Instance of [ChargeEventResponse](#cb_chargeEventResponse) |
4618
+ | chargeAuthDecoupled | <code>object</code> | Instance of [ChargeEventResponse](#cb_chargeEventResponse) |
4619
+ | error | <code>object</code> | Instance of [chargeError](#cb_chargeError) |
4620
+
4621
+ ## Response Values
4622
+
4623
+ <a name="cb_chargeEventResponse" id="cb_chargeEventResponse"></a>
4624
+
4625
+ ### ChargeEventResponse
4626
+
4627
+ | Param | Type | Description |
4628
+ | ------------------------------- | ------------------------------ | -------------------------------------------------------------------------------------------------- |
4629
+ | status | <code>string</code> | status for the event transaction |
4630
+ | charge_3ds_id | <code>string</code> | Universal unique transaction identifier to identify the transaction |
4631
+ | <code>result.description</code> | <code>string</code> [Optional] | field that you must show to the customer, indicating the method the user must use to authenticate. |
4632
+
4633
+ ### ChargeError
4634
+
4635
+ <a name="cb_chargeError" id="cb_chargeError"></a>
4636
+
4637
+ | Param | Type | Description |
4638
+ | ------------- | ------------------- | ------------------------------------------------------------------- |
4639
+ | error | <code>object</code> | error response |
4640
+ | charge_3ds_id | <code>string</code> | Universal unique transaction identifier to identify the transaction |
4641
+
4610
4642
 
4611
4643
  ## Vault Display Widget
4612
4644
  You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#vault-display-widget)
@@ -4881,6 +4913,7 @@ Interface of data used by the wallet checkout and payment proccess.
4881
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]. |
4882
4914
  | [country] | <code>string</code> | Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal]. |
4883
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. |
4884
4917
  | [request_payer_name] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
4885
4918
  | [request_payer_email] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
4886
4919
  | [request_payer_phone] | <code>boolean</code> | Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets. |
@@ -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({ 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() && {
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,12 +6112,13 @@
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"],
6077
- allowedCardNetworks: ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"]
6120
+ allowedCardNetworks: ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"],
6121
+ billingAddressRequired: !!this.meta.show_billing_address
6078
6122
  }
6079
6123
  };
6080
6124
  }
@@ -6358,6 +6402,7 @@
6358
6402
  * @param {string} [amount_label] Label shown next to the total amount to be paid. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal].
6359
6403
  * @param {string} [country] Country of the user. 2 letter ISO code format. Required for [Stripe, ApplePay, GooglePay]. N/A for [FlyPay, PayPal].
6360
6404
  * @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.
6405
+ * @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.
6361
6406
  * @param {boolean} [request_payer_name] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
6362
6407
  * @param {boolean} [request_payer_email] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.
6363
6408
  * @param {boolean} [request_payer_phone] Used mainly for fraud purposes - recommended set to true. Optional for [Stripe]. N/A for other wallets.