Web Checkout - Android

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.

Integration Steps

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.

​{{#lst:Klarna Payments (Standalone) - Android|returnUrl}}As Android Custom Tabs will be shown to the customer during the flow, we require Activity set up for intent-filter to finish immediately and retain Custom Tabs on top.

KOTLIN
class RedirectActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        handleRedirect(intent)
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        handleRedirect(intent)
    }

When creating a payment session, make sure you backend sets merchant_urls.app_return_url to return URL set up for the app.

On Android, system WebViews are commonly implemented using Android Custom Tabs. By default, Custom Tabs share cookies and session data with the device’s default browser (e.g., Chrome or Firefox). This shared session capability is essential for Klarna, as it allows us to recognize returning customers across sessions and provide a seamless checkout experience.

While it's possible to disable session sharing using Ephemeral Custom Tabs, we require persistent (non-ephemeral) sessions as this functionality enables Klarna to maintain customer context across the device.

GROOVY
dependencies {
    implementation 'androidx.browser:browser:<latestVersion>'
}
KOTLIN
val customTabsIntent = CustomTabsIntent.Builder()
    .setEphemeralBrowsingEnabled(false) // only available in android.browser version 1.9.0
    .build()

customTabsIntent.launchUrl(this, sessionUrl.toUri()) // URL of your web checkout for this customer session

Redirect back to your app

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 any intent-filter set for the Activity that you want to return to 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
Sign in with KlarnaOn-site MessagingExpress Checkout
  • On-site Messaging: Show contextual messaging let your customers know about the available payment options in pre-checkout: click here to learn more.
  • Sign in with Klarna: Seamlessly identify and let users login via their Klarna account: click here to learn more.
  • Express Checkout: Accelerate your checkout process and boost conversion by offering a one-click checkout, click here to learn more.

Complete your integration with