@paydock/client-sdk 1.120.1 → 1.121.0

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 (78) hide show
  1. package/README.md +173 -32
  2. package/bundles/index.cjs +633 -352
  3. package/bundles/index.cjs.d.ts +89 -31
  4. package/bundles/index.mjs +633 -352
  5. package/bundles/index.mjs.d.ts +89 -31
  6. package/bundles/types/api/api-base.d.ts +6 -6
  7. package/bundles/types/api/api-base.d.ts.map +1 -1
  8. package/bundles/types/api/api-checkout-internal.d.ts +2 -2
  9. package/bundles/types/api/api-checkout-internal.d.ts.map +1 -1
  10. package/bundles/types/api/api.d.ts +9 -9
  11. package/bundles/types/api/api.d.ts.map +1 -1
  12. package/bundles/types/checkout/checkout.d.ts +26 -7
  13. package/bundles/types/checkout/checkout.d.ts.map +1 -1
  14. package/bundles/types/checkout/helpers/instruction-handler.d.ts +6 -4
  15. package/bundles/types/checkout/helpers/instruction-handler.d.ts.map +1 -1
  16. package/bundles/types/checkout/instructions/v1/instruction.afterpay_checkout_form.show.d.ts.map +1 -1
  17. package/bundles/types/checkout/instructions/v1/instruction.apple_pay_form.show.d.ts.map +1 -1
  18. package/bundles/types/checkout/instructions/v1/instruction.canvas_3ds.show.d.ts.map +1 -1
  19. package/bundles/types/checkout/instructions/v1/instruction.card_form.show.d.ts.map +1 -1
  20. package/bundles/types/checkout/instructions/v1/instruction.disable_payment_method_event.emit.d.ts +1 -0
  21. package/bundles/types/checkout/instructions/v1/instruction.disable_payment_method_event.emit.d.ts.map +1 -1
  22. package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts +1 -1
  23. package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts.map +1 -1
  24. package/bundles/types/checkout/instructions/v1/instruction.google_pay_form.show.d.ts.map +1 -1
  25. package/bundles/types/checkout/instructions/v1/instruction.merchant_event.emit.d.ts.map +1 -1
  26. package/bundles/types/checkout/instructions/v1/instruction.payment_methods.show.d.ts.map +1 -1
  27. package/bundles/types/checkout/instructions/v1/instruction.paypal_form.show.d.ts.map +1 -1
  28. package/bundles/types/checkout/instructions/v1/instruction.zip_checkout_form.show.d.ts.map +1 -1
  29. package/bundles/types/checkout/layout-widgets/additionals.d.ts +1 -1
  30. package/bundles/types/checkout/layout-widgets/additionals.d.ts.map +1 -1
  31. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts +2 -1
  32. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
  33. package/bundles/types/components/iframe-event.d.ts +3 -8
  34. package/bundles/types/components/iframe-event.d.ts.map +1 -1
  35. package/bundles/types/components/param.d.ts +7 -0
  36. package/bundles/types/components/param.d.ts.map +1 -1
  37. package/bundles/types/helper/event-error.d.ts +55 -0
  38. package/bundles/types/helper/event-error.d.ts.map +1 -0
  39. package/bundles/types/helper/process-event-error.d.ts +9 -0
  40. package/bundles/types/helper/process-event-error.d.ts.map +1 -0
  41. package/bundles/types/wallet-buttons/index.d.ts +6 -1
  42. package/bundles/types/wallet-buttons/index.d.ts.map +1 -1
  43. package/bundles/types/wallet-buttons/wallet-buttons.d.ts.map +1 -1
  44. package/bundles/types/wallet-buttons/wallet-cba-buttons.d.ts.map +1 -1
  45. package/bundles/types/wallet-buttons/wallet-services/afterpay.wallet-service.d.ts +2 -0
  46. package/bundles/types/wallet-buttons/wallet-services/afterpay.wallet-service.d.ts.map +1 -1
  47. package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts +2 -2
  48. package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts.map +1 -1
  49. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts +2 -0
  50. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts.map +1 -1
  51. package/bundles/types/wallet-buttons-express/index.d.ts +5 -0
  52. package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
  53. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts +2 -1
  54. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
  55. package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-button-style.constant.d.ts +1 -3
  56. package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-button-style.constant.d.ts.map +1 -1
  57. package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts +1 -0
  58. package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts.map +1 -1
  59. package/bundles/types/widget/configuration.d.ts.map +1 -1
  60. package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
  61. package/bundles/types/widget/multi-widget.d.ts +11 -3
  62. package/bundles/types/widget/multi-widget.d.ts.map +1 -1
  63. package/bundles/widget.umd.js +633 -352
  64. package/bundles/widget.umd.js.d.ts +89 -31
  65. package/bundles/widget.umd.js.min.d.ts +89 -31
  66. package/bundles/widget.umd.min.js +1 -1
  67. package/docs/api-widget.md +38 -0
  68. package/docs/api-wrapper.md +3 -36
  69. package/docs/wallet-buttons-examples.md +4 -2
  70. package/docs/wallet-buttons-express.md +8 -1
  71. package/docs/wallet-buttons.md +3 -1
  72. package/docs/widget-examples.md +120 -28
  73. package/package.json +2 -2
  74. package/slate.md +124 -30
  75. package/bundles/types/helper/custom-error.d.ts +0 -8
  76. package/bundles/types/helper/custom-error.d.ts.map +0 -1
  77. package/bundles/types/wallet-buttons/helpers/apple-pay.helper.d.ts +0 -3
  78. package/bundles/types/wallet-buttons/helpers/apple-pay.helper.d.ts.map +0 -1
