Set up future Klarna payments
Learn how to save Klarna details and charge your customers later.
You can save Klarna as a customer’s payment method and charge future payments to support:
- Automatic payment for subscriptions, with or without a free trial.
- Saving Klarna to a wallet to streamline future on-demand purchases without requiring customer re-authentication.
The following select payment options, subscription lengths, and buyer countries support Klarna recurring payments:
Payment options | Supported use cases | Supported buyer countries |
---|---|---|
Pay in full |
| AT, BE, CA, CH, DE, DK, ES, FI, FR, IE, IT, GR, NL, NO, PL, PT, SE, UK, US |
Pay later |
| DE, SE, US |
Pay in 3 or 4 |
| AT, CA, CH, DE, DK, ES, FI, FR, IE, IT, GR, NL, NO, PL, PT, UK, US |
Choose your payment integration type below to save Klarna as a payment method. If you use Stripe Billing, see Klarna for subscriptions.
Use Stripe Checkout to collect Klarna payment details in advance, with the final amount or payment date determined later. Use this for:
- Saving payment methods to a wallet to streamline future purchases.
- Collecting surcharges after fulfilling a service.
- Starting a free trial for a subscription.
Set up StripeServer-side
First, you need a Stripe account. Register now.
Use our official libraries for access to the Stripe API from your application:
Create or retrieve a Customer before setupServer-side
To reuse a Klarna payment method for future payments, you must attach it to a Customer.
Create a Customer object when your customer creates an account on your business. Associating the ID of the Customer object with your own internal representation of a customer enables you to retrieve and use the stored payment method details later. If your customer hasn’t created an account, you can still create a Customer object now and associate it with your internal representation of the customer’s account later.
Create a Checkout SessionClient-sideServer-side
Before you can accept Klarna payments, your customer must authorise you to use their Klarna account for future payments through Stripe Checkout.
Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.
<html> <head> <title>Checkout</title> </head> <body> <form action="/create-checkout-session" method="POST"> <button type="submit">Checkout</button> </form> </body> </html>
After creating the Checkout Session, redirect your customer to the URL returned in the response.
Handle redirect back from CheckoutClient-sideServer-side
When your customer provides their payment method details, they’re redirected to the success_
, a page on your website that informs them that they saved their payment method successfully. Make the Session ID available on your success page by including the {CHECKOUT_
template variable in the success_
as in the above example.
When your customer clicks on your logo in a Checkout Session without providing their payment method details, Checkout redirects them back to your website by navigating to the cancel_
. This is usually the page on your website that the customer viewed prior to redirecting to Stripe Checkout.
Caution
Don’t rely on the redirect to the success_
alone for detecting payment initiation, as:
- Malicious users could directly access the
success_
without paying and gain access to your goods or services.url - Customers may not always reach the
success_
after a successful payment—they might close their browser tab before the redirect occurs.url
Retrieve the payment methodServer-side
After a customer submits their payment details, retrieve the PaymentMethod object. A PaymentMethod stores the customer’s Klarna account information for future payments. You can retrieve the PaymentMethod synchronously using the success_
or asynchronously using webhooks.
The decision to retrieve the PaymentMethod synchronously or asynchronously depends on your tolerance for dropoff, as customers might not always reach the success_
after a successful payment (for example, it’s possible for them to close their browser tab before the redirect occurs). Using webhooks prevents your integration from experiencing this form of dropoff.
Handle post-setup eventsServer-side
Use a method such as webhooks to confirm that the customer authorised the billing agreement. Don’t rely on your customer to return to the payment status page.
When a customer successfully authorises the billing agreement, Stripe emits a payment_intent.succeeded or setup_intent.succeeded webhook event and the Intent status transitions to succeeded
. Store the resulting payment_method ID to make payments using the saved PaymentMethod later.
If a customer doesn’t successfully authorise the billing agreement, Stripe emits a payment_intent.payment_failed or setup_intent.setup_failed webhook event and the Intent status returns to requires_
.
Test your integration
When testing your Checkout integration, select Klarna as the payment method and click the Save button. In a testing environment, you can then simulate different outcomes within Klarna’s redirect.
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 |
|