Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Notes to type of payment
Payment Type | Countries | Currency |
---|---|---|
Invoice ("Pay later") |
|
|
Installment ("Slice it") |
|
|
UI Text Box | ||
---|---|---|
| ||
B2B transactions are not supported. |
API-Requests - special notes / deviations
Overview of deviations
UI Text Box | ||
---|---|---|
| ||
|
Clearingtype / Clearingsubtype
clearingtype | financingtype | |
---|---|---|
fnc | KLS | Klarna "Slice It" (Installment, soon: KIS) |
fnc | KLV | Klarna "Pay Later" (Invoice, soon: KIV) |
Summary
Klarna Checkout is a 3 step process.
UI Steps | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
draw.io Diagram | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Creating a new session via our server api
In the first step you need to setup a new checkout session. You can do so by sending a genericpamynet-request to our server api as listed below.
Please make sure to send the customer data within this request as they're needed to initiate a new session.
→ Genericpayment start_session
Optional update session
If the customer leaves the checkout page and comes back later, you can update the created session and change for example the address data.
→ Genericpayment update_session
Token-handling via Klarna widget
Part of the response is a client token. This token needs to be passed to the Klarna Widget. This Widget sends the client token together with the selected payment method (e.g. "Klarna Pay Later") to Klarna to get a authorization token.
Finalizing the checkout ((pre-)authorization) via our server api
In the last step, you need to send the authorization token received by Klarna widget as part of the (pre-)authorization request to our server api.
→ Preauthorization/Authorization
General integration information
There are a few things you need to take care of, when integrating Klarna checkout in your shop.
- You need to make sure, that the customer didn't accidently clicked on a Klarna payment method, because you will want to start the checkout process and directly send customer data to Klarna via "start_session" call. So please implement another step where the customer needs to confirm his payment method choice (for example: "By selecting this payment method we will send personal data to Klarna. Please confirm".
- After confirmation of the payment method, you want to start with the first calls to server api as described above and then display the Klarna Widget. This Klarna Widget needs defined parameters to only display the chosen payment method, even if the widget is capable of displaying more than one Klarna payment method. For example after selecting "Klarna Pay Later", the widget should look something like this:
Anchor | ||||
---|---|---|---|---|
|
Request "generic start session" | ||||||||||||||||||||||||||||||||||
API parameter | Required | Comments | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
add_paydata[action] | + | identifies the request as one to start a new session
| ||||||||||||||||||||||||||||||||
add_paydata[merchant_data] | - | "EMD" - Extra Merchant Data - means that integration with any such package depends on (i) merchant’s offering and (ii) merchant’s technical possibilities. It is not to be interpreted in such a way that EMD is not required at all.
| ||||||||||||||||||||||||||||||||
amount | + |
| ||||||||||||||||||||||||||||||||
currency | + |
| ||||||||||||||||||||||||||||||||
firstname | + |
| ||||||||||||||||||||||||||||||||
lastname | + |
| ||||||||||||||||||||||||||||||||
company | - |
Submitting this parameter flags a transaction as B2B.
| ||||||||||||||||||||||||||||||||
title | - |
| ||||||||||||||||||||||||||||||||
street | + |
| ||||||||||||||||||||||||||||||||
zip | + |
| ||||||||||||||||||||||||||||||||
city | + |
| ||||||||||||||||||||||||||||||||
country | + |
| ||||||||||||||||||||||||||||||||
state | - |
| ||||||||||||||||||||||||||||||||
addressaddition | + |
| ||||||||||||||||||||||||||||||||
gender | o |
| ||||||||||||||||||||||||||||||||
ip | + |
| ||||||||||||||||||||||||||||||||
+ |
| |||||||||||||||||||||||||||||||||
telephonenumber | - |
| ||||||||||||||||||||||||||||||||
birthday | o | Mandatory for _____ ?
| ||||||||||||||||||||||||||||||||
language | + |
| ||||||||||||||||||||||||||||||||
- |
| |||||||||||||||||||||||||||||||||
shipping_lastname | - |
| ||||||||||||||||||||||||||||||||
addpaydata[shipping_title] | - | Title recipient within the delivery address
| ||||||||||||||||||||||||||||||||
shipping_company | - |
| ||||||||||||||||||||||||||||||||
shipping_street | - |
| ||||||||||||||||||||||||||||||||
shipping_zip | - |
| ||||||||||||||||||||||||||||||||
shipping_city | - |
| ||||||||||||||||||||||||||||||||
shipping_country | - |
| ||||||||||||||||||||||||||||||||
shipping_state | - |
| ||||||||||||||||||||||||||||||||
add_paydata[shipping_telephonenumber] | - | telephone number of the recipient or a contact at the delivery address
| ||||||||||||||||||||||||||||||||
addpaydata[shipping_email] | o | email-address of the recipient or a contact at the delivery address
This parameter is required if a shipping adress is given. | ||||||||||||||||||||||||||||||||
add_paydata[last_four_ssn] | - | Last four digits for customer social security number.
| ||||||||||||||||||||||||||||||||
add_paydata[organization_entity_type] | - | Only relevant for B2B transactions.
| ||||||||||||||||||||||||||||||||
add_paydata[organization_registry_id] | - | will be given to Klarna as "vat_id"
| ||||||||||||||||||||||||||||||||
personalid | o |
Mandatory for Denmark, Finland, Norway and Sweden | ||||||||||||||||||||||||||||||||
it[n] | + | Klarna item type
| ||||||||||||||||||||||||||||||||
id[n] | + |
AN..32 ? | ||||||||||||||||||||||||||||||||
pr[n] | + |
| ||||||||||||||||||||||||||||||||
no[n] | + |
| ||||||||||||||||||||||||||||||||
de[n] | + |
| ||||||||||||||||||||||||||||||||
va[n] | +? |
| ||||||||||||||||||||||||||||||||
add_paydata[klsid] | + | Mandatory for Klarna Installment (KLS): Campaign code |
Response "genericpayment - start_session" | ||||||||||||||||||
API parameter | Required | Comments | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
add_paydata[session_id] | + | Identifier for the started session at Klarna
| ||||||||||||||||
add_paydata[client_token] | + | Client token to authorize the session for payment via Klarna Widget
| ||||||||||||||||
add_paydata[authorized_payment_method] | + | Name of payment that got authorized for customer payment. (You will only receive the parameters according to the payment method you selected via clearingtype and financingtype) | ||||||||||||||||
add_paydata[payment_method_category_name] | + | Name of Klarna payment category Payment Method Category to show on the Payment Page.
currently only pay_later and pay_over_time are supported | ||||||||||||||||
add_paydata[payment_method_category_identifier] | + | Identifier for Klarna payment category
direct_debit is currently not supported | ||||||||||||||||
add_paydata[payment_method_category_asset_url_descriptive] | + | URL of Klarna payment category assets for descriptive design (payment method identified by small icon and test on badge)
| ||||||||||||||||
add_paydata[payment_method_category_asset_url_standard] | + | URL of Klarna payment category assets for standard design (payment method only identified by small icon on badge)
| ||||||||||||||||
status | + |
| ||||||||||||||||
APPROVED | ||||||||||||||||||
workorderid | + |
| ||||||||||||||||
ERROR | ||||||||||||||||||
errorcode | + |
| ||||||||||||||||
errormessage | + |
| ||||||||||||||||
customermessage | + |
|
Code Block |
---|
mid=23456 (your mid) portalid=12345123 (your portalid) key=abcdefghijklmn123456789 (your key) api_version=3.10 mode=test (set to „live“ for live-requests) request=preauthorization encoding=UTF-8 aid=12345 (your aid) clearingtype=fnc financingtype=KLS amount=3000 currency=EUR lastname=Approved firstname=Testperson-de salutation=Herr country=DE language=de gender=m add_paydata[action]=start_session birthday=19600707 street=Hellersbergstraße 14 city=Musterstadt zip=12345 email=youremail@email.com telephonenumber=01512345678 de[1]=for the feet id[1]=socks1 it[1]=goods no[1]=1 pr[1]=2340 va[1]=1900 _____________________________________________________ add_paydata[action]=start_session aid=111111 amount=2222 api_version=1.00 birthday=1958101 city=Neuss clearingtype=fnc country=DE currency=EUR de[1]=for ocean use only email=klarna@approved.de encoding=UTF-8 financingtype=KLS firstname=Testperson-de gender=m id[1]=boat66 it[1]=goods key=abcd12345698fffkfk language=de lastname=Approved mid=11111 mode=test no[1]=1 portalid=2011111 pr[1]=8540 request=genericpayment salutation=Herr street=Hellersbergstraße 14 telephonenumber=01522113356 va[1]=1900 zip=41460 |
Code Block |
---|
status=OK add_paydata[payment_method_category_asset_url_descriptive]=https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg add_paydata[client_token]=eyJhbGciOiJSUzI1NiJ9.ewogICJzZXNzaW9uX2lkIiA6ICI0N2EzNWIwOC1kNWVlLTcxYjUtOTVkMS1lYWU3NTFjNWJlZmIiLAogICJiYXNlX3VybCIgOiAiaHR0cHM6Ly9rbGFybmEtcGF5bWVudHMtZXUucGxheWdyb3VuZC5rbGFybmEuY29tIiwKICAiZGVzaWduIiA6ICJrbGFybmEiLAogICJsYW5ndWFnZSIgOiAiZW4iLAogICJwdXJjaGFzZV9jb3VudHJ5IiA6ICJERSIsCiAgInRyYWNlX2Zsb3ciIDogZmFsc2UsCiAgImVudmlyb25tZW50IiA6ICJwbGF5Z3JvdW5kIiwKICAibWVyY2hhbnRfbmFtZSIgOiAiWW91ciBidXNpbmVzcyBuYW1lIiwKICAic2Vzc2lvbl90eXBlIiA6ICJQQVlNRU5UUyIsCiAgImNsaWVudF9ldmVudF9iYXNlX3VybCIgOiAiaHR0cHM6Ly9ldnQucGxheWdyb3VuZC5rbGFybmEuY29tIiwKICAiZXhwZXJpbWVudHMiIDogWyBdCn0.gD6XVLaZeL541T1QYkGsZ01wbAYuTXyhIXcR8irG461U9w1HLugSji4_jc8LsE7cVWMVqLph_CJzCAiZNKzsC9AW6Mf88X8VdR9gV7owv3EVqEdK2K9-g-26Wu2pGE88Um2z2Iz7uUUzbhn6d4rI4CICOLsdaVXJ7MKhzPgnW-a6DM-K9JP2RLIflJKjn3wCjEtJSc_8gqj3_fv8YHaTWRkBd9pUGCBB0rUS-komFAPBdzZiCAbiw5Lsdk9dWpI2wszKeE_iPd6NuxGr4U37XtIX9Gc-uTfn21o0JUJddbiPtItmetWQSY_mruOO4WiVQxuZvxXk7XYwCCb8rrXYw add_paydata[payment_method_category_identifier]=pay_over_time add_paydata[session_id]=47a35b08-d5ee-71b5-95d1-eae751c5befb add_paydata[payment_method_category_name]=Slice it. add_paydata[payment_method_category_asset_url_standard]=https://x.klarnacdn.net/payment-method/assets/badges/generic/klarna.svg workorderid=WX1A37YBGD9D11DK _____________________________________________________ status=OK add_paydata[payment_method_category_name_3]=Slice it. add_paydata[payment_method_category_name_2]=Pay later. add_paydata[payment_method_category_name_1]=Direct debit add_paydata[session_id]=123-2227-456-avc11-fefe456 add_paydata[payment_method_category_identifier_3]=pay_over_time add_paydata[client_token]=W9uX2lkIiA6ICI3MGFjNGI3Ny0yMjI3LTdkNDEtY add_paydata[payment_method_category_identifier_2]=pay_later add_paydata[payment_method_category_asset_url_standard_2]=https://cdn.klarna.com/1.0/shared/image/generic/badge/en_us/pay_later/standard/pink.svg add_paydata[payment_method_category_asset_url_standard_1]=https://cdn.klarna.com/1.0/shared/image/generic/badge/en_us/pay_now/standard/pink.svg add_paydata[payment_method_category_asset_url_standard_3]=https://cdn.klarna.com/1.0/shared/image/generic/badge/en_us/slice_it/standard/pink.svg add_paydata[payment_method_category_asset_url_descriptive_3]=https://cdn.klarna.com/1.0/shared/image/generic/badge/en_us/slice_it/descriptive/pink.svg add_paydata[payment_method_category_asset_url_descriptive_2]=https://cdn.klarna.com/1.0/shared/image/generic/badge/en_us/pay_later/descriptive/pink.svg add_paydata[payment_method_category_asset_url_descriptive_1]=https://cdn.klarna.com/1.0/shared/image/generic/badge/en_us/pay_now/descriptive/pink.svg add_paydata[payment_method_category_identifier_1]=direct_debit workorderid=WX123456799 |
Anchor | ||||
---|---|---|---|---|
|
To update an order, you need to send a genericpayment-request with action=update. The call needs to provide the new list of items representing the complete shopping cart.
UI Text Box | ||
---|---|---|
| ||
|
Request "genericpayment - update" | |||||||||||||||||||||||
API parameter | Required | Comments | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
add_paydata[action] | + |
| |||||||||||||||||||||
add_paydata[reservation_txid] | + | Referencing the reservation (received from authorization.response -> add_paydata[reservation_txid]) | |||||||||||||||||||||
add_paydata[session_id] | + | Identifier for the started session at Klarna
| |||||||||||||||||||||
+ | Referencing the reservation (received from authorization.response -> add_paydata[workorderid])
| ||||||||||||||||||||||
country | + |
| |||||||||||||||||||||
amount | + |
| |||||||||||||||||||||
currency | + |
| |||||||||||||||||||||
financingtype | + |
| |||||||||||||||||||||
it[n] | + | Klarna item type
| |||||||||||||||||||||
id[n] | + |
AN..32 | |||||||||||||||||||||
pr[n] | + |
| |||||||||||||||||||||
no[n] | + |
| |||||||||||||||||||||
de[n] | + |
AN..50 | |||||||||||||||||||||
va[n] | + |
| |||||||||||||||||||||
narrative_text | - |
|
Response "genericpayment - update" | ||||||||||||||||||
API parameter | Required | Comments | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
status | + |
| ||||||||||||||||
APPROVED | ||||||||||||||||||
workorderid | + |
| ||||||||||||||||
ERROR | ||||||||||||||||||
errorcode | + |
| ||||||||||||||||
errormessage | + |
| ||||||||||||||||
customermessage | + |
| ||||||||||||||||
addresponsedata[reservation_txid] |
| |||||||||||||||||
addresponsedata[workorderid] |
| |||||||||||||||||
addresponsedata[authorized_payment_method] | Name of payment that got authorized for customer payment. (You will only receive the parameters according to the payment method you selected via clearingtype and financingtype) |
Anchor | ||||
---|---|---|---|---|
|
To update an order, you need to send a genericpayment-request with action=update. The call needs to provide the new list of items representing the complete shopping cart.
UI Text Box | ||
---|---|---|
| ||
|
Request "genericpayment - cancel_authorization"add_paydata[session_id] ? | ||
API parameter | Required | Comments |
---|---|---|
add_paydata[action] | + | cancel_authorization |
add_paydata[authorization_token] | + | Token of the authorization, which is to be canceled. Will be provided by Klarna's JS API |
Response "genericpayment - cancel_authorization" | ||||||||||||||||||
API parameter | Required | Comments | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
status | + |
| ||||||||||||||||
APPROVED | ||||||||||||||||||
workorderid | + |
| ||||||||||||||||
ERROR | ||||||||||||||||||
errorcode | + |
| ||||||||||||||||
errormessage | + |
| ||||||||||||||||
customermessage | + |
|
Anchor | ||||
---|---|---|---|---|
|
Request "preauthorization / authorization" | ||||||||||||||||||
API parameter | Required | Comments | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
firstname | + |
full address required and must match the shipping-address | ||||||||||||||||
lastname | + |
full address required and must match the shipping-address | ||||||||||||||||
company | - | If filled, the transaction is marked as B2B.
| ||||||||||||||||
street | + |
full address required and must match the shipping-address | ||||||||||||||||
zip | + |
full address required and must match the shipping-address | ||||||||||||||||
city | + |
full address required and must match the shipping-address | ||||||||||||||||
country | + |
full address required and must match the shipping-address | ||||||||||||||||
addressaddition | + |
mandatory for NL | ||||||||||||||||
gender | o |
mandatory for Austria, Germany and the Netherlands "d" is currently not supported by Klarna | ||||||||||||||||
ip | + |
| ||||||||||||||||
+ |
| |||||||||||||||||
telephonenumber | - |
| ||||||||||||||||
birthday | o |
mandatory for Austria, Germany and the Netherlands. | ||||||||||||||||
shipping_firstname | - |
| ||||||||||||||||
shipping_lastname | - |
| ||||||||||||||||
shipping_company | - |
| ||||||||||||||||
shipping_street | - |
| ||||||||||||||||
shipping_zip | - |
| ||||||||||||||||
shipping_city | - |
| ||||||||||||||||
shipping_country | - |
| ||||||||||||||||
personalid | o |
Mandatory for Denmark, Finland, Norway and Sweden | ||||||||||||||||
it[n] | + | Klarna item type
| ||||||||||||||||
id[n] | + |
| ||||||||||||||||
pr[n] | + |
| ||||||||||||||||
no[n] | + |
| ||||||||||||||||
de[n] | + |
| ||||||||||||||||
va[n] | + |
| ||||||||||||||||
add_paydata[klsid] | o | Mandatory for Klarna Installment (KLS): Campaign code |
Code Block |
---|
add_paydata[authorization_token]=aaa-bbbb-11111-2222-ccc aid=12346 amount=8540 api_version=3.10 backurl=https://meine.test.url.de/Checkout/back birthday=19600707 city=Neuss clearingtype=fnc country=DE currency=EUR de[1]=for ocean use only email=klarna@approved.de encoding=UTF-8 errorurl=https://meine.test.url.de/Checkout/error financingtype=KLS firstname=Testperson-de gender=m id[1]=boat66 it[1]=goods key=e123dc456a language=de lastname=Approved mid=12345 mode=test narrative_text=0123456789012345678901234567890123456789 no[1]=1 portalid=2000123 pr[1]=8540 reference=R15595689952007 request=authorization salutation=Herr street=Hellersbergstraße 14 successurl=https://meine.test.url.de/Checkout/success telephonenumber=01522113356 va[1]=1900 zip=41460 |
Response "preauthorization / authorization" | ||
API parameter | Required | Comments |
---|---|---|
add_paydata[workorderid] | + | Klarna Invoice: Workorder ID, used for update calls (cart updates) |
add_paydata[reservation_txid] | + | Klarna Invoice: Reservation ID, used for update calls (cart updates) |
Code Block |
---|
redirecturl=https://klarna-payments-eu.playground.klarna.com/v1/sessions/aaa-bbbb-11111-2222-ccc/redirect status=REDIRECT txid=30343747 userid=7890123 |
Capture
Request "capture" | ||||||||||||||||||||||||||||||||||
API parameter | Required | Comments | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
capturemode | + | Parameter capturemode is mandatory to indicate whether this capture will be the last one. (Default: completed)
| ||||||||||||||||||||||||||||||||
settleaccount | + | Parameter settleaccount is mandatory to indicate whether a refund to the customer should be initiated. (Default: yes)
| ||||||||||||||||||||||||||||||||
amount | + |
| ||||||||||||||||||||||||||||||||
currency | + |
| ||||||||||||||||||||||||||||||||
narrative_text | - |
| ||||||||||||||||||||||||||||||||
items | - |
| ||||||||||||||||||||||||||||||||
de[n] | + |
| ||||||||||||||||||||||||||||||||
no[n] | + |
| ||||||||||||||||||||||||||||||||
id[n] | - |
| ||||||||||||||||||||||||||||||||
it[n] | - |
| ||||||||||||||||||||||||||||||||
va[n] | + |
| ||||||||||||||||||||||||||||||||
pr[n] | + |
| ||||||||||||||||||||||||||||||||
addpaydata[shipping_info_shipping_company_n] | - | Name of the shipping company (as specific as possible).
| ||||||||||||||||||||||||||||||||
addpaydata[shipping_info_shipping_method_n] | - | Shipping method.
| ||||||||||||||||||||||||||||||||
addpaydata[shipping_info_tracking_number_n] | - | Tracking number for the shipment.
| ||||||||||||||||||||||||||||||||
addpaydata[shipping_info_tracking_uri_n] | - | URI where the customer can track their shipment.
| ||||||||||||||||||||||||||||||||
addpaydata[shipping_info_return_shipping_company_n] | - | Name of the shipping company for the return shipment (as specific as possible).
| ||||||||||||||||||||||||||||||||
addpaydata[shipping_info_return_tracking_uri_n] | - | URL where the customer can track the return shipment.
| ||||||||||||||||||||||||||||||||
addpaydata[shipping_delay] | - | Delay before the order will be shipped. Use for improving the customer experience regarding payments. This field is currently not returned when reading the order. Please note: to be able to submit values larger than 0, this has to be enabled in your merchant account. Please contact Klarna for further information.
|
Response "capture" | ||
API parameter | Required | Comments |
---|---|---|
clearing_instructionnote | o |
|
Debit / Refund
Request "debit" | ||||||||||
API parameter | Required | Comments | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
settleaccount | + | Parameter settleaccount is mandatory to indicate whether a refund to the customer should be initiated. (Default: yes)
|
Request "refund" | ||||||||||
API parameter | Required | Comments | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
amount | + |
| ||||||||
currency | + |
| ||||||||
narrative_text | - |
| ||||||||
items (following parameters for item n ) | - | In general a refund is processable without article data. But if you give any article data, then the whole set of parameters ahs to be given. | ||||||||
de[n] | + |
| ||||||||
no[n] | + |
| ||||||||
id[n] | - |
| ||||||||
pr[n] | + |
| ||||||||
it[n] | + |
| ||||||||
va[n] | + |
|
If you're using vouchers in your checkout, and want to partial refund items, you do have 2 options to do this:
- send a debit-request with the items using the original amount without any discounts and send a additional item as voucher, with an amount that sums up all discounts
- example cart with auth
- item 1; red car; 20 €
- item 2; green truck; 30 €
- item 3; voucher -10€ (-5€ discount on both items)
- example cart with debit/refund
- item 1; red car; 20 €
- item 2; voucher -5€ (15€ for one item will be returned)
- example cart with auth
- send a debit-request with the items using an reduced amount, so that the whole discount is broken down on every item.
- example cart with auth
- item 1; red car; 20 €
- item 2; green truck; 30 €
- item 3; voucher -10€ (-5€ discount on both items)
- example cart with debit/refund
- item 1; red car; 15 € (15€ for one item will be returned)
- example cart with auth
Anchor | ||||
---|---|---|---|---|
|
the follwing integration steps are taken from Klarna documentation ( https://developers.klarna.com/documentation/klarna-payments/integration-guide/present-klarna-widget )
After creating a new session, you want to present the klarna widget to your customer. This widget allows you to present all 3 payment methods offered by Klarna to the customer or define what payment method should be presented to the customer. This is
UI Steps | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Table of Contents | ||||
---|---|---|---|---|
|