@paydock/client-sdk 1.145.0-beta → 1.147.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 (43) hide show
  1. package/README.md +129 -1
  2. package/bundles/index.cjs +746 -102
  3. package/bundles/index.cjs.d.ts +131 -14
  4. package/bundles/index.mjs +746 -103
  5. package/bundles/index.mjs.d.ts +131 -14
  6. package/bundles/types/api/api-base.d.ts +6 -0
  7. package/bundles/types/api/api-base.d.ts.map +1 -1
  8. package/bundles/types/api/api-charge-internal.d.ts +1 -5
  9. package/bundles/types/api/api-charge-internal.d.ts.map +1 -1
  10. package/bundles/types/canvas-3ds/canvas-3ds-event-map.d.ts +50 -0
  11. package/bundles/types/canvas-3ds/canvas-3ds-event-map.d.ts.map +1 -1
  12. package/bundles/types/canvas-3ds/canvas-3ds.d.ts +7 -5
  13. package/bundles/types/canvas-3ds/canvas-3ds.d.ts.map +1 -1
  14. package/bundles/types/canvas-3ds/index.d.ts +1 -1
  15. package/bundles/types/canvas-3ds/index.d.ts.map +1 -1
  16. package/bundles/types/canvas-3ds/services/gpayments-service.d.ts +117 -2
  17. package/bundles/types/canvas-3ds/services/gpayments-service.d.ts.map +1 -1
  18. package/bundles/types/canvas-3ds/services/standalone3ds-service.d.ts +6 -0
  19. package/bundles/types/canvas-3ds/services/standalone3ds-service.d.ts.map +1 -1
  20. package/bundles/types/components/iframe-event.d.ts +4 -3
  21. package/bundles/types/components/iframe-event.d.ts.map +1 -1
  22. package/bundles/types/components/iframe.d.ts +5 -0
  23. package/bundles/types/components/iframe.d.ts.map +1 -1
  24. package/bundles/types/components/param.d.ts +19 -0
  25. package/bundles/types/components/param.d.ts.map +1 -1
  26. package/bundles/types/index-cba.d.ts +1 -1
  27. package/bundles/types/index-cba.d.ts.map +1 -1
  28. package/bundles/types/index.d.ts +2 -2
  29. package/bundles/types/index.d.ts.map +1 -1
  30. package/bundles/types/widget/multi-widget.d.ts +19 -0
  31. package/bundles/types/widget/multi-widget.d.ts.map +1 -1
  32. package/bundles/widget.umd.js +746 -102
  33. package/bundles/widget.umd.js.d.ts +131 -14
  34. package/bundles/widget.umd.js.min.d.ts +131 -14
  35. package/bundles/widget.umd.min.js +1 -1
  36. package/docs/api-canvas3ds.md +10 -8
  37. package/docs/api-checkout-button.md +15 -0
  38. package/docs/api-ps-widget.md +15 -0
  39. package/docs/api-widget.md +15 -0
  40. package/docs/canvas3ds-examples.md +43 -1
  41. package/docs/widget-examples.md +41 -0
  42. package/package.json +15 -9
  43. package/slate.md +84 -1
package/README.md CHANGED
@@ -194,8 +194,48 @@ widget.setRefId('id'); // your unique identifier to identify the data
194
194
  widget.setFormFields(['phone', 'email']); // add additional fields for form of widget
195
195
 
196
196
  widget.setSupportedCardIcons(['mastercard', 'visa']); // add icons of supported card types
