@paydock/client-sdk 1.103.1 → 1.103.11-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 (36) hide show
  1. package/README.md +245 -21
  2. package/bundles/widget.umd.js +433 -160
  3. package/bundles/widget.umd.min.js +1 -1
  4. package/lib/components/container.d.ts +1 -0
  5. package/lib/components/container.js +3 -0
  6. package/lib/components/container.js.map +1 -1
  7. package/lib/components/wallet-background.d.ts +2 -1
  8. package/lib/components/wallet-background.js +4 -1
  9. package/lib/components/wallet-background.js.map +1 -1
  10. package/lib/configs/sdk.js +1 -1
  11. package/lib/wallet-buttons/apple.wallet-service.d.ts +2 -0
  12. package/lib/wallet-buttons/apple.wallet-service.js +38 -5
  13. package/lib/wallet-buttons/apple.wallet-service.js.map +1 -1
  14. package/lib/wallet-buttons/flypay-v2.wallet-service.d.ts +9 -1
  15. package/lib/wallet-buttons/flypay-v2.wallet-service.js +104 -131
  16. package/lib/wallet-buttons/flypay-v2.wallet-service.js.map +1 -1
  17. package/lib/wallet-buttons/google.wallet-service.d.ts +3 -0
  18. package/lib/wallet-buttons/google.wallet-service.js +41 -8
  19. package/lib/wallet-buttons/google.wallet-service.js.map +1 -1
  20. package/lib/wallet-buttons/helpers/flypay-v2.helper.d.ts +3 -0
  21. package/lib/wallet-buttons/helpers/flypay-v2.helper.js +151 -0
  22. package/lib/wallet-buttons/helpers/flypay-v2.helper.js.map +1 -0
  23. package/lib/wallet-buttons/index.d.ts +126 -0
  24. package/lib/wallet-buttons/index.js +126 -0
  25. package/lib/wallet-buttons/index.js.map +1 -1
  26. package/lib/wallet-buttons/interfaces.d.ts +3 -0
  27. package/lib/wallet-buttons/paypal.wallet-service.js +17 -2
  28. package/lib/wallet-buttons/paypal.wallet-service.js.map +1 -1
  29. package/lib/wallet-buttons/wallet-buttons.d.ts +62 -120
  30. package/lib/wallet-buttons/wallet-buttons.js +84 -60
  31. package/lib/wallet-buttons/wallet-buttons.js.map +1 -1
  32. package/lib/wallet-buttons/wallet-service.d.ts +7 -0
  33. package/lib/wallet-buttons/wallet-service.js +11 -0
  34. package/lib/wallet-buttons/wallet-service.js.map +1 -1
  35. package/package.json +1 -1
  36. package/slate.md +48 -19
package/README.md CHANGED
@@ -5248,6 +5248,14 @@ In some situations you may want to forcibly close the checkout so that your user
5248
5248
  button.close();
5249
5249
  ```
5250
5250
 
5251
+ ### Performing actions when the wallet button is clicked
5252
+
5253
+ In some situations you may want to perform some validations or actions when the user clicks on the wallet button, for which you can use this method. Currently supported by Paypal, ApplePay and GooglePay wallets.
5254
+
5255
+ ```javascript
5256
+ button.onClick(() => console.log("Perform actions on button click"));
5257
+ ```
5258
+
5251
5259
  ### Performing actions when shipping info is updated
5252
5260
 
5253
5261
  In Flypay, Paypal, ApplePay via MPGS and GooglePay via MPGS integrations after each shipping info update the `onUpdate(data)` will be called with the selected shipping address information, plus selected shipping method when applicable for Paypal, ApplePay and GooglePay. Merchants should handle this callback, recalculate shipping costs in their server by analyzing the new data, and submit a backend to backend request to `POST charges/:id` with the new total amount and shipping amount (you can find the documentation of this call in the PayDock API documentation).
@@ -5375,30 +5383,51 @@ _(Required `meta` fields: - . Optional `meta` fields: `request_shipping`, `pay_l
5375
5383
  <script src="https://widget.paydock.com/sdk/latest/widget.umd.min.js" ></script>
