@paypercut/checkout-js 1.1.9 → 1.2.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.
- package/README.md +10 -0
- package/dist/index.cjs +14 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.mjs +14 -1
- package/dist/index.mjs.map +1 -1
- package/dist/paypercut-checkout.iife.min.js +1 -1
- package/dist/paypercut-checkout.iife.min.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -276,6 +276,7 @@ Subscribe to events using the `on()` method. You can use string event names or t
|
|
|
276
276
|
| Event | Enum | Description | Payload |
|
|
277
277
|
|-------|------|-------------|---------|
|
|
278
278
|
| `loaded` | `SdkEvent.Loaded` | Checkout iframe has finished loading | `void` |
|
|
279
|
+
| `processing` | `SdkEvent.Processing` | Payment processing has started inside the hosted checkout | `{ checkoutId: string }` |
|
|
279
280
|
| `success` | `SdkEvent.Success` | Payment completed successfully | `PaymentSuccessPayload` |
|
|
280
281
|
| `error` | `SdkEvent.Error` | Terminal failure (tokenize, confirm, or 3DS) | `ApiErrorPayload` |
|
|
281
282
|
| `expired` | `SdkEvent.Expired` | Checkout session expired | `void` |
|
|
@@ -295,6 +296,10 @@ checkout.on('loaded', () => {
|
|
|
295
296
|
console.log('Checkout loaded');
|
|
296
297
|
});
|
|
297
298
|
|
|
299
|
+
checkout.on('processing', ({ checkoutId }) => {
|
|
300
|
+
console.log('Payment processing started for checkout:', checkoutId);
|
|
301
|
+
});
|
|
302
|
+
|
|
298
303
|
checkout.on('success', (payload) => {
|
|
299
304
|
// PaymentSuccessPayload
|
|
300
305
|
console.log('Payment successful');
|
|
@@ -323,6 +328,10 @@ checkout.on(SdkEvent.Loaded, () => {
|
|
|
323
328
|
console.log('Checkout loaded');
|
|
324
329
|
});
|
|
325
330
|
|
|
331
|
+
checkout.on(SdkEvent.Processing, ({ checkoutId }) => {
|
|
332
|
+
console.log('Payment processing started for checkout:', checkoutId);
|
|
333
|
+
});
|
|
334
|
+
|
|
326
335
|
checkout.on(SdkEvent.Success, (payload) => {
|
|
327
336
|
console.log('Payment successful', payload.payment_method);
|
|
328
337
|
});
|
|
@@ -413,6 +422,7 @@ checkout.on('error', (err) => {
|
|
|
413
422
|
### Notes
|
|
414
423
|
|
|
415
424
|
- `error`: the SDK forwards a normalized `ApiErrorPayload` when provided by Hosted Checkout.
|
|
425
|
+
- `processing`: non-terminal event. Use it to disable close buttons or show "do not close" messaging, then clear that UI on `success`, `error`, `cancel`, or `expired`.
|
|
416
426
|
- `threeds_error`: forwards `payload.error` when available; otherwise the raw message data.
|
|
417
427
|
- `threeds_*` non-error events: payload is forwarded as-is from Hosted Checkout (shape may evolve).
|
|
418
428
|
|
package/dist/index.cjs
CHANGED
|
@@ -91,7 +91,7 @@ class Emitter {
|
|
|
91
91
|
* Production configuration (for merchants)
|
|
92
92
|
*/
|
|
93
93
|
const productionConfig = {
|
|
94
|
-
version: "1.
|
|
94
|
+
version: "1.2.0",
|
|
95
95
|
defaultCheckoutOrigin: 'https://buy.paypercut.io',
|
|
96
96
|
defaultApiOrigin: 'https://api.paypercut.io',
|
|
97
97
|
defaultVaultApiUrl: 'https://api.basistheory.com',
|
|
@@ -293,6 +293,7 @@ function validateUIMode(mode) {
|
|
|
293
293
|
exports.SdkEvent = void 0;
|
|
294
294
|
(function (SdkEvent) {
|
|
295
295
|
SdkEvent["Loaded"] = "loaded";
|
|
296
|
+
SdkEvent["Processing"] = "processing";
|
|
296
297
|
SdkEvent["Success"] = "success";
|
|
297
298
|
SdkEvent["Error"] = "error";
|
|
298
299
|
SdkEvent["Expired"] = "expired";
|
|
@@ -301,6 +302,7 @@ exports.SdkEvent = void 0;
|
|
|
301
302
|
SdkEvent["ThreeDSError"] = "threeds_error";
|
|
302
303
|
SdkEvent["ThreeDSCanceled"] = "threeds_canceled";
|
|
303
304
|
SdkEvent["ThreeDSStarted"] = "threeds_started";
|
|
305
|
+
SdkEvent["Cancel"] = "cancel";
|
|
304
306
|
SdkEvent["FormValidation"] = "form_validation";
|
|
305
307
|
})(exports.SdkEvent || (exports.SdkEvent = {}));
|
|
306
308
|
|
|
@@ -1909,6 +1911,11 @@ class CheckoutImpl {
|
|
|
1909
1911
|
case 'CHECKOUT_LOADED':
|
|
1910
1912
|
this.emitter.emit(exports.SdkEvent.Loaded);
|
|
1911
1913
|
break;
|
|
1914
|
+
case 'CHECKOUT_PROCESSING':
|
|
1915
|
+
this.emitter.emit(exports.SdkEvent.Processing, {
|
|
1916
|
+
checkoutId: data.checkoutId,
|
|
1917
|
+
});
|
|
1918
|
+
break;
|
|
1912
1919
|
case 'CHECKOUT_SUCCESS':
|
|
1913
1920
|
const { payment_method = {}, payment = null } = data;
|
|
1914
1921
|
this.emitter.emit(exports.SdkEvent.Success, { payment_method, payment });
|
|
@@ -1917,6 +1924,12 @@ class CheckoutImpl {
|
|
|
1917
1924
|
// Forward error payload (if provided) to SDK consumers
|
|
1918
1925
|
this.emitter.emit(exports.SdkEvent.Error, (data && data.error) ?? data);
|
|
1919
1926
|
break;
|
|
1927
|
+
case 'CHECKOUT_CANCEL':
|
|
1928
|
+
this.emitter.emit(exports.SdkEvent.Cancel, {
|
|
1929
|
+
checkoutId: data.checkoutId,
|
|
1930
|
+
wallet: data.wallet,
|
|
1931
|
+
});
|
|
1932
|
+
break;
|
|
1920
1933
|
case 'CHECKOUT_EXPIRED':
|
|
1921
1934
|
this.emitter.emit(exports.SdkEvent.Expired);
|
|
1922
1935
|
break;
|