Checkout SDK
Error handling
The onError callback receives a CheckoutApiError with everything you need to branch on failures.
The error object
CheckoutApiError is exported from the package and carries these fields:
| Property | Type | Description |
|---|---|---|
| status | number | HTTP status. 0 for a network or transport failure. |
| message | string | The server's message. |
| errors | Record<string, string[]> | Field-keyed validation messages, from a 422. |
| retryAfter | number | Seconds to back off, from a 429. |
Handling errors
onError
import {Coinfat, CheckoutApiError} from "@coinfat/checkout";coinfat.checkout({invoice: ulid,display: "inline",mount: "#pay",onError: (error) => {if (error instanceof CheckoutApiError && error.status === 429) {// rate limited — the widget is already backing off}}});
From the script-tag build, the same class hangs off the global as Coinfat.CheckoutApiError.