@paydock/client-sdk 1.120.1 → 1.122.2-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 (130) hide show
  1. package/README.md +456 -33
  2. package/bundles/index.cjs +2686 -431
  3. package/bundles/index.cjs.d.ts +438 -37
  4. package/bundles/index.mjs +2686 -431
  5. package/bundles/index.mjs.d.ts +438 -37
  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 +28 -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-template.d.ts.map +1 -1
  32. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts +2 -1
  33. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
  34. package/bundles/types/checkout/layout-widgets/payment-template.d.ts +1 -1
  35. package/bundles/types/checkout/layout-widgets/payment-template.d.ts.map +1 -1
  36. package/bundles/types/components/iframe-event.d.ts +3 -8
  37. package/bundles/types/components/iframe-event.d.ts.map +1 -1
  38. package/bundles/types/components/link.d.ts +1 -1
  39. package/bundles/types/components/link.d.ts.map +1 -1
  40. package/bundles/types/components/param.d.ts +7 -0
  41. package/bundles/types/components/param.d.ts.map +1 -1
  42. package/bundles/types/components/wallet-background.d.ts.map +1 -1
  43. package/bundles/types/helper/event-error.d.ts +55 -0
  44. package/bundles/types/helper/event-error.d.ts.map +1 -0
  45. package/bundles/types/helper/process-event-error.d.ts +9 -0
  46. package/bundles/types/helper/process-event-error.d.ts.map +1 -0
  47. package/bundles/types/wallet-buttons/index.d.ts +6 -1
  48. package/bundles/types/wallet-buttons/index.d.ts.map +1 -1
  49. package/bundles/types/wallet-buttons/wallet-buttons.d.ts.map +1 -1
  50. package/bundles/types/wallet-buttons/wallet-cba-buttons.d.ts.map +1 -1
  51. package/bundles/types/wallet-buttons/wallet-services/afterpay.wallet-service.d.ts +2 -0
  52. package/bundles/types/wallet-buttons/wallet-services/afterpay.wallet-service.d.ts.map +1 -1
  53. package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts +2 -2
  54. package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts.map +1 -1
  55. package/bundles/types/wallet-buttons/wallet-services/flypay-v2.wallet-service.d.ts.map +1 -1
  56. package/bundles/types/wallet-buttons/wallet-services/paypal.wallet-service.d.ts.map +1 -1
  57. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts +2 -0
  58. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts.map +1 -1
  59. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts +70 -13
  60. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  61. package/bundles/types/wallet-buttons-express/enum/event.enum.d.ts +3 -1
  62. package/bundles/types/wallet-buttons-express/enum/event.enum.d.ts.map +1 -1
  63. package/bundles/types/wallet-buttons-express/index.d.ts +114 -1
  64. package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
  65. package/bundles/types/wallet-buttons-express/interfaces/charge-wallet-token-meta.interface.d.ts +30 -0
  66. package/bundles/types/wallet-buttons-express/interfaces/charge-wallet-token-meta.interface.d.ts.map +1 -1
  67. package/bundles/types/wallet-buttons-express/interfaces/on-click-event-data.interface.d.ts +2 -2
  68. package/bundles/types/wallet-buttons-express/interfaces/on-click-event-data.interface.d.ts.map +1 -1
  69. package/bundles/types/wallet-buttons-express/interfaces/on-close-event-data.interface.d.ts +2 -2
  70. package/bundles/types/wallet-buttons-express/interfaces/on-close-event-data.interface.d.ts.map +1 -1
  71. package/bundles/types/wallet-buttons-express/interfaces/on-error-event-data.interface.d.ts +2 -2
  72. package/bundles/types/wallet-buttons-express/interfaces/on-error-event-data.interface.d.ts.map +1 -1
  73. package/bundles/types/wallet-buttons-express/interfaces/on-payment-error-event-data.interface.d.ts +2 -2
  74. package/bundles/types/wallet-buttons-express/interfaces/on-payment-error-event-data.interface.d.ts.map +1 -1
  75. package/bundles/types/wallet-buttons-express/interfaces/on-payment-in-review-event-data.interface.d.ts +2 -2
  76. package/bundles/types/wallet-buttons-express/interfaces/on-payment-in-review-event-data.interface.d.ts.map +1 -1
  77. package/bundles/types/wallet-buttons-express/interfaces/on-payment-successful-event-data.interface.d.ts +2 -2
  78. package/bundles/types/wallet-buttons-express/interfaces/on-payment-successful-event-data.interface.d.ts.map +1 -1
  79. package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-data.interface.d.ts +21 -0
  80. package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-data.interface.d.ts.map +1 -0
  81. package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-response.interface.d.ts +9 -0
  82. package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-response.interface.d.ts.map +1 -0
  83. package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-data.interface.d.ts +13 -0
  84. package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-data.interface.d.ts.map +1 -0
  85. package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-response.interface.d.ts +9 -0
  86. package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-response.interface.d.ts.map +1 -0
  87. package/bundles/types/wallet-buttons-express/interfaces/on-unavailable-event-data.interface.d.ts +2 -2
  88. package/bundles/types/wallet-buttons-express/interfaces/on-unavailable-event-data.interface.d.ts.map +1 -1
  89. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts +9 -1
  90. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
  91. package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-button-style.constant.d.ts +1 -3
  92. package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-button-style.constant.d.ts.map +1 -1
  93. package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-events.constant.d.ts +5 -0
  94. package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-events.constant.d.ts.map +1 -0
  95. package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts +8 -3
  96. package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts.map +1 -1
  97. package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-contact-editing-mode.type.d.ts +5 -0
  98. package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-contact-editing-mode.type.d.ts.map +1 -0
  99. package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-data.d.ts +21 -0
  100. package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-data.d.ts.map +1 -0
  101. package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-method.type.d.ts +21 -0
  102. package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-method.type.d.ts.map +1 -0
  103. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-sdk.interface.d.ts +164 -0
  104. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-sdk.interface.d.ts.map +1 -0
  105. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts +1 -1
  106. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts.map +1 -1
  107. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts +9 -3
  108. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
  109. package/bundles/types/wallet-buttons-express/types/shipping-event-to-response.type.d.ts +6 -0
  110. package/bundles/types/wallet-buttons-express/types/shipping-event-to-response.type.d.ts.map +1 -0
  111. package/bundles/types/widget/configuration.d.ts.map +1 -1
  112. package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
  113. package/bundles/types/widget/multi-widget.d.ts +11 -3
  114. package/bundles/types/widget/multi-widget.d.ts.map +1 -1
  115. package/bundles/widget.umd.js +2688 -431
  116. package/bundles/widget.umd.js.d.ts +438 -37
  117. package/bundles/widget.umd.js.min.d.ts +438 -37
  118. package/bundles/widget.umd.min.js +1 -1
  119. package/docs/api-widget.md +38 -0
  120. package/docs/api-wrapper.md +3 -36
  121. package/docs/wallet-buttons-examples.md +4 -2
  122. package/docs/wallet-buttons-express.md +291 -2
  123. package/docs/wallet-buttons.md +3 -1
  124. package/docs/widget-examples.md +120 -28
  125. package/package.json +2 -2
  126. package/slate.md +124 -30
  127. package/bundles/types/helper/custom-error.d.ts +0 -8
  128. package/bundles/types/helper/custom-error.d.ts.map +0 -1
  129. package/bundles/types/wallet-buttons/helpers/apple-pay.helper.d.ts +0 -3
  130. package/bundles/types/wallet-buttons/helpers/apple-pay.helper.d.ts.map +0 -1