5376
5384
  <script>
5377
5385
  let button = new paydock.WalletButtons(
5378
- "#widget",
5379
- charge_token,
5380
- {
5381
- request_shipping: true,
5382
- pay_later: true,
5383
- standalone: false,
5384
- style: {
5385
- layout: 'horizontal',
5386
- color: 'blue',
5387
- shape: 'rect',
5388
- label: 'paypal',
5389
- },
5390
- }
5391
- );
5386
+ "#widget",
5387
+ charge_token,
5388
+ {
5389
+ request_shipping: true,
5390
+ pay_later: true,
5391
+ standalone: false,
5392
+ style: {
5393
+ layout: 'horizontal',
5394
+ color: 'blue',
5395
+ shape: 'rect',
5396
+ label: 'paypal',
5397
+ },
5398
+ }
5399
+ );
5392
5400
  button.setEnv('sandbox');
5393
5401
  button.onUnavailable(() => console.log("No wallet buttons available"));
5394
5402
  button.onUpdate((data) => {
5395
- console.log("Updating amount via a backend to backend call to POST charges/:id");
5396
- // call `POST charges/:id` to modify charge
5397
- button.update({ success: true });
5398
- });
5403
+ console.log("Updating amount via a backend to backend call to POST charges/:id");
5404
+ // call `POST charges/:id` to modify charge
5405
+ button.update({ success: true });
5406
+ });
5399
5407
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
5400
5408
  button.onPaymentError((data) => console.log("The payment was not successful"));
5401
5409
  button.onPaymentInReview((data) => console.log("The payment is on fraud review"));
5410
+
5411
+ // Example 1: Asynchronous onClick handler
5412
+ const asyncLogic = async () => {
5413
+ // Perform asynchronous logic. Expectation is that a Promise is returned and attached to response via `attachResult`,
5414
+ // and resolve or reject of it will dictate how wallet behaves.
5415
+ }
5416
+
5417
+ button.onClick(({ data: { attachResult } }) => {
5418
+ // Promise is attached to the result. On Paypal, when promise is resolved, the user Journey will continue.
5419
+ // If no promise is attached then the Paypal journey will not depend on the promise being resolved or rejected
5420
+ attachResult(asyncLogic());
5421
+ });
5422
+
5423
+ // Example 2: Synchronous onClick handler
5424
+ // button.onClick(({ data: { attachResult } }) => {
5425
+ // // Perform synchronous logic
5426
+ // console.log("Synchronous onClick: Button clicked");
5427
+ // // Optionally return a boolean flag to halt the operation
5428
+ // attachResult(false);
5429
+ // });
5430
+
5402
5431
  button.load();
5403
5432
  </script>
5404
5433
  </html>
@@ -5532,6 +5561,7 @@ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `ra
5532
5561
  button.onUnavailable(() => console.log("No wallet buttons available"));
5533
5562
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
5534
5563
  button.onPaymentError((data) => console.log("The payment was not successful"));
5564
+ button.onClick(() => console.log("On WalletButton Click"));
5535
5565
  button.onUpdate((data) => {
5536
5566
  console.log("Updating amount via a backend to backend call to POST charges/:id");
5537
5567
  // call `POST charges/:id` to modify charge
@@ -5564,7 +5594,6 @@ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `ra
5564
5594
  Also, for **ApplePay via MPGS** you can initialize the `ApplePayPaymentRequest` with your own values instead of using the default ones. Below you can see an example on how to initialize the `ApplePayPaymentRequest` with the `raw_data_initialization` meta field.
5565
5595
 
