@paydock/client-sdk 1.113.2 → 1.114.7-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 (107) hide show
  1. package/README.md +757 -80
  2. package/bundles/index.cjs +1344 -190
  3. package/bundles/index.cjs.d.ts +2355 -2058
  4. package/bundles/index.mjs +1340 -187
  5. package/bundles/index.mjs.d.ts +2355 -2058
  6. package/bundles/types/api/api-base.d.ts.map +1 -1
  7. package/bundles/types/api/api-charge-internal.d.ts +1 -0
  8. package/bundles/types/api/api-charge-internal.d.ts.map +1 -1
  9. package/bundles/types/api/api-checkout-internal.d.ts +1 -0
  10. package/bundles/types/api/api-checkout-internal.d.ts.map +1 -1
  11. package/bundles/types/checkout/helpers/resource-helper.d.ts +4 -3
  12. package/bundles/types/checkout/helpers/resource-helper.d.ts.map +1 -1
  13. package/bundles/types/checkout/helpers/session-helper.d.ts +3 -0
  14. package/bundles/types/checkout/helpers/session-helper.d.ts.map +1 -1
  15. package/bundles/types/checkout/instructions/v1/instruction.afterpay_checkout_form.show.d.ts.map +1 -1
  16. package/bundles/types/checkout/instructions/v1/instruction.card_form.show.d.ts.map +1 -1
  17. package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts.map +1 -1
  18. package/bundles/types/checkout/instructions/v1/instruction.zip_checkout_form.show.d.ts.map +1 -1
  19. package/bundles/types/checkout/layout-widgets/additionals.d.ts +1 -1
  20. package/bundles/types/checkout/layout-widgets/additionals.d.ts.map +1 -1
  21. package/bundles/types/checkout/layout-widgets/payment-methods-template.d.ts.map +1 -1
  22. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts +1 -1
  23. package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
  24. package/bundles/types/components/iframe-event.d.ts +34 -29
  25. package/bundles/types/components/iframe-event.d.ts.map +1 -1
  26. package/bundles/types/components/iframe.d.ts +2 -2
  27. package/bundles/types/components/iframe.d.ts.map +1 -1
  28. package/bundles/types/components/param.d.ts +3 -0
  29. package/bundles/types/components/param.d.ts.map +1 -1
  30. package/bundles/types/configs/env/environment.paydock.d.ts.map +1 -1
  31. package/bundles/types/helper/event-error.d.ts +55 -0
  32. package/bundles/types/helper/event-error.d.ts.map +1 -0
  33. package/bundles/types/helper/process-event-error.d.ts +9 -0
  34. package/bundles/types/helper/process-event-error.d.ts.map +1 -0
  35. package/bundles/types/index-cba.d.ts +5 -1
  36. package/bundles/types/index-cba.d.ts.map +1 -1
  37. package/bundles/types/index.d.ts +3 -1
  38. package/bundles/types/index.d.ts.map +1 -1
  39. package/bundles/types/paypal-data-collector/index.d.ts +23 -0
  40. package/bundles/types/paypal-data-collector/index.d.ts.map +1 -0
  41. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts +58 -0
  42. package/bundles/types/paypal-data-collector/paypal-data-collector.d.ts.map +1 -0
  43. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts +21 -0
  44. package/bundles/types/paypal-data-collector/paypal-data-collector.interfaces.d.ts.map +1 -0
  45. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts +17 -0
  46. package/bundles/types/paypal-data-collector/paypal-data-collector.service.d.ts.map +1 -0
  47. package/bundles/types/paypal-save-payment-source/index.d.ts +61 -0
  48. package/bundles/types/paypal-save-payment-source/index.d.ts.map +1 -0
  49. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts +85 -0
  50. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.d.ts.map +1 -0
  51. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts +83 -0
  52. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.interfaces.d.ts.map +1 -0
  53. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts +35 -0
  54. package/bundles/types/paypal-save-payment-source/paypal-save-payment-source.service.d.ts.map +1 -0
  55. package/bundles/types/secure-remote-commerce/index.d.ts +2 -1
  56. package/bundles/types/secure-remote-commerce/index.d.ts.map +1 -1
  57. package/bundles/types/secure-remote-commerce/interfaces.d.ts +2 -5
  58. package/bundles/types/secure-remote-commerce/interfaces.d.ts.map +1 -1
  59. package/bundles/types/secure-remote-commerce/providers/mastercard-src/mastercard-src.d.ts.map +1 -1
  60. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts +12 -0
  61. package/bundles/types/shared/services/configuration-validation/configuration-validation.d.ts.map +1 -0
  62. package/bundles/types/shared/services/configuration-validation/types.d.ts +73 -0
  63. package/bundles/types/shared/services/configuration-validation/types.d.ts.map +1 -0
  64. package/bundles/types/wallet-buttons/enums.d.ts +12 -0
  65. package/bundles/types/wallet-buttons/enums.d.ts.map +1 -0
  66. package/bundles/types/wallet-buttons/index.d.ts +5 -1
  67. package/bundles/types/wallet-buttons/index.d.ts.map +1 -1
  68. package/bundles/types/wallet-buttons/wallet-buttons.d.ts +28 -15
  69. package/bundles/types/wallet-buttons/wallet-buttons.d.ts.map +1 -1
  70. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts +1 -1
  71. package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts.map +1 -1
  72. package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
  73. package/bundles/types/wallet-buttons-express/index.d.ts +1 -0
  74. package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
  75. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts +1 -0
  76. package/bundles/types/wallet-buttons-express/interfaces/wallet-capture-request.interface.d.ts.map +1 -1
  77. package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
  78. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts +1 -0
  79. package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts.map +1 -1
  80. package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
  81. package/bundles/types/widget/configuration.d.ts +13 -9
  82. package/bundles/types/widget/configuration.d.ts.map +1 -1
  83. package/bundles/types/widget/html-multi-widget.d.ts +1 -2
  84. package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
  85. package/bundles/types/widget/html-widget.d.ts +2 -1
  86. package/bundles/types/widget/html-widget.d.ts.map +1 -1
  87. package/bundles/types/widget/multi-widget.d.ts +14 -2
  88. package/bundles/types/widget/multi-widget.d.ts.map +1 -1
  89. package/bundles/widget.umd.js +1344 -190
  90. package/bundles/widget.umd.js.d.ts +2355 -2058
  91. package/bundles/widget.umd.js.min.d.ts +2355 -2058
  92. package/bundles/widget.umd.min.js +1 -61
  93. package/docs/api-widget.md +59 -16
  94. package/docs/click-to-pay-examples.md +0 -36
  95. package/docs/click-to-pay.md +1 -3
  96. package/docs/paypal-data-collector-examples.md +59 -0
  97. package/docs/paypal-data-collector.md +149 -0
  98. package/docs/paypal-save-payment-source-examples.md +63 -0
  99. package/docs/paypal-save-payment-source.md +256 -0
  100. package/docs/wallet-buttons-examples.md +1 -1
  101. package/docs/wallet-buttons-express-examples.md +1 -1
  102. package/docs/wallet-buttons-express.md +1 -0
  103. package/docs/wallet-buttons.md +3 -0
  104. package/docs/widget-examples.md +162 -25
  105. package/examples/multi-html-widget/extend.html +5 -0
  106. package/package.json +2 -2
  107. package/slate.md +161 -60
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,36 +198,174 @@ 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
 
