@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
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"}