5566
5596
  Similarly, for **GooglePay via MPGS** you can initialize the `PaymentMethodSpecification` with your own values instead of using the default ones. Below you can see an example on how to initialize the `PaymentMethodSpecification` with the `raw_data_initialization` meta field.
5567
-
5568
5597
  ### ApplePay and GooglePay via MPGS Raw data initialization example
5569
5598
 
5570
5599
  ```html
@@ -5696,6 +5725,24 @@ Similarly, for **GooglePay via MPGS** you can initialize the `PaymentMethodSpeci
5696
5725
  ## Interfaces
5697
5726
 
5698
5727
  <dl>
5728
+ <dt><a href="#IEventData">IEventData</a></dt>
5729
+ <dd><p>Interface of data from events.</p>
5730
+ </dd>
5731
+ <dt><a href="#IWalletPaymentSuccessful">IWalletPaymentSuccessful</a></dt>
5732
+ <dd><p>Interface of data from a successful payment result.</p>
5733
+ </dd>
5734
+ <dt><a href="#IWalletUpdate">IWalletUpdate</a></dt>
5735
+ <dd><p>Interface of data from an update event.</p>
5736
+ </dd>
5737
+ <dt><a href="#IWalletOnClick">IWalletOnClick</a></dt>
5738
+ <dd><p>Interface of data from a wallet onClick event.</p>
5739
+ </dd>
5740
+ <dt><a href="#IWalletUnavailable">IWalletUnavailable</a></dt>
5741
+ <dd><p>Interface of data from an unavailable event.</p>
5742
+ </dd>
5743
+ <dt><a href="#IWalletUpdateData">IWalletUpdateData</a></dt>
5744
+ <dd><p>Interface of data for wallet button <code>update</code> call.</p>
5745
+ </dd>
5699
5746
  <dt><a href="#IWalletMeta">IWalletMeta</a> : <code>object</code></dt>
5700
5747
  <dd><p>Interface of data used by the wallet checkout and payment proccess.</p>
5701
5748
  </dd>
