Accept a Klarna payment
Learn how to accept Klarna, a global buy now, pay later payment method.
Accepting Klarna in your app consists of displaying a webview for a customer to authenticate their payment. The customer then returns to your app, and you can immediately confirm whether the payment succeeded or failed.
Note
Before you start the integration, make sure your account is eligible for Klarna by navigating to your Payment methods settings.
Set up StripeServer-sideClient-side
First, you need a Stripe account. Register now.
Server-side 
This integration requires endpoints on your server that talk to the Stripe API. Use the official libraries for access to the Stripe API from your server:
Client-side 
The Stripe Android SDK is open source and fully documented.
To install the SDK, add stripe-android
to the dependencies
block of your app/build.gradle file:
Note
For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.
Configure the SDK with your Stripe publishable key so that it can make requests to the Stripe API, such as in your Application
subclass:
Note
Stripe samples also use OkHttp and GSON to make HTTP requests to a server.
Create a PaymentIntentServer-sideClient-side
A PaymentIntent is an object that represents your intent to collect payment from a customer and tracks the lifecycle of the payment process through each stage.
Client-side 
Included in the returned PaymentIntent is a client secret, which the client side can use to securely complete the payment process instead of passing the entire PaymentIntent object. On the client, request a PaymentIntent from your server and store its client secret.
Submit the payment to StripeClient-side
Retrieve the client secret from the PaymentIntent you created in step 2 and call the PaymentLauncher confirm method. This presents a webview where the customer can complete the payment. Afterwards, onActivityResult is called with the result of the payment.
Test Klarna integration
Below, we have specially selected test data for the currently supported customer countries. In a sandbox, Klarna approves or denies a transaction based on the supplied email address.
Two-step authentication
Any six digit number is a valid two-step authentication code. Use 999999
for authentication to fail.
Repayment method
Inside the Klarna flow, you can use the following test values to try various repayment types:
Type | Value |
---|---|
Direct Debit | DE11520513735120710131 |
Bank transfer | Demo Bank |
Credit Card |
|
Debit Card |
|
OptionalSeparate authorization and capture
Klarna supports separate authorization and capture. If there’s a delay between the payment and delivering the goods to your customer, authorize the payment first and capture it later. At the point of capture, Klarna sends a statement to the customer and initiates the due dates on any subsequent payments that they must make. An authorized Klarna payment must be captured within 28 days of the authorization. Otherwise, the authorization automatically cancels and you can no longer capture the payment.
Tell Stripe to authorize only
To indicate that you want separate authorization and capture, set capture_method to
manual
when creating the PaymentIntent. This parameter instructs Stripe to only authorize the amount on the customer’s Klarna account.Capture the funds
After the authorization succeeds, the PaymentIntent status transitions to
requires_
. To capture the authorized funds, make a PaymentIntent capture request. The total authorized amount is captured by default—you can’t capture more than this, but you can capture less.capture Optional Cancel the authorization
Klarna counts any authorized payments against the customer’s total purchasing power within Klarna. Make sure that you actively cancel any authorized payments that you can’t fulfill (for example, the goods can’t be shipped) as soon as this becomes apparent.
OptionalHandle post-payment events
Stripe sends a payment_intent.succeeded event when the payment completes. Use the Dashboard, a custom webhook, or a partner solution to receive these events and run actions, like sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow.
Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events also helps you accept more payment methods in the future. Learn about the differences between all supported payment methods.
Handle events manually in the Dashboard
Use the Dashboard to View your test payments in the Dashboard, send email receipts, handle payouts, or retry failed payments.
Build a custom webhook
Build a custom webhook handler to listen for events and build custom asynchronous payment flows. Test and debug your webhook integration locally with the Stripe CLI.
Integrate a prebuilt app
Handle common business events, such as automation or marketing and sales, by integrating a partner application.
OptionalCustomize the Klarna payment page
Prefill the Klarna form
When the customer chooses to pay Klarna with a deferred payment option (pay later, installments, and financing), Klarna collects enough information for risk assessment and approval. The type of information depends on the country of the customer. For most countries in Europe, it’s the full billing details and date of birth. You can pass this information through the API, and the form will be prefilled when your customer arrives on the page.
A Klarna payment page prefilled with billing details from the API and customized to render in English for a customer in Germany
OptionalAdd line items to the PaymentIntent
Unified line items with Klarna
To optimize approval rates when you integrate with Klarna, include line_
data to represent what’s in a shopper’s cart. For early access, see Payments line items.
Failed payments 
Klarna takes into account multiple factors when deciding to accept or decline a transaction (for example, length of time buyer has been using Klarna, outstanding amount customer has to repay, value of the current order).
When the customer selects a deferred payment method, Klarna performs a risk assessment before accepting the transaction. Klarna might decline the transaction due to unsatisfactory risk assessment result, the transaction amount involved, or the customer having a large outstanding debt. As such, we recommend that you present additional payment options such as card
in your checkout flow. In these cases, the PaymentMethod is detached and the PaymentIntent object’s status automatically transitions to requires_
.
Customers are expected to complete the payment within 48 hours after they’re redirected to the Klarna site. If no action is taken after 48 hours, the PaymentMethod is detached and the PaymentIntent object’s status automatically transitions from requires_
to requires_
.
In these cases, inform your customer to try again with a different payment option presented in your checkout flow.
Klarna rate limits
API requests to Klarna are subject to additional rate limits beyond Stripe’s API-wide rate limits. These limits can differ depending on the shape of the API requests that you make. In general, if you make more than 50 requests per second, you might see rate limiting in the form of responses with HTTP status code 400
or 402
. Contact us if you’re concerned that your usage might reach these levels, because Klarna might be able to increase these limits on a case-by-case basis.
Error messaging
Failed Klarna payments normally return one of the following failure codes. These codes show in the last_payment_error API object.
Caution
Before the 2023-08-16
API version, every Klarna error reported as payment_intent_authentication_failure. Make sure your API version is up to date to see the detailed errors listed below.
Failure code | Explanation |
---|---|
payment_method_customer_decline | The customer cancelled the checkout on Klarna’s page |
payment_method_provider_decline | Klarna declined the customer’s payment |
payment_intent_payment_attempt_expired | The customer never completed the checkout on Klarna’s page, and the payment session has expired |
payment_method_not_available | An unexpected error occurred when trying to use Klarna |