Skip to content

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.

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:

  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 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:

  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.

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.

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:

FieldTypeDescription
actionstringThe event’s name.
paramsmap of string to anyThe event’s parameters.

The actions you act on:

actionparamsWhat it means
completeuriThe customer has paid. uri is the confirmation URL to load next.
externaluriThe customer chose an external payment method. uri is where to send them.
validation_errorerror_type, error_textA validation error you’ve opted to handle yourself.

An error (KustomMobileSDKError) carries:

FieldTypeDescription
namestringThe error’s name.
messagestringA description of the error.
isFatalbooleanWhether the error stops the checkout.
sessionIdstringThe 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.

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

PlatformKlarna Mobile SDK version it was migrated from
Android2.6.29
iOS2.7.0
React Native2.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:

  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.

This page is also available as Markdown — append .md to its URL — and is indexed in llms.txt.