@@ -5710,6 +5757,100 @@ Similarly, for **GooglePay via MPGS** you can initialize the `PaymentMethodSpeci
5710
5757
  </dd>
5711
5758
  </dl>
5712
5759
 
5760
+ <a name="IEventData" id="IEventData" href="#IEventData">&nbsp;</a>
5761
+
5762
+ ## IEventData
5763
+ Interface of data from events.
5764
+
5765
+ **Kind**: global interface
5766
+
5767
+ | Param | Type |
5768
+ | --- | --- |
5769
+ | event | <code>string</code> |
5770
+ | data | <code>void</code> \| [<code>IWalletPaymentSuccessful</code>](#IWalletPaymentSuccessful) \| [<code>IWalletUpdate</code>](#IWalletUpdate) \| [<code>IWalletUnavailable</code>](#IWalletUnavailable) \| [<code>IWalletOnClick</code>](#IWalletOnClick) \| <code>any</code> |
5771
+
5772
+ <a name="IWalletPaymentSuccessful" id="IWalletPaymentSuccessful" href="#IWalletPaymentSuccessful">&nbsp;</a>
5773
+
5774
+ ## IWalletPaymentSuccessful
5775
+ Interface of data from a successful payment result.
5776
+
5777
+ **Kind**: global interface
5778
+
5779
+ | Param | Type |
5780
+ | --- | --- |
5781
+ | id | <code>string</code> |
5782
+ | amount | <code>number</code> |
5783
+ | currency | <code>string</code> |
5784
+ | status | <code>string</code> |
5785
+ | [payer_name] | <code>string</code> |
5786
+ | [payer_email] | <code>string</code> |
5787
+ | [payer_phone] | <code>string</code> |
5788
+
5789
+ <a name="IWalletUpdate" id="IWalletUpdate" href="#IWalletUpdate">&nbsp;</a>
5790
+
5791
+ ## IWalletUpdate
5792
+ Interface of data from an update event.
5793
+
5794
+ **Kind**: global interface
5795
+
5796
+ | Param | Type |
5797
+ | --- | --- |
5798
+ | [wallet_response_code] | <code>string</code> |
5799
+ | [wallet_session_id] | <code>string</code> |
5800
+ | [payment_source] | <code>object</code> |
5801
+ | [payment_source.wallet_payment_method_id] | <code>string</code> |
5802
+ | [payment_source.card_number_last4] | <code>string</code> |
5803
+ | [payment_source.card_scheme] | <code>string</code> |
5804
+ | [wallet_loyalty_account] | <code>object</code> |
5805
+ | [wallet_loyalty_account.id] | <code>string</code> |
5806
+ | [wallet_loyalty_account.barcode] | <code>string</code> |
5807
+ | [shipping] | <code>object</code> |
5808
+ | [shipping.address_line1] | <code>string</code> |
5809
+ | [shipping.address_line2] | <code>string</code> |
5810
+ | [shipping.address_postcode] | <code>string</code> |
5811
+ | [shipping.address_city] | <code>string</code> |
5812
+ | [shipping.address_state] | <code>string</code> |
5813
+ | [shipping.address_country] | <code>string</code> |
5814
+ | [shipping.address_company] | <code>string</code> |
5815
+ | [shipping.post_office_box_number] | <code>string</code> |
5816
+ | [shipping.wallet_address_id] | <code>string</code> |
5817
+ | [shipping.wallet_address_name] | <code>string</code> |
5818
+ | [shipping.wallet_address_created_timestamp] | <code>string</code> |
5819
+ | [shipping.wallet_address_updated_timestamp] | <code>string</code> |
5820
+
5821
+ <a name="IWalletOnClick" id="IWalletOnClick" href="#IWalletOnClick">&nbsp;</a>
5822
+
5823
+ ## IWalletOnClick
5824
+ Interface of data from a wallet onClick event.
5825
+
5826
+ **Kind**: global interface
5827
+
5828
+ | Param | Description |
5829
+ | --- | --- |
5830
+ | attachResult | Method to be called that attaches a result to the wallet onClick operation. When handler is synchronous, this method is optionally called with a boolean flag indicating validation result. When handler executes asynchronous operations, this method must be called with the Promise to have the wallet process wait for its completion or rejection. |
5831
+
5832
+ <a name="IWalletUnavailable" id="IWalletUnavailable" href="#IWalletUnavailable">&nbsp;</a>
5833
+
5834
+ ## IWalletUnavailable
5835
+ Interface of data from an unavailable event.
5836
+
5837
+ **Kind**: global interface
5838
+
5839
+ | Param | Type | Description |
5840
+ | --- | --- | --- |
5841
+ | [wallet] | <code>string</code> | For gateways with more than one wallet button available (e.g: MPGS with ApplePay and GooglePay). Possible values for wallet are 'apple' or 'google'. |
5842
+
5843
+ <a name="IWalletUpdateData" id="IWalletUpdateData" href="#IWalletUpdateData">&nbsp;</a>
5844
+
5845
+ ## IWalletUpdateData
5846
+ Interface of data for wallet button `update` call.
5847
+
5848
+ **Kind**: global interface
5849
+
5850
+ | Param | Type |
5851
+ | --- | --- |
5852
+ | success | <code>boolean</code> |
5853
+
5713
5854
  <a name="IWalletMeta" id="IWalletMeta" href="#IWalletMeta">&nbsp;</a>
5714
5855
 
5715
5856
  ## IWalletMeta : <code>object</code>
@@ -5794,14 +5935,19 @@ Class WalletButtons to work with different E-Wallets within html (currently supp
5794
5935
  * [.load()](#WalletButtons+load)
5795
5936
  * [.update()](#WalletButtons+update)
5796
5937
  * [.setEnv(env, [alias])](#WalletButtons+setEnv)
5938
+ * [.enable()](#WalletButtons+enable)
5939
+ * [.disable()](#WalletButtons+disable)
5797
5940
  * [.close()](#WalletButtons+close)
5798
- * [.on(eventName, [cb])](#WalletButtons+on) ⇒ <code>Promise.&lt;IEventData&gt;</code> \| <code>void</code>
5941
+ * [.on(eventName, [cb])](#WalletButtons+on) ⇒ [<code>Promise.&lt;IEventData&gt;</code>](#IEventData) \| <code>void</code>
5799
5942
  * [.onUnavailable([handler])](#WalletButtons+onUnavailable)
5800
5943
  * [.onUpdate([handler])](#WalletButtons+onUpdate)
5801
5944
  * [.onPaymentSuccessful([handler])](#WalletButtons+onPaymentSuccessful)
5802
5945
  * [.onPaymentInReview([handler])](#WalletButtons+onPaymentInReview)
5803
5946
  * [.onPaymentError([handler])](#WalletButtons+onPaymentError)
5804
5947
  * [.onAuthTokensChanged([handler])](#WalletButtons+onAuthTokensChanged)
5948
+ * [.onClick(handler)](#WalletButtons+onClick)
5949
+ * [.onCheckoutOpen(handler)](#WalletButtons+onCheckoutOpen)
5950
+ * [.onCheckoutClose(handler)](#WalletButtons+onCheckoutClose)
5805
5951
 
5806
5952
  <a name="new_WalletButtons_new" id="new_WalletButtons_new" href="#new_WalletButtons_new">&nbsp;</a>
5807
5953
 
@@ -5912,6 +6058,26 @@ Bear in mind that you must set an environment before calling `button.load()`.
5912
6058
  ```js