201
+ ### Error handling
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
+
272
+ ```javascript
273
+ widget.hideUiErrors(); // hide default UI errors and handle errors by listening to error events with widget.on('error')
274
+
275
+ widget.on('error', (error) => {
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
+ // }
295
+ });
296
+ ```
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
307
+
202
308
  ### Full example
203
309
 
204
310
  ```html
205
311
  <!DOCTYPE html>
206
312
  <html lang="en">
207
313
  <head>
208
- <meta charset="UTF-8">
209
- <title>Title</title>
210
- <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>
211
317
  </head>
212
318
  <body>
213
319
  <form id="paymentForm">
214
320
  <div id="widget"
215
321
  widget-style="text-color: #FFFFAA; border-color: #yellow"
216
322
  title="Payment form"
217
- finish-text="Payment resource was successfully accepted"></div>
323
+ finish-text="Payment resource was successfully accepted">
324
+ </div>
325
+
326
+ <div
327
+ id="error"
328
+ style="
329
+ display: none;
330
+ max-width: 600px;
331
+ margin: 16px auto;
332
+ padding: 16px 20px;
333
+ border-radius: 8px;
334
+ background-color: #FEF2F2;
335
+ border: 1px solid #FEE2E2;
336
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
337
+ font-family: system-ui, -apple-system, sans-serif;
338
+ color: #991B1B;
339
+ line-height: 1.5;
340
+ font-size: 14px;
341
+ "
342
+ title="error"
343
+ >
344
+ <div style="display: flex; align-items: flex-start; gap: 12px;">
345
+ <div>
346
+ <h4 style="margin: 0 0 4px 0; font-size: 14px; font-weight: 600;">Access Error</h4>
347
+ <div id="error-message"></div>
348
+ </div>
349
+ </div>
350
+ </div>
218
351
  </form>
219
352
 
220
353
  <script src="https://widget.paydock.com/sdk/latest/widget.umd.js" ></script>
221
354
  <script>
222
- var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');
355
+ var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');
223
356
 
224
- widget.setSupportedCardIcons(['mastercard', 'visa']);
225
- widget.setFormFields(['phone', 'email']);
226
- widget.setRefId('custom-ref-id');
227
- widget.onFinishInsert('input[name="payment_source_token"]', 'payment_source');z
357
+ widget.setSupportedCardIcons(['mastercard', 'visa']);
358
+ widget.setFormFields(['phone', 'email']);
359
+ widget.setRefId('custom-ref-id');
360
+ widget.onFinishInsert('input[name="payment_source_token"]', 'payment_source');
228
361
 
229
- widget.load();
230
- </script>
362
+ widget.on('error', ({ error }) => {
363
+ document.getElementById('error-message').textContent = error.details.message;
364
+ document.getElementById('error').style.display = 'block';
365
+ });
366
+ widget.load();
231
367
  </script>
368
+
232
369
  </body>
233
370
  </html>
234
371
  ```