@@ -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.122.2-beta",
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",
package/slate.md CHANGED
@@ -99,6 +99,7 @@ through named imports or namespaced imports.
99
99
 
100
100
 
101
101
  ## Widget
102
+
102
103
  You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#widget-simple-example)
103
104
 
104
105
  A payment form where it is possible to enter card data/bank accounts and then receive a one-time
@@ -115,8 +116,8 @@ It is possible in real-time to monitor the actions of user with widget and get i
115
116
 
116
117
  You must create a container for the widget. Inside this tag, the widget will be initialized
117
118
 
118
-
119
119
  ### Initialization
120
+
120
121
  ```javascript
121
122
  var widget = new paydock.HtmlWidget('#widget', 'publicKey');
122
123
  widget.load();
@@ -133,7 +134,6 @@ widget.load();
133
134
 
134
135
  Then write only need 2 lines of code in js to initialize widget
135
136
 
136
-
137
137
  ### Full example
138
138
 
139
139
  ```html
@@ -159,19 +159,18 @@ Then write only need 2 lines of code in js to initialize widget
159
159
  </html>
160
160
  ```
161
161
 
162
-
163
162
  ## Widget advanced example
164
163
 
165
164
  ### Customization
166
165
 
167
166
  ```javascript
168
167
  widget.setStyles({
169
- background_color: 'rgb(0, 0, 0)',
170
- border_color: 'yellow',
171
- text_color: '#FFFFAA',
172
- button_color: 'rgba(255, 255, 255, 0.9)',
173
- font_size: '20px'
174
- });
168
+ background_color: 'rgb(0, 0, 0)',
169
+ border_color: 'yellow',
170
+ text_color: '#FFFFAA',
171
+ button_color: 'rgba(255, 255, 255, 0.9)',
172
+ font_size: '20px'
173
+ });
175
174
  ```
176
175
 
177
176
  This example shows how you can customize to your needs and design
@@ -180,9 +179,9 @@ This example shows how you can customize to your needs and design
180
179
 
181
180
  ```html