5913
6059
  button.setEnv('production', 'paydock.com');
5914
6060
  ```
6061
+ <a name="WalletButtons+enable" id="WalletButtons+enable" href="#WalletButtons+enable">&nbsp;</a>
6062
+
6063
+ ### walletButtons.enable()
6064
+ Current method can enable the payment button. This method is only supported for Flypay V2.
6065
+
6066
+ **Kind**: instance method of [<code>WalletButtons</code>](#WalletButtons)
6067
+ **Example**
6068
+ ```js
6069
+ button.enable();
6070
+ ```
6071
+ <a name="WalletButtons+disable" id="WalletButtons+disable" href="#WalletButtons+disable">&nbsp;</a>
6072
+
6073
+ ### walletButtons.disable()
6074
+ Current method can disable the payment button. This method is only supported for Flypay V2.
6075
+
6076
+ **Kind**: instance method of [<code>WalletButtons</code>](#WalletButtons)
6077
+ **Example**
6078
+ ```js
6079
+ button.disable('production', 'paydock.com');
6080
+ ```
5915
6081
  <a name="WalletButtons+close" id="WalletButtons+close" href="#WalletButtons+close">&nbsp;</a>
5916
6082
 
5917
6083
  ### walletButtons.close()
@@ -5924,7 +6090,7 @@ button.close();
5924
6090
  ```
5925
6091
  <a name="WalletButtons+on" id="WalletButtons+on" href="#WalletButtons+on">&nbsp;</a>
5926
6092
 
5927
- ### walletButtons.on(eventName, [cb]) ⇒ <code>Promise.&lt;IEventData&gt;</code> \| <code>void</code>
6093
+ ### walletButtons.on(eventName, [cb]) ⇒ [<code>Promise.&lt;IEventData&gt;</code>](#IEventData) \| <code>void</code>
5928
6094
  Listen to events of button. `unavailable` returns no data, `paymentSuccessful` returns IWalletPaymentSuccessful
5929
6095
  for Stripe or full response for Flypay, and `paymentError` an error.
5930
6096
 
@@ -6087,6 +6253,63 @@ button.onAuthTokensChanged().then((eventData) => {
6087
6253
  console.log('Authentication tokens changed:', eventData);
6088
6254
  });
