Skip to main content

1. Initialize

Call initEscrowCheckout once, as early as possible (e.g. at your app’s entry point). This registers your publishable key and prepares the widget script.
import { initEscrowCheckout } from 'payluk-escrow-inline-checkout';

initEscrowCheckout({
  publicKey: '<YOUR_PUBLISHABLE_KEY>',
});
initEscrowCheckout(config: InitConfig) accepts:
OptionTypeRequiredDescription
publicKeystringYesYour publishable key.
scriptUrlOverridestringNoOverride the widget script URL (advanced/self-hosted).
globalNamestringNoWindow global the widget attaches to. Defaults to EscrowCheckout.
crossOrigin'' | 'anonymous' | 'use-credentials'Nocrossorigin attribute for the injected script. Defaults to anonymous.

2. Collect payment

pay() opens the checkout widget for one or more payment tokens. It returns a Promise<void> that resolves once the session has been created and the widget launched.
import { pay } from 'payluk-escrow-inline-checkout';

await pay({
  paymentToken: 'PY_8AB12C9D3045',
  reference: 'order_2026_0001',
  redirectUrl: 'https://yourapp.com/checkout/complete',
  brand: 'Acme Store',
  logoUrl: 'https://yourapp.com/logo.png',
  callback: (result) => {
    console.log('Payment result', result);
  },
  onClose: () => {
    console.log('Checkout closed');
  },
});

pay() parameters

ParameterTypeRequiredDescription
paymentTokenstring | string[]YesOne token, or an array to fund multiple escrows in one session.
referencestringYesYour unique reference for this checkout.
redirectUrlstringYesWhere the buyer is redirected after completion.
logoUrlstringNoLogo shown in the widget.
brandstringNoBrand/business name shown in the widget.
customerIdstringNoThe merchant customer the payment acts on behalf of.
extraRecord<string, unknown>NoArbitrary key/values forwarded to the widget.
callback(result: any) => voidNoInvoked with the payment result.
onClose() => voidNoInvoked when the buyer closes the widget.
pay() must run in a browser. Calling it during server-side rendering throws an EscrowCheckoutError with code BROWSER_ONLY. Calling it before initEscrowCheckout() throws NOT_INITIALIZED.

Multi-escrow checkout

Pass an array of tokens to settle several escrows in a single session:
await pay({
  paymentToken: ['PY_8AB12C9D3045', 'PY_77F0A1B2C3D4'],
  reference: 'cart_2026_0042',
  redirectUrl: 'https://yourapp.com/checkout/complete',
});
All tokens in a multi-escrow checkout must belong to the same merchant and each escrow must still be in PENDING status (not yet funded).

TypeScript

The SDK is written in TypeScript and ships its own types — no @types package needed. Import the types directly when you need them:
import {
  initEscrowCheckout,
  pay,
  type InitConfig,
  type PayInput,
} from 'payluk-escrow-inline-checkout';
See the full SDK reference for every exported type.