@@ -426,6 +426,7 @@ Class Widget include method for working on html and include extended by HtmlMult
426
426
  * [.setRefId(refId)](#user-content-w_MultiWidget+setRefId)
427
427
  * [.useGatewayFieldValidation()](#user-content-w_MultiWidget+useGatewayFieldValidation)
428
428
  * [.setSupportedCardIcons(elements, validateCardNumberInput)](#user-content-w_MultiWidget+setSupportedCardIcons)
429
+ * [.hideUiErrors()](#user-content-w_MultiWidget+hideUiErrors)
429
430
  * [.setEnv(env, [alias])](#user-content-w_MultiWidget+setEnv)
430
431
  * [.loadIFrameUrl()](#user-content-w_MultiWidget+loadIFrameUrl)
431
432
  * [.setLanguage(code)](#user-content-w_MultiWidget+setLanguage)
@@ -1057,6 +1058,18 @@ Current method can set icons of supported card types
1057
1058
  ```javascript
1058
1059
  widget.setSupportedCardIcons(['mastercard', 'visa'], validateCardNumberInput);
1059
1060
  ```
1061
+ <a name="w_MultiWidget+hideUiErrors" id="w_MultiWidget+hideUiErrors" href="#user-content-w_MultiWidget+hideUiErrors">&nbsp;</a>
1062
+
1063
+ ### htmlWidget.hideUiErrors()
1064
+ Current method can hide prevent the widget from showing the error messages
1065
+
1066
+ **Kind**: instance method of [<code>HtmlWidget</code>](#user-content-w_HtmlWidget)
1067
+ **Overrides**: [<code>hideUiErrors</code>](#user-content-w_MultiWidget+hideUiErrors)
1068
+ **Example**
1069
+
1070
+ ```javascript
1071
+ widget.hideUiErrors('id');
1072
+ ```
1060
1073
  <a name="w_MultiWidget+setEnv" id="w_MultiWidget+setEnv" href="#user-content-w_MultiWidget+setEnv">&nbsp;</a>
1061
1074
 
1062
1075
  ### htmlWidget.setEnv(env, [alias])
@@ -1151,6 +1164,7 @@ Class HtmlMultiWidget include method for working with html
1151
1164
  * [.setRefId(refId)](#user-content-w_MultiWidget+setRefId)
1152
1165
  * [.useGatewayFieldValidation()](#user-content-w_MultiWidget+useGatewayFieldValidation)
1153
1166
  * [.setSupportedCardIcons(elements, validateCardNumberInput)](#user-content-w_MultiWidget+setSupportedCardIcons)
1167
+ * [.hideUiErrors()](#user-content-w_MultiWidget+hideUiErrors)
1154
1168
  * [.setEnv(env, [alias])](#user-content-w_MultiWidget+setEnv)
1155
1169
  * [.loadIFrameUrl()](#user-content-w_MultiWidget+loadIFrameUrl)
1156
1170
  * [.setLanguage(code)](#user-content-w_MultiWidget+setLanguage)
@@ -1683,6 +1697,18 @@ Current method can set icons of supported card types
1683
1697
  ```javascript
1684
1698
  widget.setSupportedCardIcons(['mastercard', 'visa'], validateCardNumberInput);
1685
1699
  ```
1700
+ <a name="w_MultiWidget+hideUiErrors" id="w_MultiWidget+hideUiErrors" href="#user-content-w_MultiWidget+hideUiErrors">&nbsp;</a>
1701
+
1702
+ ### htmlMultiWidget.hideUiErrors()
1703
+ Current method can hide prevent the widget from showing the error messages
1704
+
1705
+ **Kind**: instance method of [<code>HtmlMultiWidget</code>](#user-content-w_HtmlMultiWidget)
1706
+ **Overrides**: [<code>hideUiErrors</code>](#user-content-w_MultiWidget+hideUiErrors)
1707
+ **Example**
1708
+
1709
+ ```javascript
1710
+ widget.hideUiErrors('id');
1711
+ ```
1686
1712
  <a name="w_MultiWidget+setEnv" id="w_MultiWidget+setEnv" href="#user-content-w_MultiWidget+setEnv">&nbsp;</a>
1687
1713
 
1688
1714
  ### htmlMultiWidget.setEnv(env, [alias])
@@ -1936,6 +1962,7 @@ Class MultiWidget include method for for creating iframe url
1936
1962
  * [.setRefId(refId)](#user-content-w_MultiWidget+setRefId)
1937
1963
  * [.useGatewayFieldValidation()](#user-content-w_MultiWidget+useGatewayFieldValidation)
1938
1964
  * [.setSupportedCardIcons(elements, validateCardNumberInput)](#user-content-w_MultiWidget+setSupportedCardIcons)
1965
+ * [.hideUiErrors()](#user-content-w_MultiWidget+hideUiErrors)
1939
1966
  * [.setEnv(env, [alias])](#user-content-w_MultiWidget+setEnv)
1940
1967
  * [.loadIFrameUrl()](#user-content-w_MultiWidget+loadIFrameUrl)
1941
1968
  * [.setLanguage(code)](#user-content-w_MultiWidget+setLanguage)
@@ -2223,6 +2250,17 @@ Current method can set icons of supported card types
2223
2250
  ```javascript
2224
2251
  widget.setSupportedCardIcons(['mastercard', 'visa'], validateCardNumberInput);
2225
2252
  ```
2253
+ <a name="w_MultiWidget+hideUiErrors" id="w_MultiWidget+hideUiErrors" href="#user-content-w_MultiWidget+hideUiErrors">&nbsp;</a>
2254
+
2255
+ ### multiWidget.hideUiErrors()
2256
+ Current method can hide prevent the widget from showing the error messages
2257
+
2258
+ **Kind**: instance method of [<code>MultiWidget</code>](#user-content-w_MultiWidget)
2259
+ **Example**
2260
+
2261
+ ```javascript
2262
+ widget.hideUiErrors('id');
2263
+ ```
2226
2264
  <a name="w_MultiWidget+setEnv" id="w_MultiWidget+setEnv" href="#user-content-w_MultiWidget+setEnv">&nbsp;</a>
2227
2265
 
2228
2266
  ### multiWidget.setEnv(env, [alias])
@@ -1,36 +1,3 @@
1
- ## Classes
2
-
3
- <dl>
4
- <dt><a href="#Api">Api</a></dt>
5
- <dd><p>Class Api include method for working with paydock api</p>
6
- </dd>
7
- </dl>
8
-
9
- ## Interfaces
10
-
11
- <dl>
12
- <dt><a href="#BrowserDetails">BrowserDetails</a></dt>
13
- <dd><p>Interface for browser details response.</p>
14
- </dd>
15
- </dl>
16
-
17
- <a name="BrowserDetails" id="BrowserDetails" href="#BrowserDetails">&nbsp;</a>
18
-
19
- ## BrowserDetails
20
- Interface for browser details response.
21
-
22
- **Kind**: global interface
23
-
24
- | Param | Type |
25
- | --- | --- |
26
- | [name] | <code>string</code> |
27
- | [java_enabled] | <code>string</code> |
28
- | [language] | <code>string</code> |
29
- | [screen_height] | <code>string</code> |
30
- | [screen_width] | <code>string</code> |
31
- | [time_zone] | <code>string</code> |
32
- | [color_depth] | <code>string</code> |
33
-
34
1
  <a name="Api" id="Api" href="#Api">&nbsp;</a>
35
2
 
36
3
  ## Api
@@ -40,7 +7,7 @@ Class Api include method for working with paydock api
40
7
 
41
8
  * [Api](#Api)
42
9
  * [new Api(publicKey)](#new_Api_new)
43
- * [.getBrowserDetails()](#Api+getBrowserDetails) ⇒ [<code>BrowserDetails</code>](#BrowserDetails)
10
+ * [.getBrowserDetails()](#Api+getBrowserDetails) ⇒ <code>BrowserDetails</code>
44
11
  * [.charge()](#Api+charge)
45
12
 
46
13
  <a name="new_Api_new" id="new_Api_new" href="#new_Api_new">&nbsp;</a>
@@ -57,11 +24,11 @@ var api = new Api('publicKey');
57
24
  ```
58
25
  <a name="Api+getBrowserDetails" id="Api+getBrowserDetails" href="#Api+getBrowserDetails">&nbsp;</a>
59
26
 
60
- ### api.getBrowserDetails() ⇒ [<code>BrowserDetails</code>](#BrowserDetails)
27
+ ### api.getBrowserDetails() ⇒ <code>BrowserDetails</code>
61
28
  Method for getting browser details
62
29
 
63
30
  **Kind**: instance method of [<code>Api</code>](#Api)
64
- **Returns**: [<code>BrowserDetails</code>](#BrowserDetails) - Browser details object
31
+ **Returns**: <code>BrowserDetails</code> - Browser details object
65
32
  **Example**
66
33
  ```js
67
34
  api.getBrowserDetails();
@@ -234,7 +234,7 @@ button.onUpdate((data) => {
234
234
  After the payment is completed, the onPaymentSuccessful(data) will be called if the payment was successful. If the payment was not successful, the function onPaymentError(data) will be called. If fraud check is active for the gateway, a fraud body was sent in the wallet charge initialize call and the fraud service left the charge in review, then the onPaymentInReview(data) will be called.
235
235
  All three callbacks return relevant data according to each one of the scenarios.
236
236
 
237
- Note that these callbacks will not trigger for Afterpay wallet since the payment completion for it is done via Redirect method, and therefore this SDK won't be loaded once the payment is completed at checkout.
237
+ >*Note that these callbacks will not be triggered for the Afterpay wallet when Redirect mode is used, that is when the charge is initialized with the success_url and error_url parameters, since the payment completion is done through the Redirect method, and therefore this SDK will not be loaded once the payment is completed at checkout.*
238
238
 
239
239
  ```javascript
240
240
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
@@ -436,7 +436,7 @@ _(Required `meta` fields: - . Optional `meta` fields: -)_
436
436
 
437
437
  This example shows how to use these functions for **ApplePay via MPGS** and **GooglePay via MPGS**:
438
438
 
439
- _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `raw_data_initialization`, `request_shipping`, `style.button_type`)_
439
+ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `raw_data_initialization`, `request_shipping`, `style.button_type`, `style.button_style`)_
440
440
  ### ApplePay and GooglePay via MPGS Full example
441
441
 
442
442
  ```html
@@ -468,6 +468,7 @@ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `ra
468
468
  },
469
469
  apple: {
470
470
  button_type: 'buy',
471
+ button_style: 'black',
471
472
  },
472
473
  },
473
474
  shipping_options: [
@@ -584,6 +585,7 @@ Similarly, for **GooglePay via MPGS** you can initialize the `PaymentMethodSpeci
584
585
  },
585
586
  apple: {
586
587
  button_type: 'buy',
588
+ button_style: 'black',
587
589
  },
588
590
  },
589
591
  shipping_options: [
@@ -47,7 +47,10 @@
47
47
 
48
48
  <dl>
49
49
  <dt><a href="#ApplePayWalletMeta">ApplePayWalletMeta</a> : <code>object</code></dt>
50
- <dd><p>Interface for configuration metadata specific to ApplePay integration in the wallet checkout and payment process.</p>
50
+ <dd><p>Interface for configuration metadata specific to ApplePay integration in the wallet checkout and payment process.
51
+ For further information about ApplePay Capabilities refer to <a href="https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/4440085-applepaycapabilities">the documentation</a>.
52
+ Apple will determinate if the device has an ApplePay wallet available and at least one active payment.
53
+ If the determinated value is credentials_status_unknown, the payment possbily should might be not able to be finished on the web, and the buyer must complete it on a compatible device, like Iphone or Ipad.</p>
51
54
  </dd>
52
55
  <dt><a href="#PaypalWalletMeta">PaypalWalletMeta</a> : <code>object</code></dt>
53
56
  <dd><p>Interface for configuration metadata specific to PayPal integration in the wallet checkout and payment process.
@@ -80,6 +83,9 @@ For in-depth information, please refer to the <a href="https://developer.paypal.
80
83
 
81
84
  ## ApplePayWalletMeta : <code>object</code>
82
85
  Interface for configuration metadata specific to ApplePay integration in the wallet checkout and payment process.
86
+ For further information about ApplePay Capabilities refer to [the documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/4440085-applepaycapabilities).
87
+ Apple will determinate if the device has an ApplePay wallet available and at least one active payment.
88
+ If the determinated value is credentials_status_unknown, the payment possbily should might be not able to be finished on the web, and the buyer must complete it on a compatible device, like Iphone or Ipad.
83
89
 
84
90
  **Kind**: global interface
85
91
 
@@ -97,6 +103,7 @@ Interface for configuration metadata specific to ApplePay integration in the wal
97
103
  | [style] | <code>object</code> | Styling configuration for ApplePay buttons displayed during checkout. |
98
104
  | [style.button_type] | <code>ApplePayButtonType</code> | Enum type to select the type of ApplePay button (e.g., 'buy', 'donate', etc.), providing user interface customization. |
99
105
  | [style.button_style] | <code>ApplePayButtonStyle</code> | Style applied to the ApplePay button, which can include color and form factor adjustments according to the brand's visual guidelines. |
106
+ | [apple_pay_capabilities] | <code>Array.&lt;(&#x27;credentials\_available&#x27;\|&#x27;credentials\_status\_unknown&#x27;\|&#x27;credentials\_unavailable&#x27;)&gt;</code> | Device capabilities needed for wallet button to be available. |
100
107
 
101
108
  <a name="PaypalWalletMeta" id="PaypalWalletMeta" href="#PaypalWalletMeta">&nbsp;</a>
102
109
 
@@ -170,10 +170,12 @@ Interface of data used by the wallet checkout and payment proccess.
170
170
  | [merchant_name] | <code>string</code> | Merchant Name used for GooglePay integration via MPGS. Required for [GooglePay]. N/A for other wallets. |
171
171
  | [raw_data_initialization] | <code>object</code> | Used to provide values to initialize wallet with raw data. Optional for [ApplePay]. N/A for the other wallets. |
172
172
  | [style] | <code>object</code> | For **Paypal**: used to style the buttons, check possible values in the [style guide](https://developer.paypal.com/docs/business/checkout/reference/style-guide). When `standalone` and `pay_later`, extra options can be provided in `style.messages` with the [messages style options](https://developer.paypal.com/docs/checkout/pay-later/us/integrate/reference/#stylelayout). Also used at **ApplePay**, **GooglePay** and **Afterpay** to select button type. Optional for [PayPal, ApplePay, GooglePay, Afterpay]. N/A for [Stripe, FlyPay, Flypay V2]. |
173
- | [style.button_type] | <code>object</code> | 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. Also select button type for GooglePay (check GooglePayStyles) and Afterpay (check AfterpayStyles). Optional for [ApplePay, GooglePay, Afterpay]. N/A for other wallets. |
173
+ | [style.button_type] | <code>object</code> | Used to select ApplePay button type (e.g: 'buy','donate', etc), check possible values [here](https://developer.apple.com/documentation/apple_pay_on_the_web/displaying_apple_pay_buttons_using_css). Also select button type for GooglePay (check GooglePayStyles) and Afterpay (check AfterpayStyles). Optional for [ApplePay, GooglePay, Afterpay]. N/A for other wallets. |
174
+ | [style.button_style] | <code>object</code> | Used to select ApplePay button style (e.g: 'black', 'white', etc), check possible values [here](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaybuttonstyle). Optional for [ApplePay]. N/A for other wallets. |
174
175
  | [style.height] | <code>object</code> | Used to select Afterpay button height. Optional for [Afterpay]. N/A for other wallets. |
175
176
  | [wallets] | <code>array</code> | 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. |
176
177
  | [client_id] | <code>string</code> | Client ID to be used in the provider system. Required for [Flypay V2]. N/A for [FlyPay, GooglePay, ApplePay, PayPal, Afterpay]. |
178
+ | [apple_pay_capabilities] | <code>Array.&lt;(&#x27;credentials\_available&#x27;\|&#x27;credentials\_status\_unknown&#x27;\|&#x27;credentials\_unavailable&#x27;)&gt;</code> | Device capabilities needed for wallet button to be available. For further information about refer to [the documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession/4440085-applepaycapabilities). If the recognized value is credentials_status_unknown, the payment most possibly cannot be finished on the web, and the buyer must complete it on a compatible device, like Iphone, via QR scan. Optional parameter for [ApplePay]. N/A for [FlyPay, GooglePay, Flypay V2, PayPal, Afterpay]. |
177
179
 
178
180
  <a name="IApplePayShippingOption" id="IApplePayShippingOption" href="#IApplePayShippingOption">&nbsp;</a>
179
181
 
@@ -1,4 +1,5 @@
1
1
  ## Widget
2
+
2
3
  You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#widget-simple-example)
3
4
 
4
5
  A payment form where it is possible to enter card data/bank accounts and then receive a one-time
@@ -15,8 +16,8 @@ It is possible in real-time to monitor the actions of user with widget and get i
15
16
 
16
17
  You must create a container for the widget. Inside this tag, the widget will be initialized
17
18
 
18
-
19
19
  ### Initialization
20
+
20
21
  ```javascript
21
22
  var widget = new paydock.HtmlWidget('#widget', 'publicKey');
22
23
  widget.load();
@@ -33,7 +34,6 @@ widget.load();
33
34
 
34
35
  Then write only need 2 lines of code in js to initialize widget
35
36
 
36
-
37
37
  ### Full example
38
38
 
39
39
  ```html
@@ -59,19 +59,18 @@ Then write only need 2 lines of code in js to initialize widget
59
59
  </html>
60
60
  ```
61
61
 
62
-
63
62
  ## Widget advanced example
64
63
 
65
64
  ### Customization
66
65
 
67
66
  ```javascript
68
67
  widget.setStyles({
69
- background_color: 'rgb(0, 0, 0)',
70
- border_color: 'yellow',
71
- text_color: '#FFFFAA',
72
- button_color: 'rgba(255, 255, 255, 0.9)',
73
- font_size: '20px'
74
- });
68
+ background_color: 'rgb(0, 0, 0)',
69
+ border_color: 'yellow',
70
+ text_color: '#FFFFAA',
71
+ button_color: 'rgba(255, 255, 255, 0.9)',
72
+ font_size: '20px'
73
+ });
75
74
  ```
76
75
 
77
76
  This example shows how you can customize to your needs and design
@@ -80,9 +79,9 @@ This example shows how you can customize to your needs and design
80
79
 
81
80
  ```html
82
81
  <div id="widget"
83
- widget-style="text-color: #FFFFAA; border-color: #yellow"
84
- title="Payment form"
85
- finish-text="Payment resource was successfully accepted"></div>
82
+ widget-style="text-color: #FFFFAA; border-color: #yellow"
83
+ title="Payment form"
84
+ finish-text="Payment resource was successfully accepted"></div>
86
85
  ```
87
86
 
88
87
  This example shows how you can set style and texts from html
@@ -99,19 +98,112 @@ widget.setSupportedCardIcons(['mastercard', 'visa']); // add icons of supported
99
98
 
100
99
  This example shows how you can use a lot of other methods to settings your form
101
100
 
102
-
103
101
  ### Error handling
104
102
 
103
+ ## Overview
104
+
105
+ Error events are emitted when an error occurs during widget operations. These events provide detailed information about the error, including its category, cause, and contextual details.
106
+
107
+ ## Error Event Structure
108
+
109
+ ### Base Properties
110
+
111
+ | Property | Type | Description |
112
+ |----------|------|-------------|
113
+ | `event` | `string` | Always set to `"error"` |
114
+ | `purpose` | `string` | Indicates the purpose of the action that triggered the error event (e.g., `"payment_source"`) |
115
+ | `message_source` | `string` | Source of the message (e.g., `"widget.paydock"`) |
116
+ | `ref_id` | `string` | Reference ID for the operation |
117
+ | `widget_id` | `string` | Unique identifier of the widget instance |
118
+ | `error` | `object` | Error object containing error information |
119
+
120
+ ### Error Object Properties
121
+
122
+ The `error` object contains detailed information about the error:
123
+
124
+ | Property | Type | Description |
125
+ |----------|------|-------------|
126
+ | `category` | `string` | High-level error classification |
127
+ | `cause` | `string` | Specific error cause |
128
+ | `retryable` | `boolean` | Indicates if the operation can be retried |
129
+ | `details` | `object` | Additional error context |
130
+
131
+ ## Error Categories
132
+
133
+ | Category | Description |
134
+ |----------|-------------|
135
+ | `configuration` | Configuration-related errors |
136
+ | `identity_access_management` | Authentication and authorization errors |
137
+ | `internal` | Internal system errors |
138
+ | `process` | Process and operation errors |
139
+ | `resource` | Resource-related errors |
140
+ | `validation` | Input validation errors |
141
+
142
+ ## Error Causes
143
+
144
+ | Cause | Category | Description |
145
+ |-------|----------|-------------|
146
+ | `aborted` | `process` | Operation was aborted |
147
+ | `access_forbidden` | `identity` | Access to resource is forbidden |
148
+ | `already_exists` | `validation` | Resource already exists |
149
+ | `canceled` | `process` | Operation was canceled |
150
+ | `invalid_configuration` | `configuration` | Invalid widget configuration |
151
+ | `invalid_input` | `validation` | Invalid input provided |
152
+ | `not_found` | `resource` | Requested resource not found |
153
+ | `not_implemented` | `process` | Requested feature not implemented |
154
+ | `rate_limited` | `process` | Too many requests |
155
+ | `server_busy` | `process` | Server is too busy to handle request |
156
+ | `service_unreachable` | `process` | Unable to reach required service |
157
+ | `unauthorized` | `identity` | Authentication required |
158
+ | `unknown_error` | `internal` | Unexpected error occurred |
159
+ | `unprocessable_entity` | `validation` | Valid input but cannot be processed |
160
+
161
+ ## Error Details Object
162
+
163
+ | Property | Type | Description |
164
+ |----------|------|-------------|
165
+ | `cause` | `string` | Matches the top-level error cause |
166
+ | `contextId` | `string` | Context identifier (usually matches widget_id) |
167
+ | `message` | `string` | Human-readable error message |
168
+ | `timestamp` | `string` | ISO 8601 timestamp of when the error occurred |
169
+
170
+ ## Example
171
+
105
172
  ```javascript
173
+ widget.hideUiErrors(); // hide default UI errors and handle errors by listening to error events with widget.on('error')
174
+
106
175
  widget.on('error', (error) => {
107
- const errorDiv = document.getElementById('error');
108
- const errorMessage = document.getElementById('error-message');
109
-
110
- errorMessage.textContent = error.data.message;
111
- errorDiv.style.display = 'block';
176
+ console.log(error);
177
+ // {
178
+ // "event": "error",
179
+ // "purpose": "payment_source",
180
+ // "message_source": "widget.paydock",
181
+ // "ref_id": "",
182
+ // "widget_id": "d4744f30-dcf5-168e-7f78-c8273a3401d4",
183
+ // "error": {
184
+ // "category": "process",
185
+ // "cause": "service_unreachable",
186
+ // "details": {
187
+ // "cause": "service_unreachable",
188
+ // "contextId": "d4744f30-dcf5-168e-7f78-c8273a3401d4",
189
+ // "message": "The service is not availabe",
190
+ // "timestamp": "2025-02-13T09:30:21.157Z"
191
+ // },
192
+ // "retryable": false
193
+ // }
194
+ // }
112
195
  });
113
196
  ```
114
197
 
198
+ ## Handling Errors (Tips)
199
+
200
+ When handling errors, consider:
201
+
202
+ 1. Check the `retryable` flag to determine if the operation can be retried
203
+ 2. Use the `category` for high-level error handling logic
204
+ 3. Use the `cause` for specific error handling cases
205
+ 4. The `contextId` can be used for error tracking and debugging
206
+ 5. The `timestamp` helps with error logging and debugging
115
207
 
116
208
  ### Full example
117
209
 
@@ -119,9 +211,9 @@ widget.on('error', (error) => {
119
211
  <!DOCTYPE html>
120
212
  <html lang="en">
121
213
  <head>
122
- <meta charset="UTF-8">
123
- <title>Title</title>
124
- <style>iframe {border: 0;width: 100%;height: 400px;}</style>
214
+ <meta charset="UTF-8">
215
+ <title>Title</title>
216
+ <style>iframe {border: 0;width: 100%;height: 400px;}</style>
125
217
  </head>
126
218
  <body>
127
219
  <form id="paymentForm">
@@ -160,18 +252,18 @@ widget.on('error', (error) => {
160
252
 
161
253
  <script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
162
254
  <script>
163
- var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');
255
+ var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');
164
256
 
165
- widget.setSupportedCardIcons(['mastercard', 'visa']);
166
- widget.setFormFields(['phone', 'email']);
167
- widget.setRefId('custom-ref-id');
257
+ widget.setSupportedCardIcons(['mastercard', 'visa']);
258
+ widget.setFormFields(['phone', 'email']);
259
+ widget.setRefId('custom-ref-id');
168
260
  widget.onFinishInsert('input[name="payment_source_token"]', 'payment_source');
169
261
 
170
- widget.on('error', (error) => {
171
- document.getElementById('error-message').textContent = error.data.message;
262
+ widget.on('error', ({ error }) => {
263
+ document.getElementById('error-message').textContent = error.details.message;
172
264
  document.getElementById('error').style.display = 'block';
173
265
  });
174
- widget.load();
266
+ widget.load();
175
267
  </script>
176
268
 
177
269
  </body>
package/package.json CHANGED
@@ -104,7 +104,7 @@
104
104
  }
105
105
  },
106
106
  "name": "@paydock/client-sdk",
107
- "version": "1.120.1",
107
+ "version": "1.121.0",
108
108
  "scripts": {
109
109
  "build:doc": "node docs/html/marked.js",
110
110
  "build:js": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
@@ -160,7 +160,7 @@
160
160
  "@rollup/plugin-terser": "0.4.4",
161
161
  "@rollup/plugin-typescript": "11.1.6",
162
162
  "@rollup/pluginutils": "5.1.0",
163
- "@types/applepayjs": "14.0.8",
163
+ "@types/applepayjs": "14.0.9",
164
164
  "@types/es6-promise": "3.3.0",
165
165
  "@types/googlepay": "0.6.4",
166
166
  "@types/jasmine": "5.1.4",