6089
6255
  ```
6256
+ <a name="WalletButtons+onClick" id="WalletButtons+onClick" href="#WalletButtons+onClick">&nbsp;</a>
6257
+
6258
+ ### walletButtons.onClick(handler)
6259
+ Registers a callback function to be invoked when the wallet button gets clicked.
6260
+ There are two operational modes supported, Synchronous and Asynchronous.
6261
+ When asynchronous operations need to occur on the callback handler, attaching the Promise via `attachResult` is required to have the wallet wait for a result.
6262
+ When synchronous operations occur on the callback handler, attaching a boolean result via `attachResult` is optional to control the execution flow.
6263
+ Note this is supported for Paypal, GooglePay and ApplePay wallet buttons at the moment.
6264
+
6265
+ **Kind**: instance method of [<code>WalletButtons</code>](#WalletButtons)
6266
+
6267
+ | Param | Type | Description |
6268
+ | --- | --- | --- |
6269
+ | handler | <code>listener</code> | Function to be called when the wallet button is clicked. |
6270
+
6271
+ **Example**
6272
+ ```js
6273
+ button.onClick((data) => {
6274
+ performValidationLogic();
6275
+ });
6276
+ ```
6277
+ <a name="WalletButtons+onCheckoutOpen" id="WalletButtons+onCheckoutOpen" href="#WalletButtons+onCheckoutOpen">&nbsp;</a>
6278
+
6279
+ ### walletButtons.onCheckoutOpen(handler)
6280
+ Registers a callback function to be invoked when the wallet checkout opens.
6281
+ Note this is supported for FlypayV2 wallet button at the moment.
6282
+
6283
+ **Kind**: instance method of [<code>WalletButtons</code>](#WalletButtons)
6284
+
6285
+ | Param | Type | Description |
6286
+ | --- | --- | --- |
6287
+ | handler | <code>listener</code> | Function to be called when the wallet checkout opens. |
6288
+
6289
+ **Example**
6290
+ ```js
6291
+ button.onCheckoutOpen((data) => {
6292
+ console.log('Checkout opens');
6293
+ });
6294
+ ```
6295
+ <a name="WalletButtons+onCheckoutClose" id="WalletButtons+onCheckoutClose" href="#WalletButtons+onCheckoutClose">&nbsp;</a>
6296
+
6297
+ ### walletButtons.onCheckoutClose(handler)
6298
+ Registers a callback function to be invoked when the wallet checkout closes.
6299
+ Note this is supported for FlypayV2 wallet button at the moment.
6300
+
6301
+ **Kind**: instance method of [<code>WalletButtons</code>](#WalletButtons)
6302
+
6303
+ | Param | Type | Description |
6304
+ | --- | --- | --- |
6305
+ | handler | <code>listener</code> | Function to be called when the wallet checkout closes. |
6306
+
6307
+ **Example**
6308
+ ```js
6309
+ button.onCheckoutClose(() => {
6310
+ console.log('Wallet checkout closes');
6311
+ });
6312
+ ```
6090
6313
  <a name="EVENT" id="EVENT" href="#EVENT">&nbsp;</a>
6091
6314
 
6092
6315
  ## EVENT : <code>object</code>
@@ -6100,6 +6323,7 @@ List of available event's name in the wallet button lifecycle
6100
6323
  | UPDATE | <code>string</code> | <code>&quot;update&quot;</code> |
6101
6324
  | PAYMENT_SUCCESSFUL | <code>string</code> | <code>&quot;paymentSuccessful&quot;</code> |
6102
6325
  | PAYMENT_ERROR | <code>string</code> | <code>&quot;paymentError&quot;</code> |
6326
+ | ON_CLICK | <code>string</code> | <code>&quot;onClick&quot;</code> |
6103
6327
 
6104
6328
 
6105
6329
  ## Secure Remote Commerce