---
updatedAt: 2026-10-19T09:11:40.000Z
agentTools:
  projectIndex: https://developer.pay.nl/llms.txt
---

# SDK API Reference

This page provides a concise reference for the PayParts SDK (TypeScript) public API. It covers the newer `init() -> prepare() -> bind()` flow. See [Add components to your frontend](add-components-to-your-frontend) for guidance, and [Handle events](handle-events) for the event model.

## PayPartsSDK

The global object exposed as `window.PayPartsSDK` (also the named export `PayParts`).

| Method    | Signature                                       | Description                                                                                   |
| :-------- | :---------------------------------------------- | :-------------------------------------------------------------------------------------------- |
| `init`    | `(opt: InitOptions) => Promise<Checkout>`       | Initializes the SDK using your `sessionToken` and returns a `Checkout`.                       |
| `prepare` | `(methodOrSection: string) => PaymentComponent` | Returns a `PaymentComponent` for the given method/section. Throws unless called after `init`. |

<Callout icon="📘" theme="info">
  ### Pass `customer` to `init()` — attaches payer data to `/pay`

  Include the payer's details in the `init()` options so the SDK can attach them to the `POST /v1/session/{id}/pay` request:

  ```typescript
  const checkout = await window.PayPartsSDK.init({
    sessionToken,
    apiUrl,
    country: 'NL',
    language: 'nl',
    customer: {
      email: cart.email,
      firstName: cart.shipping_address?.first_name,
      lastName: cart.shipping_address?.last_name,
      phone: cart.shipping_address?.phone,
      shippingAddress: { /* street, streetNumber, streetNumberExtension, zipCode, city, country */ },
      billingAddress:  { /* ... */ },
    },
  });
  ```

  `shippingAddress` / `billingAddress` are sent as the order's `deliveryAddress` / `invoiceAddress` in the `/pay` body — but note that body fields are **optional**. PayParts builds the actual order (products, addresses, customer) from the data stored on the **session** at `POST /v1/session/start`. For order-based methods (e.g. iDEAL) the session must be created with the full `order` + `customer`, otherwise `/pay` can fail with `422 PAY-2880 requiredDataMissing`.
</Callout>

<br />

## Checkout

The object returned by `PayPartsSDK.init()`.

| Member          | Signature                                                           | Description                                                                      |
| :-------------- | :------------------------------------------------------------------ | :------------------------------------------------------------------------------- |
| `events`        | `MountEventHandlers`                                                | Attach event handlers to control the payment flow.                               |
| `prepare`       | `(methodOrSection: string) => PaymentComponent`                     | Prepare a component (e.g. `'card-payments'`, `'checkout-buttons'`, `'methods'`). |
| `updateConfig`  | `(config: Partial<CheckoutConfig>) => void`                         | Update the SDK configuration after initialization.                               |
| `getConfig`     | `() => Readonly<Required<CheckoutConfig>>`                          | Get the current configuration.                                                   |
| `updateSession` | `(request: UpdateSessionRequest) => Promise<UpdateSessionResponse>` | Update the session amount/order. **Zero only (not yet in Production).**          |

<br />

<Callout icon="🏷️" theme="default">
  ### Section titles (`showSectionTitles`, default `true`)

  The SDK renders a small section heading above the **payment methods** list, **express buttons**, and the **credit‑card** form (e.g. "Local payment methods", "Express checkout"). These are controlled by the `showSectionTitles` config option, which **defaults to&#x20;**`true`. The heading text itself is translatable — see [Translations](translations).

  ```typescript
  checkout.updateConfig({ showSectionTitles: false }); // hide the section headings
  ```
</Callout>

<br />

## PaymentComponent

Returned by `checkout.prepare(methodOrSection)`.

| Method          | Signature                                          | Description                                                                                                             |
| :-------------- | :------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------- |
| `bind`          | `(target: string \| HTMLElement) => void`          | Mounts the component into a target element or selector.                                                                 |
| `unmount`       | `() => void`                                       | Unmounts the component from the page.                                                                                   |
| `updateContext` | `(context: Partial<PaymentMethodContext>) => void` | Updates the component's context.                                                                                        |
| `isReady`       | `() => boolean`                                    | Whether the component is ready to submit (all fields valid).                                                            |
| `refresh`       | `() => Promise<void>`                              | Refreshes the component data.                                                                                           |
| `reset`         | `() => Promise<void>`                              | Clears the component's resettable state and re-mounts it. No-op for components without state to reset.                  |
| `submit`        | `() => Promise<SubmitResult>`                      | Triggers payment programmatically. Useful when you hide the built-in pay button (`creditCardOptions.hideSubmitButton`). |

