Payments
Other payment methods
Klarna
iOS

Klarna payments on iOS Beta

Use Sources to accept payments using Klarna, a popular global payment method.

Stripe users in supported countries can enable Klarna payments using Sources.

During the payment process, a Source object is created and your customer is presented with a Klarna Hosted Payment Page that displays payment options, including Pay now, Pay later, and Financing. Your integration then uses the source to make a charge request and complete the payment.

Within the scope of Sources, Klarna is a push-based, single-use and synchronous or asynchronous method of payment.

U.S. users can accept payments from U.S. customers, and European users can accept payments from customers in the following countries:

Purchase Country Country Code Currency
Austria AT EUR
Denmark DK DKK
Finland FI EUR
Germany DE EUR
Netherlands NL EUR
Norway NO NOK
Sweden SE SEK
United Kingdom GB GBP

Prerequisite: Update Terms and Conditions

Prior to processing live transactions with Klarna, it’s important that you update your Terms and Conditions and Privacy Policy, per Klarna’s requirements.

Step 1: Create an STPSource object

A Source object is either created client-side using the iOS SDK or server-side using the Source creation endpoint. If you would like to create a Klarna source server-side, visit Klarna payments with Sources.

You can use the STPAPIClient class to create a source. First, assemble an STPSourceParams object with the payment, address, and order information you’ve collected. Then, pass this object to STPAPIClient’s createSourceWithParams: method.

Unlike most payment methods, Klarna requires that you pass in a list of the line items in your order. It will also optionally accept customer information to be used for Klarna’s credit check. If you do not provide this information, Klarna will prompt the user for additional information during checkout.

If you decide to provide customer information to Klarna, you must include at least the following details:

  • Separate first and last names
  • Full street address
  • Email address

You may also provide the following extra information, to prevent the user from being asked for it at checkout:

  • Phone number
  • Date of birth
let address = STPAddress() address.line1 = "29 Arlington Avenue" address.email = "test@example.com" address.city = "London" address.postalCode = "N1 7BE" address.country = "UK" address.phone = "02012267709" // Klarna requires separate first and last names for the customer. let firstName = "Arthur" let lastName = "Dent" // In some EU countries, Klarna uses the user's date of birth for a credit check. let dob = STPDateOfBirth.init() dob.day = 11 dob.month = 3 dob.year = 1952 // Klarna requires individual line items in the transaction to be broken out let items = [STPKlarnaLineItem(itemType: .SKU, itemDescription: "Towel", quantity: 1, totalAmount: 10000), STPKlarnaLineItem(itemType: .SKU, itemDescription: "Digital Watch", quantity: 2, totalAmount: 20000), STPKlarnaLineItem(itemType: .tax, itemDescription: "Taxes", quantity: 1, totalAmount: 100), STPKlarnaLineItem(itemType: .shipping, itemDescription: "Shipping", quantity: 1, totalAmount: 100)] let sourceParams = STPSourceParams.klarnaParams( withReturnURL: "payments-example://stripe-redirect", currency: "GBP", purchaseCountry: "UK", items: items, customPaymentMethods: [], // The CustomPaymentMethods flag is ignored outside the US billingAddress: address, billingFirstName: firstName, billingLastName: lastName, billingDOB: dob) STPAPIClient.shared().createSource(with: sourceParams) { source, error in // Handle the returned source (or error) here. }
STPAddress *address = [[STPAddress alloc] init]; address.line1 = @"29 Arlington Avenue"; address.email = @"test@example.com"; address.city = @"London"; address.postalCode = @"N1 7BE"; address.country = @"UK"; address.phone = @"02012267709"; // Klarna requires separate first and last names for the customer. NSString *firstName = @"Arthur"; NSString *lastName = @"Dent"; // In some EU countries, Klarna uses the user's date of birth for a credit check. STPDateOfBirth *dob = [[STPDateOfBirth alloc] init]; dob.day = 11; dob.month = 3; dob.year = 1952; NSArray *items = @[[[STPKlarnaLineItem alloc] initWithItemType:STPKlarnaLineItemTypeSKU itemDescription:@"Towel" quantity:@(1) totalAmount:@(10000)], [[STPKlarnaLineItem alloc] initWithItemType:STPKlarnaLineItemTypeSKU itemDescription:@"Digital Watch" quantity:@(2) totalAmount:@(20000)], [[STPKlarnaLineItem alloc] initWithItemType:STPKlarnaLineItemTypeTax itemDescription:@"Taxes" quantity:@(1) totalAmount:@(100)], [[STPKlarnaLineItem alloc] initWithItemType:STPKlarnaLineItemTypeShipping itemDescription:@"Shipping" quantity:@(1) totalAmount:@(100)] ]; STPSourceParams *sourceParams = [STPSourceParams klarnaParamsWithReturnURL:@"payments-example://stripe-redirect" currency:@"GBP" purchaseCountry:@"UK" items:items customPaymentMethods:STPKlarnaPaymentMethodsNone billingAddress:address billingFirstName:firstName billingLastName:lastName billingDOB:dob]; [[STPAPIClient sharedClient] createSourceWithParams:sourceParams completion:^(STPSource * _Nullable source, NSError * _Nullable error) { // Handle the returned source (or error) here. }];

