Skip to main content
All failures thrown by the SDK are instances of EscrowCheckoutError, which extends the native Error with a machine-readable code.
class EscrowCheckoutError extends Error {
  code: EscrowCheckoutErrorCode;
  status?: number;   // HTTP status, when the error came from a network call
  details?: unknown; // extra context, when available
}

Handling errors

import { pay, EscrowCheckoutError } from 'payluk-escrow-inline-checkout';

try {
  await pay({
    paymentToken: 'PY_8AB12C9D3045',
    reference: 'order_2026_0001',
    redirectUrl: 'https://yourapp.com/checkout/complete',
  });
} catch (err) {
  if (err instanceof EscrowCheckoutError) {
    switch (err.code) {
      case 'NOT_INITIALIZED':
        // call initEscrowCheckout() first
        break;
      case 'INVALID_INPUT':
        // fix the pay() arguments
        break;
      default:
        console.error(err.code, err.status, err.details);
    }
  }
}
When using the React hook, the same error is surfaced on the hook’s error field instead of being thrown — no try/catch needed.

Error codes

CodeMeaning
NOT_INITIALIZEDpay() was called before initEscrowCheckout().
BROWSER_ONLYCalled outside a browser (e.g. during SSR).
INVALID_INPUTA required pay() argument is missing or malformed.
WIDGET_LOADThe widget script failed to load.
NETWORKA network request failed.
SESSION_CREATEThe checkout session could not be created.
SESSION_RESPONSEThe session-create response was missing or unexpected.
NOT_INITIALIZED, BROWSER_ONLY and INVALID_INPUT are developer/integration errors — fix them in code. WIDGET_LOAD, NETWORK, SESSION_CREATE and SESSION_RESPONSE are runtime conditions worth retrying or reporting to the buyer.