@@ -1481,7 +1618,7 @@ _(Required `meta` fields: - . Optional `meta` fields: -)_
1481
1618
  },
1482
1619
  );
1483
1620
  button.setEnv('sandbox');
1484
- button.onUnavailable(() => console.log("No wallet buttons available"));
1621
+ button.onUnavailable((data) => console.log("No wallet buttons available"));
1485
1622
  button.onPaymentSuccessful((data) => console.log("The payment was successful"));
1486
1623
  button.onPaymentError((data) => console.log("The payment was not successful"));
1487
1624
  button.onAuthTokensChanged((data) => console.log('Authentication tokens changed'));
@@ -1922,39 +2059,3 @@ src.setStyles({
1922
2059
  font_family: 'Arial',
1923
2060
  });
1924
2061
  ```
1925
-
1926
- ## Recognition token
1927
-
1928
- In order to store user information for further payments, click to pay provides a recognition token that is used to load user information.
1929
- If you already have a recognitionToken stored, you can use it in meta to load the user information.
1930
-
1931
- ### Storage suggestions
1932
- Merchant can store the tokens by dropping the token as a 1st party cookie in the browser, and must ensure to manage all the security aspects around dropping/storing the cookie by following the security standards:
1933
-
1934
- - `Expiration Date=` cookie should be set to expire at a max 180 days
1935
- - `Secure` flag
1936
- - `httpOnly` flag
1937
- - `sameSite=` strict
1938
- - `Value=` recognition token JWT
1939
-
1940
- ### Example code
1941
-
1942
- ```javascript
1943
- var src = new paydock.ClickToPay(
1944
- "#checkoutIframe",
1945
- "service_id",
1946
- "paydock_public_key",
1947
- {
1948
- "recognition_token": "eyJraWQiOiIy...",
1949
- },
1950
- );
1951
- src.on('recognitionTokenRequested', (data) => {
1952
- console.log('Recognition token was found: ' + data.data.recognitionToken);
1953
- // Add recognition token to your store
1954
- });
1955
-
1956
- src.on('recognitionTokenDropped', () => {
1957
- console.log('Recognition token was droped');
1958
- // Delete recognition token from your store
1959
- });
1960
- ```