Stripe returns a Source object containing the relevant details for the method of payment used. Information specific to Klarna is provided within the source.klarna accessor.

{ "id": "src_16xhynE8WzK49JbAs9M21jaR", "object": "source", "amount": 1099, "client_secret": "src_client_secret_qxC8aTQt9mSnwh29lLgP9pfb", "created": 1445277809, "currency": "eur", "flow": "none", "klarna": { "locale": "de-DE",
See all 48 lines "purchase_country": "DE", "client_token": "eyJhbGciOiJub25lIn0...", "pay_later_asset_urls_descriptive": "https://cdn.klarna.com/1.0/shared/image/generic/badge/en_gb/pay_later/descriptive/pink.svg", "pay_later_asset_urls_standard": "https://cdn.klarna.com/1.0/shared/image/generic/badge/en_gb/pay_later/standard/pink.svg", "pay_later_name": "Pay later.", "pay_now_asset_urls_descriptive": "https://cdn.klarna.com/1.0/shared/image/generic/badge/en_gb/pay_now/descriptive/pink.svg", "pay_now_asset_urls_standard": "https://cdn.klarna.com/1.0/shared/image/generic/badge/en_gb/pay_now/standard/pink.svg", "pay_now_name": "Pay now.", "pay_over_time_asset_urls_descriptive": "https://cdn.klarna.com/1.0/shared/image/generic/badge/en_gb/slice_it/descriptive/pink.svg", "pay_over_time_asset_urls_standard": "https://cdn.klarna.com/1.0/shared/image/generic/badge/en_gb/slice_it/standard/pink.svg", "pay_over_time_name": "Slice it.", "payment_method_category": "pay_later,pay_now,pay_over_time" }, "livemode": true, "source_order": { "items": [{ "type": "sku", "description": "Grey cotton T-shirt", "quantity": 2, "currency": "eur", "amount": 796 }, { "type": "tax", "description": "Taxes", "currency": "eur", "amount": 20 }, { "type": "shipping", "description": "Free Shipping", "currency": "eur", "amount": 0 }], }, "statement_descriptor": null, "status": "pending", "type": "klarna", "usage": "single_use" }

Error codes

Source creation for Klarna payments may return any of the following errors:

Error Description
payment_method_not_available The payment method is currently not available. Invite your customer to fallback to another payment method to proceed.
processing_error An unexpected error prevented us from creating the source. Retry source creation.
missing_sku_item_quantity The SKU provided in the order is missing a quantity value.
country_currency_mismatch The currency is not the default currency of the customer’s billing address country.
country_not_supported The country is not supported for the currency being used.
invalid_currency The currency is not supported.
invalid_email The owner’s email is not valid.
invalid_phone The owner’s phone number is not valid.
invalid_address The specified address is not valid.

