# Kustom Checkout in a mobile app

Embed Kustom Checkout in iOS, Android or React Native apps with the Mobile SDK. Set up the return URL, handle events and errors or migrate from Klarna.

The Kustom Mobile SDK embeds Checkout in iOS, Android and React Native apps. Your server
creates the order, and the SDK renders its `html_snippet` and reports checkout events.
Choose a platform guide for setup; shared behavior is documented below.

## Choose your platform

  iOS

Swift, with the SDK from Swift Package Manager or CocoaPods.

[iOS integration](/checkout/mobile-sdk/ios/)

  Android

Kotlin, with the view declared in XML or built in code.

[Android integration](/checkout/mobile-sdk/android/)

  React Native

A KustomCheckoutView component with props for events and errors.

[React Native integration](/checkout/mobile-sdk/react-native/)

## How it works

**Your backend, not the app, creates the order.** The SDK never holds your API credentials.
Expose an endpoint that [creates the order](/checkout/integrate/create-order/) and returns its
`html_snippet`, and have the app fetch from there. The platform pages call it `<YOUR-URL>`.

Choose a native checkout view or attach the SDK to an existing web view.

**Native.** The SDK renders Checkout in its own view. The platform guides use this approach:

1. Fetch a Kustom Checkout `html_snippet` from your server.
2. Set the snippet on a `KustomCheckoutView` and display it.
3. Handle the events the view dispatches.

**Hybrid.** The SDK attaches to a web view that already displays your checkout page:

1. Initialize the SDK with your web view.
2. Present your web page as usual.
3. Notify the SDK about the web view's navigation events.
4. Handle the events the SDK dispatches.

## The return URL

Some payment methods open a bank or wallet app for authorization. Set the **return URL**
to a custom scheme your app handles, such as `myapp://`, so the customer can return.
Every platform requires it.

The third-party app handles the return; you don't need a separate handler when your app
reopens.

**BankID may not return the customer automatically.** After authenticating with BankID, the
customer might have to switch back to your app themselves.

## Events and errors

The SDK reports through two callbacks: one for product events and one for errors. The names
are the same on every platform.

A **product event** (`KustomProductEvent`) carries:

| Field | Type | Description |
| --- | --- | --- |
| `action` | string | The event's name. |
| `params` | map of string to any | The event's parameters. |

Product actions:

| `action` | `params` | What it means |
| --- | --- | --- |
| `complete` | `uri` | The customer has paid. `uri` is the confirmation URL to load next. |
| `external` | `uri` | The customer chose an external payment method. `uri` is where to send them. |
| `validation_error` | `error_type`, `error_text` | A validation error you've opted to handle yourself. |

An **error** (`KustomMobileSDKError`) carries:

| Field | Type | Description |
| --- | --- | --- |
| `name` | string | The error's name. |
| `message` | string | A description of the error. |
| `isFatal` | boolean | Whether the error stops the checkout. |
| `sessionId` | string | The session the error occurred in. |

**If `isFatal` is set, checkout can't continue.** Navigate away from the checkout view.

## Migrating from the Klarna Mobile SDK

KustomMobileSDK is built on the Klarna Mobile SDK and has feature parity with it for Kustom
Checkout. It was branched from these versions:

| Platform | Klarna Mobile SDK version it was migrated from |
|---|---|
| Android | 2.6.29 |
| iOS | 2.7.0 |
| React Native | 2.4.10 |

You can migrate directly from older Klarna versions without upgrading through the versions
listed above:

1. Swap the dependency for KustomMobileSDK, as shown on your platform page.
2. Rename `KlarnaCheckoutView` to `KustomCheckoutView` wherever you construct or reference it.
   The event and error types follow the same rename.

## Related

- [iOS](/checkout/mobile-sdk/ios/), [Android](/checkout/mobile-sdk/android/) and [React Native](/checkout/mobile-sdk/react-native/) integration guides
- [Confirmation and push](/checkout/integrate/confirmation-and-push/) — what your server must do once `complete` fires
- [Integration models](/checkout/#integration-models) — the SDK renders the same checkout as the web snippet
- [Test data](/basics/test-data/) — Playground customers and cards to pay with