182
181
  <div id="widget"
183
- widget-style="text-color: #FFFFAA; border-color: #yellow"
184
- title="Payment form"
185
- finish-text="Payment resource was successfully accepted"></div>
182
+ widget-style="text-color: #FFFFAA; border-color: #yellow"
183
+ title="Payment form"
184
+ finish-text="Payment resource was successfully accepted"></div>
186
185
  ```
187
186
 
188
187
  This example shows how you can set style and texts from html
@@ -199,19 +198,112 @@ widget.setSupportedCardIcons(['mastercard', 'visa']); // add icons of supported
199
198
 
200
199
  This example shows how you can use a lot of other methods to settings your form
201
200
 
202
-
203
201
  ### Error handling
204
202
 
203
+ ## Overview
204
+
205
+ 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.
206
+
207
+ ## Error Event Structure
208
+
209
+ ### Base Properties
210
+
211
+ | Property | Type | Description |
212
+ |----------|------|-------------|
213
+ | `event` | `string` | Always set to `"error"` |
214
+ | `purpose` | `string` | Indicates the purpose of the action that triggered the error event (e.g., `"payment_source"`) |
215
+ | `message_source` | `string` | Source of the message (e.g., `"widget.paydock"`) |
216
+ | `ref_id` | `string` | Reference ID for the operation |
217
+ | `widget_id` | `string` | Unique identifier of the widget instance |
218
+ | `error` | `object` | Error object containing error information |
219
+
220
+ ### Error Object Properties
221
+
222
+ The `error` object contains detailed information about the error:
223
+
224
+ | Property | Type | Description |
225
+ |----------|------|-------------|
226
+ | `category` | `string` | High-level error classification |
227
+ | `cause` | `string` | Specific error cause |
228
+ | `retryable` | `boolean` | Indicates if the operation can be retried |
229
+ | `details` | `object` | Additional error context |
230
+
231
+ ## Error Categories
232
+
233
+ | Category | Description |
234
+ |----------|-------------|
235
+ | `configuration` | Configuration-related errors |
236
+ | `identity_access_management` | Authentication and authorization errors |
237
+ | `internal` | Internal system errors |
238
+ | `process` | Process and operation errors |
239
+ | `resource` | Resource-related errors |
240
+ | `validation` | Input validation errors |
241
+
242
+ ## Error Causes
243
+
244
+ | Cause | Category | Description |
245
+ |-------|----------|-------------|
246
+ | `aborted` | `process` | Operation was aborted |
247
+ | `access_forbidden` | `identity` | Access to resource is forbidden |
248
+ | `already_exists` | `validation` | Resource already exists |
249
+ | `canceled` | `process` | Operation was canceled |
250
+ | `invalid_configuration` | `configuration` | Invalid widget configuration |
251
+ | `invalid_input` | `validation` | Invalid input provided |
252
+ | `not_found` | `resource` | Requested resource not found |
253
+ | `not_implemented` | `process` | Requested feature not implemented |
254
+ | `rate_limited` | `process` | Too many requests |
255
+ | `server_busy` | `process` | Server is too busy to handle request |
256
+ | `service_unreachable` | `process` | Unable to reach required service |
257
+ | `unauthorized` | `identity` | Authentication required |
258
+ | `unknown_error` | `internal` | Unexpected error occurred |
259
+ | `unprocessable_entity` | `validation` | Valid input but cannot be processed |
260
+
261
+ ## Error Details Object
262
+
263
+ | Property | Type | Description |
264
+ |----------|------|-------------|
265
+ | `cause` | `string` | Matches the top-level error cause |
266
+ | `contextId` | `string` | Context identifier (usually matches widget_id) |
267
+ | `message` | `string` | Human-readable error message |
268
+ | `timestamp` | `string` | ISO 8601 timestamp of when the error occurred |
269
+
270
+ ## Example
271
+
205
272
  ```javascript