Update the source

If customer details are not provided at source creation, these parameters must be added using a source update.

Billing information

Billing information is required for physical goods and, if not provided during source creation a source update is required. If the billing address is provided but the shipping address isn’t, Klarna will assume the shipping address is the same as the billing address. If neither the billing or shipping address is provided, Klarna will collect the billing address during the checkout, and assume the shipping address is the same as the billing address. In both circumstances, if the order’s shipping address differs from the billing address, Klarna will not cover any losses that might occur due to customer disputes or fraud.

Parameter Value
klarna[first_name] The first name of the customer (Klarna requires the customer’s name to be passed as separate first and last name values).
klarna[last_name] The last name of the customer.
owner[email] The email address of the customer.
owner[address] The billing address of the customer.

See an example of updating a source with billing information:

curl https://api.stripe.com/v1/sources/src_18cPLvAHEMiOZZp1YBngt6En \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "klarna[first_name]"=Jenny \ -d "klarna[last_name]"=Rosen \ -d "owner[email]"="jenny.rosen@example.com" \ -d "owner[address][line1]"="Schulstrasse 4" \ -d "owner[address][line2]"= \ -d "owner[address][city]"="Bad Oeynhausen" \ -d "owner[address][state]"=Nordrhein-Westfalen \ -d "owner[address][postal_code]"=32547 \ -d "owner[address][country]"=DE
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = Stripe::Source.retrieve('src_18cPLvAHEMiOZZp1YBngt6En') source.klarna["first_name"] = "Jenny" source.klarna["last_name"] = "Rosen" source.owner["email"] = "jenny.rosen@example.com" source.owner["address"]["line1"] = "Schulstrasse 4" source.owner["address"]["line2"] = "" source.owner["address"]["city"] = "Bad Oeynhausen" source.owner["address"]["state"] = "Nordrhein-Westfalen" source.owner["address"]["postal_code"] = "32547" source.owner["address"]["country"] = "DE" source.save
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = stripe.Source.retrieve("src_18cPLvAHEMiOZZp1YBngt6En") source.klarna["first_name"] = "Jenny" source.klarna["last_name"] = "Rosen" source.owner["email"] = "jenny.rosen@example.com" source.owner["address"]["line1"] = "Schulstrasse 4" source.owner["address"]["line2"] = "" source.owner["address"]["city"] = "Bad Oeynhausen" source.owner["address"]["state"] = "Nordrhein-Westfalen" source.owner["address"]["postal_code"] = "32547" source.owner["address"]["country"] = "DE" source.save()
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $source = StripeSource::retrieve("src_18cPLvAHEMiOZZp1YBngt6En"); $source->klarna["first_name"] = "Jenny" $source->klarna["last_name"] = "Rosen" $source->owner["email"] = "jenny.rosen@example.com" $source->owner["address"]["line1"] = "Schulstrasse 4" $source->owner["address"]["line2"] = "" $source->owner["address"]["city"] = "Bad Oeynhausen" $source->owner["address"]["state"] = "Nordrhein-Westfalen" $source->owner["address"]["postal_code"] = "32547" $source->owner["address"]["country"] = "DE" $source->owner["email"] = "amount_4242@example.com"; $source->save();

Shipping information

If selling a physical product that must be shipped, shipping information is required. If not provided during creation, shipping information should be provided in a source update.

Parameter Value
klarna[shipping_first_name] The first name used on the shipping address (Klarna requires the shipping name to be passed as separate first and last name values).
klarna[shipping_last_name] The last name used on the shipping address.
source_order[shipping][phone] Recipient phone (including extension).
source_order[shipping][address] The shipping address of the customer.

See an example of updating a source with shipping information:

