When the recommended integration approach of Klarna Mobile SDK is not possible, the guide below will guide you through how to integrate your web checkout in your mobile app without the Mobile SDK.
![]() | ![]() | ![]() |
Your checkout screen when Klarna is selected as payment method. | Hosted Payment Page flow starts when customer confirms to Continue with Klarna. | Your order confirmation screen after a successful payment. |
This guide will lead you through all the steps required to accept Klarna Payments in your mobile app using your web integration. At the end, you will be able to accept payments with Klarna with very few native changes.
Klarna still recommends Klarna Mobile SDK as first choice for Web Checkout integrations in mobile apps, Mobile SDK WebView integrations can be utilized instead of System WebViews in such cases.
This guide assumes that you already have a web checkout integrated with Klarna Payments and you intend to use it in your mobile application.
If you haven't done such web integration, we suggest you to check the recommended integration approaches here. These will also help you offer better UX and more stable integration than System WebViews.
Klarna purchase flows might require authorizations in other applications (e.g. bank apps) or do a handover to the Klarna app. In such cases, a return URL to your application ensures seamless return to the flow in your app, hence setting up a return URL is required. It is expected that redirects to this URL should only open your application without any changes in the UI state, ensuring the customer can continue the flow prior to external navigation.
You can set up a Return URL app scheme to your application by configuring a custom URL scheme.
Important: The return URL string passed to Klarna must include ://
after the scheme name. For example, if you defined myApp
as the scheme, you must use "myApp://"
as the return URL argument to Klarna.
To avoid a Klarna specific app scheme, you can use a host in a common scheme for Klarna redirects, e.g. myApp://klarna-redirect
, this can allow you to differentiate and handle these redirect in your handler.
Considering the return URL is a constant value in Constants.klarnaReturnUrl
, you can handle redirects to your return URL as such:
When creating a payment session, make sure you backend sets merchant_urls.app_return_url
to return URL set up for the app.
On iOS, system WebViews are typically implemented using ASWebAuthenticationSession
or SFSafariViewController
. While they appear similar from the customer's perspective, they differ significantly in how they handle session and cookie management.
ASWebAuthenticationSession
supports cookie and session sharing with the Safari browser by default. This capability is crucial for Klarna, as it allows us to recognize returning customers across the device and deliver a smoother checkout experience.In contrast, SFSafariViewController
does not support session persistence or cookie sharing.
Therefore, we require the use of ASWebAuthenticationSession
with prefersEphemeralWebBrowserSession set to false, ensuring sessions are persistent and shared with Safari.
Start ASWebAuthenticationSession
with your web checkout URL for this customer session:
let session: ASWebAuthenticationSession = ASWebAuthenticationSession(
url: sessionUrl, // URL of your web checkout
callbackURLScheme: callbackUrl // your completion for closing the System WebView from your confirmation page
) { url, error in
guard error == nil else {
// Handle error
return
}
guard let url = url else {
Implement ASWebAuthenticationPresentationContextProviding
to provide a ASPresentationAnchor
to the session:
extension YourViewController: ASWebAuthenticationPresentationContextProviding {
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
return self.view.window ?? ASPresentationAnchor()
}
}
Enabling shared cookies and device wide single login experience for System WebView will result in user accepting to allow login via "<yourdomain>.com" on iOS. This is a common practice, and we expect almost all iOS users to be familiar with it and accept accordingly.
After the purchase is completed, Klarna payment flow will be closed and the customer will be taken back to your checkout page where you will be notified for the authorized session in your web integration. From your checkout or the confirmation page, you can choose to redirect the customer back to your application.
To get the user back to your application from System WebViews, you can redirect to callbackURLScheme
set for ASWebAuthenticationSession
from your checkout or confirmation pages, as those will be loaded in the System WebView.
![]() | ![]() | ![]() |
Klarna purchase flow in System WebView. | Your checkout page in System WebView. | Your confirmation page in System WebView. |
As you are re-using your web integration, this integration approach assumes that you have implemented order creation via the integration that exists in web. Hence, this documentation does not cover this step, if you would like to learn more about authorizing a session and creating an order in web, check out these documentations
Klarna Mobile SDK provides a full suite of mobile-first integrations, including Klarna products like:
![]() | ![]() | ![]() |
Sign in with Klarna | On-site Messaging | Express Checkout |
Complete your integration with