- Checkout
- Features
Kustom Checkout in a mobile app
How the Kustom Mobile SDK runs Kustom Checkout in iOS, Android and React Native apps — native or hybrid, the return URL, events and errors, Klarna migration.
The Kustom Mobile SDK renders Kustom Checkout inside a native app. It works the same way as
the web integration: your server creates the order and returns its html_snippet, you hand
that snippet to a checkout view, and the view tells you what the customer did through an
event handler. This page covers what’s common to every platform. The platform pages walk
through the integration step by step.
Choose your platform
Section titled “Choose your platform”iOS
Swift, with the SDK from Swift Package Manager or CocoaPods.
Android
Kotlin, with the view declared in XML or built in code.
React Native
A KustomCheckoutView component with props for events and errors.
How it works
Section titled “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 and returns its
html_snippet, and have the app fetch from there. The platform pages call it <YOUR-URL>.
There are two ways to integrate, depending on who owns the screen.
Native. The app owns the screen, and the SDK renders the checkout in its own view. This is what the platform pages build, and what most apps want:
- Fetch a Kustom Checkout
html_snippetfrom your server. - Set the snippet on a
KustomCheckoutViewand display it. - Handle the events the view dispatches.
Hybrid. The app already renders your checkout page in a web view. The SDK attaches to that web view and reacts to the Kustom content inside the page rather than rendering its own:
- Initialize the SDK with your web view.
- Present your web page as usual.
- Notify the SDK about the web view’s navigation events.
- Handle the events the SDK dispatches.
The return URL
Section titled “The return URL”Some payment methods hand the customer to a third-party app, such as a bank or a wallet, to
authorize the purchase. The return URL is what brings them back: a custom scheme your app
is registered for, such as myapp://. Every platform requires one, and the value you pass to
the SDK must be a scheme your app actually handles.
You don’t need a special handler for when the app reopens. The third-party app sends the customer back to your app by itself.
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
Section titled “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. |
The actions you act on:
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. |
An error with isFatal set means the checkout can’t continue. Send the customer somewhere
else rather than leaving them on a dead view.
Migrating from the Klarna Mobile SDK
Section titled “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 |
Migrate straight to KustomMobileSDK even if you’re several minor versions behind those. There’s no benefit in stepping through the Klarna versions first. The migration itself is two changes:
- Swap the dependency for KustomMobileSDK, as shown on your platform page.
- Rename
KlarnaCheckoutViewtoKustomCheckoutViewwherever you construct or reference it. The event and error types follow the same rename.
Related
Section titled “Related”- iOS, Android and React Native integration guides
- Confirmation and push — what your server must do once
completefires - Integration models — the SDK renders the same checkout as the web snippet
- Test data — Playground customers and cards to pay with
This page is also available as Markdown — append .md to its URL — and is indexed in llms.txt.