curl https://api.stripe.com/v1/sources/src_18cPLvAHEMiOZZp1YBngt6En \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "klarna[shipping_first_name]"=Jenny \ -d "klarna[shipping_last_name]"=Rosen \ -d "source_order[shipping][phone]"="(0xx) xxxx-xxxx" \ -d "source_order[shipping][address][line1]"="Schulstrasse 4" \ -d "source_order[shipping][address][line2]"= \ -d "source_order[shipping][address][city]"="Bad Oeynhausen" \ -d "source_order[shipping][address][state]"=Nordrhein-Westfalen \ -d "source_order[shipping][address][postal_code]"=32547 \ -d "source_order[shipping][address][country]"=DE
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = Stripe::Source.retrieve('src_18cPLvAHEMiOZZp1YBngt6En') source.klarna["shipping_first_name"] = "Jenny" source.klarna["shipping_last_name"] = "Rosen" source.source_order["shipping"]["phone"] = "(0xx) xxxx-xxxx" source.source_order["shipping"]["address"]["line1"] = "Schulstrasse 4" source.source_order["shipping"]["address"]["line2"] = "" source.source_order["shipping"]["address"]["city"] = "Bad Oeynhausen" source.source_order["shipping"]["address"]["state"] = "Nordrhein-Westfalen" source.source_order["shipping"]["address"]["postal_code"] = "32547" source.source_order["shipping"]["address"]["country"] = "DE" source.save
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = stripe.Source.retrieve("src_18cPLvAHEMiOZZp1YBngt6En") source.klarna["shipping_first_name"] = "Jenny" source.klarna["shipping_last_name"] = "Rosen" source.source_order["shipping"]["phone"] = "(0xx) xxxx-xxxx" source.source_order["shipping"]["address"]["line1"] = "Schulstrasse 4" source.source_order["shipping"]["address"]["line2"] = "" source.source_order["shipping"]["address"]["city"] = "Bad Oeynhausen" source.source_order["shipping"]["address"]["state"] = "Nordrhein-Westfalen" source.source_order["shipping"]["address"]["postal_code"] = "32547" source.source_order["shipping"]["address"]["country"] = "DE" source.save()
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $source = StripeSource::retrieve("src_18cPLvAHEMiOZZp1YBngt6En"); $source->klarna["shipping_first_name"] = "Jenny" $source->klarna["shipping_last_name"] = "Rosen" $source->source_order["shipping"]["phone"] = "(0xx) xxxx-xxxx" $source->source_order["shipping"]["address"]["line1"] = "Schulstrasse 4" $source->source_order["shipping"]["address"]["line2"] = "" $source->source_order["shipping"]["address"]["city"] = "Bad Oeynhausen" $source->source_order["shipping"]["address"]["state"] = "Nordrhein-Westfalen" $source->source_order["shipping"]["address"]["postal_code"] = "32547" $source->source_order["shipping"]["address"]["country"] = "DE" $source->owner["email"] = "amount_4242@example.com"; $source->save();

Tracking information

Additionally, to assist Klarna with any customer requests about a physical shipment, you can update the source to include tracking information.

Parameter Value
source_order[shipping][carrier] The delivery service used to ship a physical product, such as FedEx, UPS, USPS, etc.
source_order[shipping][tracking_number] The tracking number obtained from the delivery service. If multiple tracking numbers were generated for this purchase, please separate them with commas.

Here is an example of how to update a source with tracking information:

curl https://api.stripe.com/v1/sources/src_18cPLvAHEMiOZZp1YBngt6En \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "source_order[shipping][carrier]"=UPS \ -d "source_order[shipping][tracking_number]"=1Z999AA10123456784
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = Stripe::Source.retrieve('src_18cPLvAHEMiOZZp1YBngt6En') source.source_order["shipping"]["carrier"] = "UPS" source.source_order["shipping"]["tracking_number"] = "1Z999AA10123456784" source.save
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = stripe.Source.retrieve("src_18cPLvAHEMiOZZp1YBngt6En") source.source_order["shipping"]["carrier"] = "UPS" source.source_order["shipping"]["tracking_number"] = "1Z999AA10123456784" source.save()
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $source = StripeSource::retrieve("src_18cPLvAHEMiOZZp1YBngt6En"); $source->source_order["shipping"]["carrier"] = "UPS" $source->source_order["shipping"]["tracking_number"] = "1Z999AA10123456784" $source->owner["email"] = "amount_4242@example.com"; $source->save();

