This guide will show you how to use Klarna Mobile SDK to implement Express Checkout in your React Native mobile application, providing a fast and simple shopping experience for your users.
Please review this brief guide first to ensure you are prepared to offer this integration to your customers.
You have allowlisted the domain of the page/app on which Express Checkout will be integrated. Without this, customers will see a "We couldn't load the next screen" error.
3.2.
You have generated a client identifier (for client-side sessions) or can generate client tokens from your backend (for server-side sessions).
4.
Your project meets the minimum platform requirements:
For a Mobile SDK integration your Payment Server and Mobile App must work together to offer one-click checkout experience:
sequenceDiagram
participant Consumer
participant Merchant App
participant Mobile SDK
participant Merchant Server
participant Klarna API
Consumer->>Merchant App: Navigate to checkout, shopping cart, product or wishlist page
Merchant App->>Mobile SDK: Create Express Checkout Button with session information
Merchant App->>Merchant App: Display the Express Checkout Button
Consumer->>Mobile SDK: Click the Express Checkout Button
Note over Mobile SDK: Consumer completes to purchase flow.
Mobile SDK-->>Merchant App: Provide authorization token (valid for 60 minutes)
Merchant App->>Merchant Server: Sends the authorization token for creating order
Merchant Server->>Klarna API: Create Order POST (setup/payments/v1/authorizations/{authorizationToken}/order)
Klarna API-->>Merchant Server: Provide order_id and redirect_url
Merchant Server-->>Merchant App: Provide order details
Merchant App->>Consumer: Redirected to order confirmation screen
React Native 0.59+: Third-party Gradle repositories may not be automatically recognized. The Maven entry above is required — without it, the Android build will fail to resolve Klarna SDK dependencies.
Klarna purchase flows may require authorization in external apps (e.g. bank apps) or hand over to the Klarna app. Set up a custom URL scheme so the customer can return to your app seamlessly.
1.
In Xcode, go to your target's Info tab and add a URL Type with your custom scheme (e.g. myApp).
2.
Pass the scheme as returnUrl including :// (e.g. "myApp://" or "myApp://klarna-redirect").
Create an instance of the KlarnaExpressCheckoutButton when your cart page or product detail page is loaded. This ensures that the button is readily available for user interaction. Depending on your integration setup, you can create and initiate the Express Checkout button using either a Client-Side Session or a Server-Side Session:
Client-Side session: Use this method if you prefer to set a partner client ID from the Merchant Portal. This approach is typically used when the session management is handled entirely on the client side. You would need to provide the order details in this approach.
Server-Side session: Choose this method if you have a client token generated by the backend for the server-side session. This is suitable when you want to manage sensitive session data on the server. You do not need to provide the order details with this approach.
Once the button is created, add it to your screen. This involves adding the button to the appropriate view hierarchy in your application's user interface:
Session type discrimination: The component detects the session type from the shape of the sessionOptions object. If it contains a clientId property, a client-side session is used. If it contains a clientToken property, a server-side session is used.
When the customer clicks the Express Checkout button and completes the Klarna purchase flow, the onAuthorized callback fires with an authorization response. Extract the authorizationToken and send it to your backend to create the order.
TYPESCRIPT
1
2
3
4
5
6
7
8
9
10
<KlarnaExpressCheckoutView
// ... session and style props ...
onAuthorized={(response) => {
if (response.approved && response.authorizationToken) {
// Authorization successful — send token to your backendcreateOrder(response.authorizationToken, response.collectedShippingAddress);
}
if (response.finalizedRequired) {
// Finalization needed (only when autoFinalize is false)
Whether the payment is still available for authorization.
finalizedRequired
boolean
Whether the session requires finalization (only when autoFinalize is false).
authorizationToken
string
The authorization token to use when creating the order. Valid for 60 minutes.
clientToken
string
Client token for the session, used for finalization if needed.
sessionId
string
The Klarna Payments session ID.
collectedShippingAddress
string
JSON string with the shipping address collected during the session (if collectShippingAddress was true).
merchantReference1
string
Merchant reference provided in session creation.
merchantReference2
string
Additional merchant reference provided in session creation.
60-minute expiry: The authorizationToken is valid for 60 minutes. Create the order on your backend immediately after receiving the authorization. If the token expires, request a new authorization.
If the session needs to be finalized, you’ll need to perform this last step to get an authorization token from your checkout confirmation screen. This can be done via KlarnaPaymentView, using the clientToken from KlarnaExpressCheckoutButtonAuthorizationResponse to initialize the view and calling finalize method of that view.
This is only required of autoFinalize is set to false in session options.
Once you have the authorization token from the mobile app, create the order on your server using the Klarna Payments API. If you collected the shipping address, ensure it matches in the order creation request.
Transparent background with a border. Useful on all background colours.
Sizing: The recommended button height is 48dp (minimum 40dp). The component defaults to 48dp if the native button hasn't reported its intrinsic size yet. Make the button the same width and height as other payment buttons in your checkout layout.
Provide an onError callback to handle errors from the Express Checkout button. The callback receives a KlarnaMobileSDKError object:
TYPESCRIPT
1
2
3
4
5
6
interfaceKlarnaMobileSDKError {
readonly isFatal: boolean; // If fatal, the button should not be shown furtherreadonly message: string; // Human-readable error descriptionreadonly name: string; // Error type identifier
}