197
+
198
+ widget.setAllowedCardSchemes(['mastercard', 'visa']); // restrict which card schemes the card number field accepts
199
+ ```
200
+
201
+ ### Restricting accepted card schemes
202
+
203
+ `setAllowedCardSchemes(schemes)` restricts which card schemes the card number field accepts, **without** changing
204
+ which card icons the widget displays. Call it before `load()`.
205
+
206
+ ```javascript
207
+ widget.setAllowedCardSchemes(['visa', 'mastercard']);
197
208
  ```
198
209
 
210
+ Accepted identifiers — the schemes the widget can resolve from a card number:
211
+
212
+ `amex`, `ausbc`, `diners`, `discover`, `eftpos`, `japcb`, `mastercard`, `solo`, `unionpay`, `visa`
213
+
214
+ Behaviour:
215
+
216
+ - **Not called, or an empty array** — every scheme is accepted. Existing integrations are unaffected.
217
+ - **Case-insensitive**, and surrounding whitespace is ignored: `' Visa '` and `'MASTERCARD'` both work. Note that
218
+ `setSupportedCardIcons` matches case-**sensitively**; the two methods differ here.
219
+ - **Unsupported identifiers are ignored with a `console.warn`** naming the value, and never throw. A list in which
220
+ every identifier is unsupported therefore applies **no restriction at all** — check the console if a restriction
221
+ seems to have no effect. The icon-only values `visa_white` and `eftpos_white` are not schemes and are rejected,
222
+ as are `laser` and `maestro`, which the widget can never resolve from a card number.
223
+ - **Takes precedence over `setSupportedCardIcons`.** When a non-empty list is supplied here, it is the only list
224
+ used for validation, and the second argument of `setSupportedCardIcons` no longer affects validation. Icons keep
225
+ coming from `setSupportedCardIcons`, so a scheme can legitimately be shown as an icon and still be rejected —
226
+ make sure that is what you intend:
227
+
228
+ ```javascript
229
+ widget.setSupportedCardIcons(['visa', 'mastercard', 'amex'], true);
230
+ widget.setAllowedCardSchemes(['visa', 'mastercard']);
231
+ // three icons are displayed; an Amex card is rejected
232
+ ```
233
+
234
+ - **Calling it again replaces the previous list** rather than merging with it.
235
+ - A card of a rejected scheme shows `Card type not accepted.` on the card number field, the submit button is
236
+ disabled, and the submit handler refuses the card even if the button is re-enabled outside the widget. The same
237
+ message is shown for a card whose scheme cannot be resolved at all.
238
+
199
239
  This example shows how you can use a lot of other methods to settings your form
200
240
 
201
241
  ### Error handling
@@ -355,6 +395,7 @@ When handling errors, consider:
355
395
  var widget = new paydock.HtmlWidget('#widget', 'publicKey', 'gatewayId');
356
396
 
357
397
  widget.setSupportedCardIcons(['mastercard', 'visa']);
398
+ widget.setAllowedCardSchemes(['mastercard', 'visa']);
358
399
  widget.setFormFields(['phone', 'email']);
359
400
  widget.setRefId('custom-ref-id');
360
401
  widget.onFinishInsert('input[name="payment_source_token"]', 'payment_source');
@@ -400,6 +441,12 @@ When handling errors, consider:
400
441
  <dt><a href="#user-content-w_GENERIC_VALIDATORS">GENERIC_VALIDATORS</a> : <code>Record.&lt;string, string&gt;</code></dt>
401
442
  <dd><p>List of available generic form field validators and their definition</p>
402
443
  </dd>
444
+ <dt><a href="#user-content-w_CARD_SCHEME">CARD_SCHEME</a></dt>
445
+ <dd><p>Card schemes the widget is able to resolve from a card number, and therefore the only values
446
+ <code>setAllowedCardSchemes</code> accepts. This is a separate vocabulary from SUPPORTED_CARD_TYPES, which drives the
447
+ card icons: it omits the icon-only variants <code>visa_white</code> / <code>eftpos_white</code>, and the <code>laser</code> / <code>maestro</code>
448
+ identifiers the widget can never resolve — allowing those would be configuration that can never match.</p>
449
+ </dd>
403
450
  <dt><a href="#user-content-w_TRIGGER">TRIGGER</a> : <code>object</code></dt>
404
451
  <dd><p>List of available triggers</p>
405
452
  </dd>
@@ -786,6 +833,15 @@ List of available generic form field validators and their definition
786
833
  | --- | --- | --- | --- |
787
834
  | REQUIRED | <code>string</code> | <code>&quot;required&quot;</code> | Asserts the input or form field has a value defined truthy value |
788
835
 
836
+ <a name="w_CARD_SCHEME" id="w_CARD_SCHEME" href="#user-content-w_CARD_SCHEME">&nbsp;</a>
837
+
838
+ ## CARD\_SCHEME
839
+ Card schemes the widget is able to resolve from a card number, and therefore the only values
840
+ `setAllowedCardSchemes` accepts. This is a separate vocabulary from SUPPORTED_CARD_TYPES, which drives the
841
+ card icons: it omits the icon-only variants `visa_white` / `eftpos_white`, and the `laser` / `maestro`
842
+ identifiers the widget can never resolve — allowing those would be configuration that can never match.
843
+
844
+ **Kind**: global constant
789
845
  <a name="w_TRIGGER" id="w_TRIGGER" href="#user-content-w_TRIGGER">&nbsp;</a>
790
846
 
791
847
  ## TRIGGER : <code>object</code>
@@ -958,6 +1014,12 @@ This example shows how you can use a lot of other methods to settings your form
958
1014
  <dt><a href="#user-content-psw_PAYMENT_SOURCE_TYPE">PAYMENT_SOURCE_TYPE</a> : <code>object</code></dt>
959
1015
  <dd><p>List of available payment source types</p>
960
1016
  </dd>
1017
+ <dt><a href="#user-content-psw_CARD_SCHEME">CARD_SCHEME</a></dt>
1018
+ <dd><p>Card schemes the widget is able to resolve from a card number, and therefore the only values
1019
+ <code>setAllowedCardSchemes</code> accepts. This is a separate vocabulary from SUPPORTED_CARD_TYPES, which drives the
1020
+ card icons: it omits the icon-only variants <code>visa_white</code> / <code>eftpos_white</code>, and the <code>laser</code> / <code>maestro</code>
1021
+ identifiers the widget can never resolve — allowing those would be configuration that can never match.</p>
1022
+ </dd>
961
1023
  </dl>
962
1024
 
963
1025
  ## Typedefs
@@ -1509,6 +1571,15 @@ List of available payment source types
1509
1571
  | BANK_ACCOUNT | <code>string</code> | <code>&quot;bank_account&quot;</code> |
1510
1572
  | CHECKOUT | <code>string</code> | <code>&quot;checkout&quot;</code> |
1511
1573
 
1574
+ <a name="psw_CARD_SCHEME" id="psw_CARD_SCHEME" href="#user-content-psw_CARD_SCHEME">&nbsp;</a>
1575
+
1576
+ ## CARD\_SCHEME
1577
+ Card schemes the widget is able to resolve from a card number, and therefore the only values
1578
+ `setAllowedCardSchemes` accepts. This is a separate vocabulary from SUPPORTED_CARD_TYPES, which drives the
1579
+ card icons: it omits the icon-only variants `visa_white` / `eftpos_white`, and the `laser` / `maestro`
1580
+ identifiers the widget can never resolve — allowing those would be configuration that can never match.
1581
+
1582
+ **Kind**: global constant
1512
1583
  <a name="psw_listener--PaymentSourceWidget" id="psw_listener--PaymentSourceWidget" href="#user-content-psw_listener--PaymentSourceWidget">&nbsp;</a>
1513
1584
 
1514
1585
  ## listener--PaymentSourceWidget : <code>function</code>
@@ -1670,6 +1741,12 @@ Then write only need 1 line of code in js to initialize widget
1670
1741
  <dl>
1671
1742
  <dt><a href="#user-content-cb_CHECKOUT_BUTTON_EVENT">CHECKOUT_BUTTON_EVENT</a> : <code>object</code></dt>
1672
1743
  <dd></dd>
1744
+ <dt><a href="#user-content-cb_CARD_SCHEME">CARD_SCHEME</a></dt>
1745
+ <dd><p>Card schemes the widget is able to resolve from a card number, and therefore the only values
1746
+ <code>setAllowedCardSchemes</code> accepts. This is a separate vocabulary from SUPPORTED_CARD_TYPES, which drives the
1747
+ card icons: it omits the icon-only variants <code>visa_white</code> / <code>eftpos_white</code>, and the <code>laser</code> / <code>maestro</code>
1748
+ identifiers the widget can never resolve — allowing those would be configuration that can never match.</p>
1749
+ </dd>
1673
1750
  </dl>
1674
1751
 
1675
1752
  ## Typedefs
@@ -2203,6 +2280,15 @@ button.turnOffBackdrop();
2203
2280
  | FINISH | <code>string</code> | <code>&quot;finish&quot;</code> |
2204
2281
  | CLOSE | <code>string</code> | <code>&quot;close&quot;</code> |
2205
2282
 
2283
+ <a name="cb_CARD_SCHEME" id="cb_CARD_SCHEME" href="#user-content-cb_CARD_SCHEME">&nbsp;</a>
2284
+
2285
+ ## CARD\_SCHEME
2286
+ Card schemes the widget is able to resolve from a card number, and therefore the only values
2287
+ `setAllowedCardSchemes` accepts. This is a separate vocabulary from SUPPORTED_CARD_TYPES, which drives the
2288
+ card icons: it omits the icon-only variants `visa_white` / `eftpos_white`, and the `laser` / `maestro`
2289
+ identifiers the widget can never resolve — allowing those would be configuration that can never match.
2290
+
2291
+ **Kind**: global constant
2206
2292
  <a name="cb_listener" id="cb_listener" href="#user-content-cb_listener">&nbsp;</a>
2207
2293
 
2208
2294
  ## listener : <code>function</code>
@@ -2459,7 +2545,13 @@ After you initialized the standalone 3ds charge via `v1/charges/standalone-3ds`
2459
2545
  console.log(data);
2460
2546
  });
2461
2547
  canvas3ds.on("chargeAuthChallenge", function (data) {
2462
- console.log(data);
2548
+ console.log(data); // keep your loader up — the challenge page is still loading
2549
+ });
2550
+ canvas3ds.on("chargeAuthChallengeLoaded", function (data) {
2551
+ console.log(data.reason); // 'load' | 'timeout' — hide your loader, the challenge is visible
2552
+ });
2553
+ canvas3ds.on("chargeAuthChallengeCompleted", function (data) {
2554
+ console.log(data.source); // 'poll' | 'callback' — shopper finished, cover the challenge with "Completing verification"
2463
2555
  });
2464
2556
  canvas3ds.on("chargeAuthDecoupled", function (data) {
2465
2557
  console.log(data.result.description);
@@ -2482,10 +2574,26 @@ After you initialized the standalone 3ds charge via `v1/charges/standalone-3ds`
2482
2574
  - A `data.status` of `rejected` will be received when the authorization was rejected.
2483
2575
  - A `data.status` of `invalid_event` will be received for unhandled situations.
2484
2576
  - The `chargeAuthChallenge` event is sent before starting a challenge flow (i.e. opening an IFrame for the customer to complete a challenge with ther bank). Once the end customer performs the challenge, the Canvas3ds will be able to identify the challenge result and will either produce a `chargeAuthSuccess` or `chargeAuthReject` event.
2577
+ - The `chargeAuthChallengeLoaded` event (SDK **v1.147.0+**) is sent once per challenge, after `chargeAuthChallenge`, when the challenge IFrame has finished loading the bank's page (its first `load` event) — this is the moment the customer can actually see the challenge. `data.reason` is `load` for a real load, or `timeout` when no load was observed within 2.5 seconds: the event is emitted anyway so you never hold a loading indicator forever (a `load` arriving later is simply ignored). Hide your loader on this event either way; `data.reason` is only informational (e.g. analytics). Not sent for decoupled challenges (no challenge IFrame).
2578
+ - The `chargeAuthChallengeCompleted` event (SDK **v1.147.0+**) is sent once the customer has finished the challenge (or approved a decoupled authentication): the bank has delivered the final result to the 3DS server and the Canvas3ds is now obtaining the outcome. Whatever the bank or the 3DS server render inside the IFrame from here on is plumbing, not UX — cover the IFrame with your own "Completing verification" state and hold it until the terminal event. `data.source` tells you how the SDK learned about it: `poll` (the 3DS server's result monitor — the usual case, it flips before the IFrame has even left the bank's page) or `callback` (the callback message carrying the outcome arrived first; the terminal event follows immediately) — handle both the same way. Sent at most once per authentication, always before `chargeAuthSuccess` / `chargeAuthReject` / `error` and never after them. A wrong OTP or a further interactive step (e.g. a second OTP screen) does **not** send it — no result has been delivered yet — so no grace timer or reveal fallback is needed on your side. Also sent for decoupled challenges.
2485
2579
  - The `chargeAuthDecoupled` event is sent when the flow is a decoupled challenge, alongside a `data.result.description` field that you must show to the customer, indicating the method the user must use to authenticate. For example this may happen by having the cardholder authenticating directly with their banking app through biometrics. Once the end customer does this, the Canvas3ds will be able to recognize the challenge result is ready and will either produce a `chargeAuthSuccess` or `chargeAuthReject` event.
2486
2580
  - The `error` event is sent if an unexpected issue with the client library occurs. In such scenarios, you should consider the autentication process as interrupted:
2487
2581
  - When getting this event, you will get on `data.error` the full error object.
2488
2582
 
2583
+ ### Recommended loading indicator pattern
2584
+
2585
+ > Requires SDK **v1.147.0 or later** (`chargeAuthChallengeLoaded` / `chargeAuthChallengeCompleted`). On older versions the same effect needs a `MutationObserver` on the container plus `load` listeners on the challenge IFrame — see the Standalone 3DS UX guide in the playground for that legacy approach.
2586
+
2587
+ The Canvas3ds renders nothing visible until a challenge is presented, and `chargeAuthChallenge` fires when the API responds — about 1–2 seconds before the bank's page actually paints inside the IFrame. Drive a single loading indicator from the events:
2588
+
2589
+ 1. Show the loader **before** you `POST /v1/charges/standalone-3ds` and keep it up through `canvas3ds.load()` (fingerprinting and processing are invisible).
2590
+ 2. Keep it up on `chargeAuthChallenge` — the challenge IFrame is being injected but is still blank.
2591
+ 3. Hide it on `chargeAuthChallengeLoaded` — the challenge is visible. `data.reason` tells you whether it was a real paint (`load`) or the 2.5 s safety fallback (`timeout`); either way, no further handling is needed.
2592
+ 4. Cover the IFrame with a "Completing verification" indicator on `chargeAuthChallengeCompleted` — the customer finished the challenge and the SDK is obtaining the outcome — and hold it until the terminal event. No grace timer or reveal fallback is needed: a wrong OTP or a second interactive step does not fire this event.
2593
+ 5. Finish on `chargeAuthSuccess` / `chargeAuthReject` / `error`.
2594
+
2595
+ Decoupled challenges (`chargeAuthDecoupled`) never emit `chargeAuthChallengeLoaded` (there is no challenge IFrame) but do emit `chargeAuthChallengeCompleted` once the customer approved out-of-band: show a dedicated waiting state with `data.result.description` until then, and "Completing verification" until the terminal event. Frictionless flows go straight from `load()` to the terminal event.
2596
+
2489
2597
  ### Events and Values
2490
2598
 
2491
2599
  | Event Value | Type | Description |
@@ -2493,6 +2601,8 @@ After you initialized the standalone 3ds charge via `v1/charges/standalone-3ds`
2493
2601
  | <code>chargeAuthSuccess</code> | <code>object</code> | Instance of [ChargeEventResponse](#cb_chargeEventResponse) |
2494
2602
  | <code>chargeAuthReject</code> | <code>object</code> | Instance of [ChargeEventResponse](#cb_chargeEventResponse) |
2495
2603
  | <code>chargeAuthChallenge</code> | <code>object</code> | Instance of [ChargeEventResponse](#cb_chargeEventResponse) |
2604
+ | <code>chargeAuthChallengeLoaded</code> | <code>object</code> | Instance of [ChallengeLoadedResponse](#cb_challengeLoadedResponse) |
2605
+ | <code>chargeAuthChallengeCompleted</code> | <code>object</code> | Instance of [ChallengeCompletedResponse](#cb_challengeCompletedResponse) |
2496
2606
  | <code>chargeAuthDecoupled</code> | <code>object</code> | Instance of [ChargeEventResponse](#cb_chargeEventResponse) |
2497
2607
  | <code>chargeAuthInfo</code> | <code>object</code> | Instance of [ChargeEventResponse](#cb_chargeEventResponse) |
2498
2608
  | <code>error</code> | <code>object</code> | Instance of [chargeError](#cb_chargeError) |
@@ -2510,6 +2620,24 @@ After you initialized the standalone 3ds charge via `v1/charges/standalone-3ds`
2510
2620
  | <code>info</code> | <code>string</code> | info field for `chargeAuthInfo` event |
2511
2621
  | <code>result.description</code> | <code>string</code> [Optional] | field that you must show to the customer, indicating the method the user must use to authenticate during the decoupled challenge flow. |
2512
2622
 
2623
+ <a name="cb_challengeLoadedResponse" id="cb_challengeLoadedResponse"></a>
2624
+
2625
+ ### ChallengeLoadedResponse
2626
+
2627
+ | Param | Type | Description |
2628
+ | ------------------------------- | ------------------------------ | -------------------------------------------------------------------------------------------------- |
2629
+ | <code>charge_3ds_id</code> | <code>string</code> | Universal unique transaction identifier to identify the transaction |
2630
+ | <code>reason</code> | <code>string</code> | `load` — the challenge IFrame fired its first load event; `timeout` — no load within 2.5 s, emitted so a loader is never held forever (a later load is ignored) |
2631
+
2632
+ <a name="cb_challengeCompletedResponse" id="cb_challengeCompletedResponse"></a>
2633
+
2634
+ ### ChallengeCompletedResponse
2635
+
2636
+ | Param | Type | Description |
2637
+ | ------------------------------- | ------------------------------ | -------------------------------------------------------------------------------------------------- |
2638
+ | <code>charge_3ds_id</code> | <code>string</code> | Universal unique transaction identifier to identify the transaction |
2639
+ | <code>source</code> | <code>string</code> | `poll` — the 3DS server's result monitor reported that the bank delivered the result (the usual case); `callback` — the callback message carrying the outcome arrived first (the terminal event follows immediately). Informational only — handle both the same way |
2640
+
2513
2641
  ### ChargeError
2514
2642
 
2515
2643
  <a name="cb_chargeError" id="cb_chargeError"></a>