Attachment

For businesses on Klarna’s Restricted List, it’s recommended that you update the source to include additional purchase information relating to the transaction via the klarna[attachment] parameter.

Parameter Value
klarna[attachment] Additional purchase information relating to the transaction that may be required for select businesses, such as those on Klarna’s Restricted List to increase approval rates. Values provided vary based on business type and can be found on Klarna’s site

See below for an example of updating a source with an event attachment.

curl https://api.stripe.com/v1/sources/src_18cPLvAHEMiOZZp1YBngt6En \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "klarna[attachment]"="{\"event\":[{\"event_name\":\"Music Festival\",\"arena_name\":\"The Big Concert Venue\",\"start_time\":\"2019-12-12T16:00:00Z\",\"end_time\":\"2019-12-13T06:00:00Z\"}]}"
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = Stripe::Source.retrieve('src_18cPLvAHEMiOZZp1YBngt6En') source.klarna["attachment"] = "{\"event\":[{\"event_name\":\"Music Festival\",\"arena_name\":\"The Big Concert Venue\",\"start_time\":\"2019-12-12T16:00:00Z\",\"end_time\":\"2019-12-13T06:00:00Z\"}]}" source.save
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = stripe.Source.retrieve("src_18cPLvAHEMiOZZp1YBngt6En") source.klarna["attachment"] = "{\"event\":[{\"event_name\":\"Music Festival\",\"arena_name\":\"The Big Concert Venue\",\"start_time\":\"2019-12-12T16:00:00Z\",\"end_time\":\"2019-12-13T06:00:00Z\"}]}" source.save()
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $source = StripeSource::retrieve("src_18cPLvAHEMiOZZp1YBngt6En"); $source->klarna["attachment"] = "{\"event\":[{\"event_name\":\"Music Festival\",\"arena_name\":\"The Big Concert Venue\",\"start_time\":\"2019-12-12T16:00:00Z\",\"end_time\":\"2019-12-13T06:00:00Z\"}]}" $source->owner["email"] = "amount_4242@example.com"; $source->save();

Step 2: Authorize the payment with Klarna

Klarna will return a redirect URL. You can use STPRedirectContext to handle the redirect flow.