273
+ widget.hideUiErrors(); // hide default UI errors and handle errors by listening to error events with widget.on('error')
274
+
206
275
  widget.on('error', (error) => {
207
- const errorDiv = document.getElementById('error');
208
- const errorMessage = document.getElementById('error-message');
209
-
210
- errorMessage.textContent = error.data.message;
211
- errorDiv.style.display = 'block';
276
+ console.log(error);
277
+ // {
278
+ // "event": "error",
279
+ // "purpose": "payment_source",
280
+ // "message_source": "widget.paydock",
281
+ // "ref_id": "",
282
+ // "widget_id": "d4744f30-dcf5-168e-7f78-c8273a3401d4",
283
+ // "error": {
284
+ // "category": "process",
285
+ // "cause": "service_unreachable",
286
+ // "details": {
287
+ // "cause": "service_unreachable",
288
+ // "contextId": "d4744f30-dcf5-168e-7f78-c8273a3401d4",
289
+ // "message": "The service is not availabe",
290
+ // "timestamp": "2025-02-13T09:30:21.157Z"
291
+ // },
292
+ // "retryable": false
293
+ // }
294
+ // }
212
295
  });
213
296
  ```
214
297
 
298
+ ## Handling Errors (Tips)
299
+
300
+ When handling errors, consider:
301
+
302
+ 1. Check the `retryable` flag to determine if the operation can be retried
303
+ 2. Use the `category` for high-level error handling logic
304
+ 3. Use the `cause` for specific error handling cases
305
+ 4. The `contextId` can be used for error tracking and debugging
306
+ 5. The `timestamp` helps with error logging and debugging
215
307
 
216
308
  ### Full example
217
309
 
@@ -219,9 +311,9 @@ widget.on('error', (error) => {
219
311
  <!DOCTYPE html>
220
312
  <html lang="en">
221
313
  <head>
222
- <meta charset="UTF-8">
223
- <title>Title</title>
224
- <style>iframe {border: 0;width: 100%;height: 400px;}</style>
314
+ <meta charset="UTF-8">
315
+ <title>Title</title>
316
+ <style>iframe {border: 0;width: 100%;height: 400px;}</style>
225
317
  </head>
226
318
  <body>
227
319
  <form id="paymentForm">
@@ -260,18 +352,18 @@ widget.on('error', (error) => {
260
352
 
261
353
  <script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
262
354
  <script>
263
- var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');
355
+ var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');
264
356
 
265
- widget.setSupportedCardIcons(['mastercard', 'visa']);
266
- widget.setFormFields(['phone', 'email']);
267
- widget.setRefId('custom-ref-id');
357
+ widget.setSupportedCardIcons(['mastercard', 'visa']);
358
+ widget.setFormFields(['phone', 'email']);
359
+ widget.setRefId('custom-ref-id');
268
360
  widget.onFinishInsert('input[name="payment_source_token"]', 'payment_source');
269
361
 
270
- widget.on('error', (error) => {
271
- document.getElementById('error-message').textContent = error.data.message;
362
+ widget.on('error', ({ error }) => {
363
+ document.getElementById('error-message').textContent = error.details.message;
272
364
  document.getElementById('error').style.display = 'block';
273
365
  });
274
- widget.load();
366
+ widget.load();
275
367
  </script>
276
368
 
277
369
  </body>
@@ -1335,7 +1427,7 @@ button.onUpdate((data) => {
1335
1427
  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.
1336
1428
  All three callbacks return relevant data according to each one of the scenarios.
1337
1429
 
1338
- 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.
1430
+ >*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.*
1339
1431
 
1340
1432
  ```javascript
