@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.
- package/README.md +456 -33
- package/bundles/index.cjs +2686 -431
- package/bundles/index.cjs.d.ts +438 -37
- package/bundles/index.mjs +2686 -431
- package/bundles/index.mjs.d.ts +438 -37
- package/bundles/types/api/api-base.d.ts +6 -6
- package/bundles/types/api/api-base.d.ts.map +1 -1
- package/bundles/types/api/api-checkout-internal.d.ts +2 -2
- package/bundles/types/api/api-checkout-internal.d.ts.map +1 -1
- package/bundles/types/api/api.d.ts +9 -9
- package/bundles/types/api/api.d.ts.map +1 -1
- package/bundles/types/checkout/checkout.d.ts +28 -7
- package/bundles/types/checkout/checkout.d.ts.map +1 -1
- package/bundles/types/checkout/helpers/instruction-handler.d.ts +6 -4
- package/bundles/types/checkout/helpers/instruction-handler.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.afterpay_checkout_form.show.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.apple_pay_form.show.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.canvas_3ds.show.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.card_form.show.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.disable_payment_method_event.emit.d.ts +1 -0
- package/bundles/types/checkout/instructions/v1/instruction.disable_payment_method_event.emit.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.generic.show_message.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.google_pay_form.show.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.merchant_event.emit.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.payment_methods.show.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.paypal_form.show.d.ts.map +1 -1
- package/bundles/types/checkout/instructions/v1/instruction.zip_checkout_form.show.d.ts.map +1 -1
- package/bundles/types/checkout/layout-widgets/additionals.d.ts +1 -1
- package/bundles/types/checkout/layout-widgets/additionals.d.ts.map +1 -1
- package/bundles/types/checkout/layout-widgets/payment-methods-template.d.ts.map +1 -1
- package/bundles/types/checkout/layout-widgets/payment-methods.d.ts +2 -1
- package/bundles/types/checkout/layout-widgets/payment-methods.d.ts.map +1 -1
- package/bundles/types/checkout/layout-widgets/payment-template.d.ts +1 -1
- package/bundles/types/checkout/layout-widgets/payment-template.d.ts.map +1 -1
- package/bundles/types/components/iframe-event.d.ts +3 -8
- package/bundles/types/components/iframe-event.d.ts.map +1 -1
- package/bundles/types/components/link.d.ts +1 -1
- package/bundles/types/components/link.d.ts.map +1 -1
- package/bundles/types/components/param.d.ts +7 -0
- package/bundles/types/components/param.d.ts.map +1 -1
- package/bundles/types/components/wallet-background.d.ts.map +1 -1
- package/bundles/types/helper/event-error.d.ts +55 -0
- package/bundles/types/helper/event-error.d.ts.map +1 -0
- package/bundles/types/helper/process-event-error.d.ts +9 -0
- package/bundles/types/helper/process-event-error.d.ts.map +1 -0
- package/bundles/types/wallet-buttons/index.d.ts +6 -1
- package/bundles/types/wallet-buttons/index.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-buttons.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-cba-buttons.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/afterpay.wallet-service.d.ts +2 -0
- package/bundles/types/wallet-buttons/wallet-services/afterpay.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts +2 -2
- package/bundles/types/wallet-buttons/wallet-services/apple.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/flypay-v2.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/paypal.wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts +2 -0
- package/bundles/types/wallet-buttons/wallet-services/wallet-service.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts +70 -13
- package/bundles/types/wallet-buttons-express/base.wallet-button-express.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/enum/event.enum.d.ts +3 -1
- package/bundles/types/wallet-buttons-express/enum/event.enum.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/index.d.ts +114 -1
- package/bundles/types/wallet-buttons-express/index.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/charge-wallet-token-meta.interface.d.ts +30 -0
- package/bundles/types/wallet-buttons-express/interfaces/charge-wallet-token-meta.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-click-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-click-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-close-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-close-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-error-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-error-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-error-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-error-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-in-review-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-in-review-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-successful-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-payment-successful-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-data.interface.d.ts +21 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-data.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-response.interface.d.ts +9 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-address-change-event-response.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-data.interface.d.ts +13 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-data.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-response.interface.d.ts +9 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-shipping-option-change-event-response.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/interfaces/on-unavailable-event-data.interface.d.ts +2 -2
- package/bundles/types/wallet-buttons-express/interfaces/on-unavailable-event-data.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts +9 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/apple-pay.wallet-button-express.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-button-style.constant.d.ts +1 -3
- package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-button-style.constant.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-events.constant.d.ts +5 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/constants/apple-pay-events.constant.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts +8 -3
- package/bundles/types/wallet-buttons-express/services/apple-pay/interfaces/apple-pay-wallet-meta.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-contact-editing-mode.type.d.ts +5 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-contact-editing-mode.type.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-data.d.ts +21 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-data.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-method.type.d.ts +21 -0
- package/bundles/types/wallet-buttons-express/services/apple-pay/types/apple-pay-shipping-method.type.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-sdk.interface.d.ts +164 -0
- package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-sdk.interface.d.ts.map +1 -0
- package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts +1 -1
- package/bundles/types/wallet-buttons-express/services/paypal/interfaces/paypal-wallet-meta.interface.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts +9 -3
- package/bundles/types/wallet-buttons-express/services/paypal/paypal.wallet-button-express.d.ts.map +1 -1
- package/bundles/types/wallet-buttons-express/types/shipping-event-to-response.type.d.ts +6 -0
- package/bundles/types/wallet-buttons-express/types/shipping-event-to-response.type.d.ts.map +1 -0
- package/bundles/types/widget/configuration.d.ts.map +1 -1
- package/bundles/types/widget/html-multi-widget.d.ts.map +1 -1
- package/bundles/types/widget/multi-widget.d.ts +11 -3
- package/bundles/types/widget/multi-widget.d.ts.map +1 -1
- package/bundles/widget.umd.js +2688 -431
- package/bundles/widget.umd.js.d.ts +438 -37
- package/bundles/widget.umd.js.min.d.ts +438 -37
- package/bundles/widget.umd.min.js +1 -1
- package/docs/api-widget.md +38 -0
- package/docs/api-wrapper.md +3 -36
- package/docs/wallet-buttons-examples.md +4 -2
- package/docs/wallet-buttons-express.md +291 -2
- package/docs/wallet-buttons.md +3 -1
- package/docs/widget-examples.md +120 -28
- package/package.json +2 -2
- package/slate.md +124 -30
- package/bundles/types/helper/custom-error.d.ts +0 -8
- package/bundles/types/helper/custom-error.d.ts.map +0 -1
- package/bundles/types/wallet-buttons/helpers/apple-pay.helper.d.ts +0 -3
- package/bundles/types/wallet-buttons/helpers/apple-pay.helper.d.ts.map +0 -1
package/docs/widget-examples.md
CHANGED
|
@@ -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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
255
|
+
var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');
|
|
164
256
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
355
|
+
var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');
|
|
264
356
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
|
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 +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 +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"}
|