# Token-based initialisation

Initialise the SDK with an order token to access card payment methods.

Token-based initialisation creates a `RevolutCheckoutInstance` for a specific order. Use this method when you create orders on your server before showing the checkout, and you need card field or card popup functionality.

**Payment methods available:**

| Payment method | Reference                                                               | Integration guide                                                                  |
| -------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| Card field     | [SDK reference](/docs/sdks/merchant-web-sdk/payment-methods/card-field) | [Guide](/docs/guides/merchant/accept-payments/online-payments/card-payments/web/card-field) |
| Card pop-up    | [SDK reference](/docs/sdks/merchant-web-sdk/payment-methods/pop-up)     | [Guide](/docs/guides/merchant/accept-payments/online-payments/card-payments/web/pop-up)     |

## Type signature

```typescript
function RevolutCheckout(
  token: string,
  mode?: 'prod' | 'sandbox',
): Promise<RevolutCheckoutInstance>
```

## Parameters

| Parameter | Description                                                                        | Type                  | Required |
| --------- | ---------------------------------------------------------------------------------- | --------------------- | -------- |
| `token`   | Order `token` from the [Create an order](/docs/api/merchant#create-order) response | `string`              | Yes      |
| `mode`    | API environment. Default: `'prod'`                                                 | `'prod' \| 'sandbox'` | No       |

:::tip
The `mode` parameter must match the environment used to create the order.
:::

## Returns

Returns a `Promise<RevolutCheckoutInstance>` with the following methods:

```typescript
interface RevolutCheckoutInstance {
  createCardField: (options?: CardFieldOptions) => RevolutCheckoutCardField
  payWithPopup: (options?: PopupOptions) => RevolutCheckoutInstance
  setDefaultLocale: (locale: Locale) => void
  destroy: () => void
}
```

- **[`createCardField`](/docs/sdks/merchant-web-sdk/payment-methods/card-field)** - Create an embedded card input field
- **[`payWithPopup`](/docs/sdks/merchant-web-sdk/payment-methods/pop-up)** - Show a full-screen payment pop-up
- **[`setDefaultLocale`](/docs/sdks/merchant-web-sdk/types/locale#with-token-based-initialisation)** - Change widget language dynamically
- **`destroy`** - Manually destroy the instance

## Example

```typescript
import RevolutCheckout from '@revolut/checkout'

const instance = await RevolutCheckout('order_token_here', 'prod')
```