1341
1433
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
@@ -1537,7 +1629,7 @@ _(Required `meta` fields: - . Optional `meta` fields: -)_
1537
1629
 
1538
1630
  This example shows how to use these functions for **ApplePay via MPGS** and **GooglePay via MPGS**:
1539
1631
 
1540
- _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `raw_data_initialization`, `request_shipping`, `style.button_type`)_
1632
+ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `raw_data_initialization`, `request_shipping`, `style.button_type`, `style.button_style`)_
1541
1633
  ### ApplePay and GooglePay via MPGS Full example
1542
1634
 
1543
1635
  ```html
@@ -1569,6 +1661,7 @@ _(Required `meta` fields: `amount_label`, `country`. Optional `meta` fields: `ra
1569
1661
  },
1570
1662
  apple: {
1571
1663
  button_type: 'buy',
1664
+ button_style: 'black',
1572
1665
  },
1573
1666
  },
1574
1667
  shipping_options: [
@@ -1685,6 +1778,7 @@ Similarly, for **GooglePay via MPGS** you can initialize the `PaymentMethodSpeci
1685
1778
  },
1686
1779
  apple: {
1687
1780
  button_type: 'buy',
1781
+ button_style: 'black',
1688
1782
  },
1689
1783
  },
1690
1784
  shipping_options: [
@@ -1,8 +0,0 @@
1
- export declare class CustomError extends Error {
2
- status?: number | undefined;
3
- data: {
4
- _message: string;
5
- } & Record<string, any>;
6
- constructor(message: string, status?: number, data?: any);
7
- }
8
- //# sourceMappingURL=custom-error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"custom-error.d.ts","sourceRoot":"","sources":["../../src/helper/custom-error.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAMzD"}
@@ -1,3 +0,0 @@
1
- import type { ApplePayStyles } from "../../components/param";
2
- export declare const APPLE_PAY_BUTTON_TYPES_ARIA_LABEL_MAPPING: Record<ApplePayStyles['button_type'], string>;
3
- //# sourceMappingURL=apple-pay.helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apple-pay.helper.d.ts","sourceRoot":"","sources":["../../../src/wallet-buttons/helpers/apple-pay.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,eAAO,MAAM,yCAAyC,EAAE,MAAM,CAC5D,cAAc,CAAC,aAAa,CAAC,EAC7B,MAAM,CAmBP,CAAC"}