STPAPIClient.shared().createSource(with: sourceParams) { source, error in guard let source = source else { // Handle any errors from Stripe's backend when creating the source return } // Set up an STPRedirectContext with your newly-created Klarna STPSource object self.redirectContext = STPRedirectContext(source: source) { sourceID, clientSecret, error in guard error == nil else { // Handle any errors from displaying the Klarna redirect return } // The user has completed the redirect flow. // Handle updating the status of the order in your UI. } // Present the Klarna redirect webview self.redirectContext?.startRedirectFlow(from: self) }
[[STPAPIClient sharedClient] createSourceWithParams:sourceParams completion:^(STPSource * _Nullable source, NSError * _Nullable error) { if (error != nil) { // Handle any errors from Stripe's backend when creating the source return; } // Set up an STPRedirectContext with your newly-created Klarna STPSource object self.redirectContext = [[STPRedirectContext alloc] initWithSource:source completion:^(NSString * _Nonnull sourceID, NSString * _Nullable clientSecret, NSError * _Nullable error) { if (error != nil) { // Handle any errors from displaying the Klarna redirect return; } // The user has completed the redirect flow. // Handle updating the status of the order in your UI. }]; [self.redirectContext startRedirectFlowFromViewController:self]; }];

As the customer interacts with the Klarna widget, they may be asked for additional information depending on the jurisdiction they are in.

If an attempt to authorize a payment fails, that category is removed from the list of available payment_method_category on the source, and reloading the Klarna widget will return show_form: false. The source status will stay pending until the the last method is failed, this will cause the source status to become failed.

After the authorization process, your customer is redirected back to the URL provided as the value of redirect[return_url]. This happens regardless of authorization success or failure. Stripe appends redirect[return_url] with a redirect_status parameter, with the following potential values:

Value Description Suggested Action
canceled The customer abandoned the payment flow. Reload the checkout page with the same options
failed The customer was not eligible for the selected Klarna method. Reload the checkout page with the remaining eligible Klarna payment_method_category

If the customer authorizes the payment, the Source object’s status transitions to chargeable when it is ready to be used in a charge request. If your customer declines the payment and no other payment_method_category are available, the status transitions to failed.

Styling the Klarna Hosted Payment Page

You can customize the style of the Klarna hosted payment page by providing additional options when creating the source, such as purchase_type. Refer to the Klarna SDK documentation for more information.

Parameter   Value
logo_url optional A public URL for your businesses logo, must be served over HTTPS.
background_image_url optional A public URL for a background image, must be served over HTTPS.
page_title optional Title displayed on the top of the Klarna Hosted Payment Page.
purchase_type optional The buy button type, accepted values are buy, rent, book, subscribe, download, order, continue.

Testing the redirect process

When creating a Source object using your test API keys, follow any one of the URLs returned in the klarna[***_redirect_url] field. This leads to a Klarna page that displays information about the test payment, where you can either authorize or cancel the payment. Authorizing the payment redirects you to the URL specified in redirect[return_url] but doesn’t attempt to charge or contact the customer.

Step 3: Charge the source

Once Klarna authorizes the payment, the source’s status transitions to chargeable and it can be used to make a charge request.

Since that transition happens asynchronously, it is essential that your integration rely on webhooks to determine when the source becomes chargeable in order to create a charge. Please refer to our best practices for more details on how to best integrate payment methods using webhooks.

Webhooks

The following webhook events are also sent to notify you about changes to the source’s status:

Event Description
source.chargeable A source object becomes chargeable after it has been authorized by Klarna.
source.failed A source object failed to become chargeable.
source.canceled A source object expired and cannot be used to create a charge.

Make a charge request to finalize the authorization

Once the source is chargeable, from your source.chargeable webhook handler, you can make a charge request using the source ID as the value for the source parameter to complete the payment. The amount must match the Source object’s amount.

When selling physical goods, you should pass the capture: false flag to the charge request to let Klarna know that you’re working on fulfilling the order. Once all items have been shipped, send a capture request to let Klarna know that the order has been fulfilled. Note that the order must be fulfilled within 28 days. Only one capture, less than or equal to the charge amount, is permitted. Any remaining amount will be released back to the customer.

curl https://api.stripe.com/v1/charges \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d amount=1099 \ -d currency=eur \ -d capture=false \ -d source=src_18eYalAHEMiOZZp1l9ZTjSU0
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' charge = Stripe::Charge.create({ amount: 1099, currency: 'eur', source: 'src_18eYalAHEMiOZZp1l9ZTjSU0', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' charge = stripe.Charge.create( amount=1099, currency='eur', source='src_18eYalAHEMiOZZp1l9ZTjSU0', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $charge = \Stripe\Charge::create([ 'amount' => 1099, 'currency' => 'eur', 'source' => 'src_18eYalAHEMiOZZp1l9ZTjSU0', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; ChargeCreateParams params = ChargeCreateParams.builder() .setAmount(1099L) .setCurrency("eur") .setDescription("Example charge") .setStatementDescriptor("Custom descriptor") .setSource("src_18eYalAHEMiOZZp1l9ZTjSU0") .build(); Charge charge = Charge.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const charge = await stripe.charges.create({ amount: 1099, currency: 'eur', source: 'src_18eYalAHEMiOZZp1l9ZTjSU0', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" chargeParams := &stripe.ChargeParams{ Amount: stripe.Int64(1099), Currency: stripe.String(string(stripe.CurrencyEUR)), } chargeParams.SetSource("src_18eYalAHEMiOZZp1l9ZTjSU0") ch, err := charge.New(chargeParams)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new ChargeCreateOptions { Amount = 1099, Currency = "eur", Source = "src_18eYalAHEMiOZZp1l9ZTjSU0", }; var service = new ChargeService(); Charge charge = service.Create(options);

Klarna Sources are single-use and cannot be used for recurring or additional payments. Refer to our Sources & Customers guide for more information on how single-use Source objects interact with Customer objects.

Optional: Authorizing the payment and capturing immediately

By omitting the capture parameter or sending capture: true, Klarna assumes that the order is immediately fulfilled. This is handy if you’re selling digital goods.

Step 4: Confirm that the charge has succeeded

Klarna is asynchronous for payments made by customers in the UK and U.S., and synchronous otherwise. When async for the UK and U.S., the Charge object’s status remains in a pending state for up to 24 hours from its creation. Once the charge is confirmed—and the funds guaranteed—its status is updated to succeeded.

All other supported countries are synchronously approved. The Charge object’s status immediately reflects whether or not it has succeeded.

One of the following events is sent when the charge’s status is updated:

Event Description
charge.succeeded The charge succeeded and the payment is complete.
charge.failed The charge has failed and the payment could not be completed.

We recommend that you rely on the charge.succeeded webhook event to notify your customer that the payment process has been completed and their order is confirmed. Please refer to our best practices for more details on how to best integrate payment methods using webhooks.

Stop payment

Klarna may request additional information relating to high risk orders and in some cases require that you cancel and create a refund for orders that haven’t shipped. Generally, failure to respond within 24 hours may result in a dispute at a later date. Refer to the Klarna shipping policies for more details.

Refunds

Payments made with Klarna can only be submitted for refund within 180 days from the date of the original charge. After 180 days, it is no longer possible to refund the charge.

Klarna supports both full and partial refunds. When you create a refund for the full amount of the charge, the Klarna order is voided, and if funds had been moved by the customer, Klarna will return these funds. You can also issue multiple partial refunds, up to the amount of the original charge. A partial refund will update the Klarna order to reflect the new total amount, and if funds were moved by the customer, Klarna will return the difference.

You can submit a refund against charges that are still pending and have not yet been confirmed. If you create a full or partial refund on a pending charge, the refund is performed only after the charge’s status is transitioned to succeeded. In the event of the charge transitioning to status failed, full and partial refunds are marked as canceled, as the money never left the customer’s bank account.

Disputes

Klarna may initiate a dispute if the customer claims that you haven’t delivered the relevant goods or services as expected. Before initiating a dispute, Klarna will contact you via email, providing details of the customer’s claim. Klarna may request additional information in order to resolve it. If Klarna ultimately rules in favor of the customer, they may initiate a dispute.

If Klarna creates a dispute, a charge.dispute.created webhook event is sent and Stripe deducts the amount of the dispute from your Stripe balance.

Klarna disputes are final and there is no appeal process.

Source expiration

A source must be used within one hour of becoming chargeable. If unused after an hour, its status automatically transitions to canceled and your integration receives a source.canceled webhook event.

Testing Klarna payments

Below is a set of test email addresses and test credit repayment options outlined by customer country. You can use these to test Klarna payments under various conditions while you develop your Klarna integration.

Email Description
test+red@example.com During authorization, the Klarna widget returns show_form: false for all methods. Following a redirect shows “Option not available”.
Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131 Use the supplied test IBAN in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.
Bank Transfer Use Klarna’s Demo Bank in the Klarna Widget Use Klarna’s “Demo Bank” in the loaded Klarna widget to simulate the bank transfer payment flow for a customer.
Email Description
test+red@example.com During authorization, the Klarna widget returns show_form: false for all methods. Following a redirect shows “Option not available”.
Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131 Use the supplied test IBAN in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.
Email Description
test+red@example.com During authorization, the Klarna widget returns show_form: false for all methods. Following a redirect shows “Option not available”.
Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131 Use the supplied test IBAN in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.
Bank Transfer Use Klarna’s Demo Bank in the Klarna Widget Use Klarna’s “Demo Bank” in the loaded Klarna widget to simulate the bank transfer payment flow for a customer.
Email Description
test+red@example.com During authorization, the Klarna widget returns show_form: false for all methods. Following a redirect shows “Option not available”.
Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131 Use the supplied test IBAN in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.
Bank Transfer Use Klarna’s Demo Bank in the Klarna Widget Use Klarna’s “Demo Bank” in the loaded Klarna widget to simulate the bank transfer payment flow for a customer.
Email Description
test+red@example.com During authorization, the Klarna widget returns show_form: false for all methods. Following a redirect shows “Option not available”.
Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131 Use the supplied test IBAN in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.
Bank Transfer Use Klarna’s Demo Bank in the Klarna Widget Use Klarna’s “Demo Bank” in the loaded Klarna widget to simulate the bank transfer payment flow for a customer.
Email Description
test+red@example.com During authorization, the Klarna widget returns show_form: false for all methods. Following a redirect shows “Option not available”.
Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131 Use the supplied test IBAN in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.
Email Description
test+red@example.com During authorization, the Klarna widget returns show_form: false for all methods. Following a redirect shows “Option not available”.
Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131
Personal Number:19770111-6050
Use the supplied test IBAN and Personal number in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.
Bank Transfer Use Klarna’s Demo Bank in the Klarna Widget Use Klarna’s “Demo Bank” in the loaded Klarna widget to simulate the bank transfer payment flow for a customer.

No test emails for Swiss customers.

Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131 Use the supplied test IBAN in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.
Bank Transfer Use Klarna’s Demo Bank in the Klarna Widget Use Klarna’s “Demo Bank” in the loaded Klarna widget to simulate the bank transfer payment flow for a customer.
Email Description
test+require_signup@example.com During authorization of pay_over_time, Klarna prompts for the customer to sign up. Otherwise, it assumes it’s a returning customer.
test+red@example.com During authorization, the Klarna widget returns show_form: false for all methods. Following a redirect shows “Option not available”.
test+denied@stripe.com Using the Klarna SDK to call authorize displays “Your purchase can not be accepted” for all methods. Submitting the form on the Klarna Hosted Payment Page displays the same message.
test+pend-accept-03@example.com The status of a charge created with this source is initially set to pending, then transitions to successful after about 3 minutes.
test+pend-reject-03@example.com The status of a charge created with this source is initially set to pending, then transitions to failed after about 3 minutes.
Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131 Use the supplied test IBAN in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.
Email Description
test+require_signup@example.com During authorization of pay_over_time, Klarna prompts for the customer to sign up. Otherwise, it assumes it’s a returning customer.
test+red@example.com During authorization, the Klarna widget returns show_form: false for all methods. Following a redirect shows “Option not available”.
test+denied@stripe.com Using the Klarna SDK to call authorize displays “Your purchase can not be accepted” for all methods. Submitting the form on the Klarna Hosted Payment Page displays the same message.
test+pend-accept-03@example.com The status of a charge created with this source is initially set to pending, then transitions to successful after about 3 minutes.
test+pend-reject-03@example.com The status of a charge created with this source is initially set to pending, then transitions to failed after about 3 minutes.
Repayment Type Test Number Description
Direct Debit IBAN:DE11520513735120710131 Use the supplied test IBAN in order to simulate the direct debit payment flow for a customer.
Credit Card Number:4111 1111 1111 1111
CVV:123
Expiration:12/25(Or any other valid date in the future)
Use the supplied test card number, CVV and expiration date to simulate the card payment flow for a customer.

Related resources

Was this page helpful?
Questions? Contact us.
Developer tutorials on YouTube.