<br />

### `reset()` and Click to Pay recognition

When called on a card component with Click to Pay enabled, `reset()` provides a **new-user** experience. Click to Pay remembers a returning shopper via a recognition binding held by the Visa / Mastercard SRC network (server-side) — not an email. `reset()`:

1. Calls `unbindAppInstance` against the SRC network with the stored `idToken`, removing the device/app-instance recognition binding.
2. Clears the locally stored recognition tokens, then re-mounts the component.
3. On the next mount the shopper is treated as unrecognized and prompted for their identity instead of having their cards silently loaded.

If Click to Pay is not enabled on the component, `reset()` still clears any stale stored recognition tokens so a later mount starts fresh.

<br />

## SubmitResult

Returned by `PaymentComponent.submit()`.

```typescript
type SubmitResult =
  | { status: 'success'; orderId: string; returnUrl: string }
  | { status: 'validation_failed' }
  | { status: 'error'; message: string; errorTag?: string }
  | { status: 'not_ready' };
```

<br />

## Async submit (`onSubmit`)

The `onSubmit` handler supports **asynchronous** logic. When the user submits payment, the SDK waits (up to `onSubmitTimeout`, default `30000` ms) for the handler to call `event.resolve()` before continuing with the payment.

This lets you run other async work first — for example creating an order on a different platform/ERP, freezing stock, or validating inventory — and only continue once it has completed:

```typescript
onSubmit: async (event) => {
  // Create the order on another platform first...
  await myPlatformApi.createOrder({ items, customer });
  // ...and only then continue with the PayParts payment
  event.resolve();
}
```

* Call `event.resolve()` to continue with the payment.
* Call `event.reject(error)` to cancel/abort the payment (e.g. if the external order creation fails).
* See [Handle events](handle-events) for the full `onSubmit` example.

<br />

## The pay call (`POST /v1/session/{id}/pay`)

When the payer confirms a redirect/order-based method (such as **iDEAL**), the SDK calls:

```
POST /v1/session/{sessionId}/pay
Content-Type: application/json
```

with a body such as:

```json
{
  "methodId": 10,
  "customer": {
    "email": "john@example.com",
    "firstName": "John",
    "lastName": "Doe",
    "phone": "+31000000000"
  }
}
```

Important details:

* `amount`**&#x20;is NOT required** in `/pay` — it already exists on the session.
* `methodId`**&#x20;is required**. **iDEAL (**`10`**) is a redirect method and needs no issuer**; only bank-selection methods (MetjeBank `5358`, PayByBank `2970`) require one via `input.issuerId` / `subMethodId`.
* `customer`**&#x20;and&#x20;**`order`**&#x20;in the body are optional** — the SDK sends them if a `customer` was passed to `init()`, but PayParts builds the actual order from the **session** data.
* **The order line items come from the session, not&#x20;**`/pay`: the products/amount are created server-side from the data you supplied in `POST /v1/session/start`. This is why the session must contain the full `order` + `customer` for order-based methods (see [Create a session from your backend](create-a-session-from-your-backend)).

### Example response (HTTP 200)

```json
{
  "request": { "result": "1" },
  "data": {
    "orderId": "50xxxxxxxxxxxxxx",
    "returnUrl": "https://checkout-zero.pay.nl/to/payment/..."
  }
}
```

The `data.returnUrl` is where the payer should be sent (or directly navigated to) to complete their payment / bank selection. Use it to redirect the shopper from your checkout.

**Failures worth knowing**

* `422` — validation problems (e.g. a zero-priced `price.value: 0` line, or a `reference` mismatch).
* `422 PAY-2880 requiredDataMissing` — the **session** is missing required order/customer data. Add the full `order` and `customer` when creating the session.
* `422 PAY-1422 reference: Deze waarde is niet geldig.` — the session's `reference` contains characters Pay rejects server-side (commonly `_`, e.g. a `cart_...` identifier). Strip them or use a plain order number. See the `reference` format note in [Create a session from your backend](create-a-session-from-your-backend).
* `410 Gone` — the session has expired / is no longer available. Create a fresh session or set a longer `expire`.

<Callout icon="💱" theme="default">
  **Units (cents):** all monetary values (`amount.value`, and every order `products[].price.value`) are in the **smallest currency unit** (e.g. cents) — **€0.01 =&#x20;**`1` (one cent, minimum `value`). Never send decimal euros.
</Callout>

<br />

## Events

Event handlers are attached via `checkout.events`. Full list and event payloads: [Handle events](handle-events).