Enable Klarna Payment messaging on your online store with Klarna's Mobile SDK and boost transparency and conversion. This includes our pre-qualification feature, which allows customers to check their eligibility for Klarna financing before completing a payment request. This reduces friction and increases confidence, as customers know their options upfront.
Adding On-Site Messaging to your native app is a straightforward process. At a high level, to achieve this tailored experience for your users, you will need to follow these steps:
Request access to On-Site Messaging.
Install the react-native-klarna-inapp-sdk npm package.
Add the KlarnaOSMView component to your screen and provide the required props.
sequenceDiagram
participant C as Customer
participant P as Partner
participant K as Klarna
participant AP as Acquiring Partner
P->>K: Initialize Klarna SDK
P->>K: Get OSM placement
K->>P: Return messaging/prequalification content
P->>C: Display messaging/prequalification content
alt Prequalification flow - Approved
C->>P: Clicks to check purchase power
P->>K: Create session ID & request interoperability token
K->>P: Return session ID & interoperability token
K->>C: Start prequalification journey
C->>K: Completes prequalification
K->>P: Send approval event & updated messaging
K->>C: Update placement to show approval
alt Partner builds checkout form
K->>P: Prequalification state preserved
else Checkout form via Acquiring Partner
P->>K: Fetch interoperability token
P->>AP: Share interoperability token
end
end
The Android integration depends on the native Klarna Mobile SDK hosted on Klarna's Maven repository. Add the repository to your app's android/build.gradle:
Auto-sizing: The KlarnaOSMView automatically adjusts its height based on the rendered content. You do not need to set a fixed height — the component emits an internal onResized event and updates its layout.
Provide an onError callback to handle errors from the OSM view. The callback receives a KlarnaMobileSDKError object:
JAVASCRIPT
1
2
3
4
5
6
interfaceKlarnaMobileSDKError {
readonly isFatal: boolean; // Whether the error is unrecoverable
readonly message: string; // Human-readable error description
readonly name: string; // Error type identifier
}
Sample code
HTML
1
2
3
4
5
6
7
8
9
10
<KlarnaOSMView
clientId="your-client-id"
placementKey="credit-promotion-badge"
locale="en-US"
purchaseAmount="12000"
environment={KlarnaEnvironment.Production}
region={KlarnaRegion.NA}
onError={(error) => {
if (error.isFatal) {
// Fatal error — OSM cannot render
Graceful degradation: When an error occurs, the KlarnaOSMView collapses its height to 0, effectively hiding itself. This means a failed OSM placement won't break your layout — but you should still log errors for monitoring.
Use KlarnaEnvironment.Playground during development and testing. The playground environment returns simulated messaging content without requiring a live merchant account.