Introduction
The Klarna Dynamic store assets API is the interface for all our widgets and services, such as the Part Payment Widget, KPM checkout service, etc.
This reference guide will allow you to dive into the details of our API for even more control of your integration.
Live environment access information
To use the Dynamic store assets API, you need live API credentials. Please contact your integration sales representative.
Host: api.klarna.com port: 443
Digest
A digest is a cryptographic hash function that takes a block of data and returns a fixed-size bit string. The digest is used to verify the integrity of the call as well as to identify the caller, and sent in as a base64 encoded string.
Note: the string is formatted to hexadecimal before encoding.
Supported hashing algorithms are, in descending order of recommendation:
- SHA-256
Methods
Checkout Page
To show available payment methods on a checkout page using invoice and part payment.
Digest
Consists of the xmlrpc client version followed by values from merchant_id, currency code and secret (in this order) separated with a colon without the square brackets. The format for the constructing the correct header is:
Authorization: \{XMLRPC-VERSION\} \{DIGEST\}
The complete header would look like this:
Authorization: xmlrpc-4.2 xZWJjNjI5NmRlZjEwZThmMzE1MA==
Only a proprietary Klarna authentication scheme is supported. The table below, shows what to replace the placeholder values with.
{XMLRPC-VERSION} | xmlrpc-4.2 |
{DIGEST} | base64encode(hex(sha256("[merchant_id]:[currency]:[shared_secret]"))) |
The DIGEST formula is broken down to the following components.
merchant_id | The unique number that identifies your e-store |
currency_code | The three letter uppercase currency of your store, based on ISO 4217. Currencies supported at this time are: EUR, NOK, SEK |
shared_secret | This is the shared secret key assigned to your merchant_id by Klarna |
Request
After the header has been created, an HTTP GET request must be made and sent along with the header. This is what the HTTP GET request looks like:
https://api.klarna.com/touchpoint/checkout/?merchant_id=<strong>[merchant_id]</strong>¤cy=<strong>[currency]</strong>&locale=<strong>[locale]</strong>&total_price=<strong>[total_price]</strong>
* Required
Variable | Type | Description |
---|---|---|
Variable merchant_id * | Type int | Description The unique number that identifies your e-store |
Variable total_price * | Type int | Description Total price of the purchase, in cents, e.g. 500.00 kr == 50000 |
Variable currency * | Type string | Description Currency used for the purchase. Currency codes are defined in ISO 4217. |
Variable locale * | Type string | Description Locale used when displaying texts. It is a ISO 639 language code and a ISO 3166-1 alpha-2 country code, e.g. sv_se |
Example
1 2 3 4 5
GET /touchpoint/checkout/?merchant_id=0¤cy=SEK&locale=sv_se&total_price=1000000 HTTP/1.1 Host: api.klarna.com Accept: application/vnd.klarna.touchpoint-checkout.payment-methods-v1+json Authorization: xmlrpc-4.2 xZWJjNjI5NmRjEwZThmMzE1MA== User-Agent: curl/7.35.0
1 2 3 4 5
GET /touchpoint/checkout/?merchant_id=0¤cy=EUR&locale=de_de&total_price=10000 HTTP/1.1 Host: api.klarna.com Accept: application/vnd.klarna.touchpoint-checkout.payment-methods-v1+json Authorization: xmlrpc-4.2 xZWJjNjI5NmRjEwZThmMzE1MA== User-Agent: curl/7.35.0
1 2 3 4 5
GET /touchpoint/checkout/?merchant_id=0¤cy=EUR&locale=fi_fi&total_price=10000 HTTP/1.1 Host: api.klarna.com Accept: application/vnd.klarna.touchpoint-checkout.payment-methods-v1+json Authorization: xmlrpc-4.2 xZWJjNjI5NmRjEwZThmMzE1MA== User-Agent: curl/7.35.0
Response
The response will be a JSON envelope structure with a list of payment methods. And a payment method will have the following fields:
Field | Type | Description |
---|---|---|
Field pclass_id | Type number | Description The pclass id number. This is to be used in the reserveAmount call. |
Field name | Type string | Description Name of the payment option in English. |
Field terms.uri | Type string | Description Absolute URL to the terms for this payment method |
Field logo.uri | Type string | Description Absolute URL to the logo used for this payment method |
Field title | Type string | Description Title to display for payment option |
Field extra_info | Type string | Description Detailed information about payment option |
Field group.code | Type string | Description Payment option group |
Field use_case | Type string | Description Calculation example of payment option |
Field details | Type object | Description Breakdown of fees and various information to be used by merchant as he see fit |
Field details.interest_rate.value | Type string | Description Interest rate for payment option |
Field details.monthly_pay.value | Type string | Description Calculated monthly payment. Value is displayed in localized format depending on the locale that is sent in the parameters. |
Field details.months.value | Type number | Description Number of installments for payment option. |
Field details.month.value | Type string | Description The localised name of the month |
Field details.annual_percentage_rate.value | Type string | Description Calculated annual percentage rate. |
Field details.montly_invoice_fee.value | Type string | Description Monthly administrator invoice fee |
Field details.total_credit_purchase_price.value | Type string | Description The total amount that is payable for this purchase, including starting fee, administrative fees and interest rates |
Field details.start_fee.value | Type string | Description The start fee of the instalment |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
HTTP/1.1 200 OK Connection: close Content-Length: 1002 Content-Type: application/vnd.klarna.touchpoint-checkout.payment-methods-v1+json; charset=utf-8 Date: Thu, 17 Jul 2014 14:29:00 GMT ETag: W/"612-3862573905" Server: nginx { "payment_methods": [ { "pclass_id": 100, "name": "Account", "logo": { "uri": "https://cdn.klarna.com/1.0/shared/image/generic/logo/de_de/basic/blue-black.png" }, "terms": { "uri": "https://cdn.klarna.com/1.0/shared/content/legal/terms/0/de_de/account" }, "group": { "code": "part_payment" }, "details": { "annual_percentage_rate": { "value": "11,95" }, "interest_rate": { "value": "14,79" }, "monthly_invoice_fee": { "value": "0,45" }, "setup_fee": { "value": "0" }, "monthly_pay": { "value": "44,86" }, "months": { "value": 3 }, "month": { "value": "august" }, "total_credit_purchase_cost": { "value": "1145" } }, "title": "Flexible Laufzeit – Raten und Laufzeit selbst bestimmen", "extra_info": "...", "use_case": "..." } ] }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
HTTP/1.1 200 OK Connection: close Content-Length: 1002 Content-Type: application/vnd.klarna.touchpoint-checkout.payment-methods-v1+json; charset=utf-8 Date: Thu, 17 Jul 2014 14:29:00 GMT ETag: W/"612-3862573905" Server: nginx { "payment_methods": [ { "pclass_id": 100, "name": "Account", "logo": { "uri": "https://cdn.klarna.com/1.0/shared/image/generic/logo/sv_se/basic/blue-black.png" }, "terms": { "uri": "https://cdn.klarna.com/1.0/shared/content/legal/terms/0/sv_se/account" }, "group": { "code": "part_payment" }, "details": { "annual_percentage_rate": { "value": "11,1" }, "interest_rate": { "value": "19,9" }, "monthly_invoice_fee": { "value": "29" }, "setup_fee": { "value": "0" }, "monthly_pay": { "value": "583" }, "months": { "value": 3 }, "month": { "value": "augusti" }, "total_credit_purchase_cost": { "value": "11 458" } }, "title": "Konto - delbetala i din egen takt", "extra_info": "...", "use_case": "..." } ] }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
HTTP/1.1 200 OK Connection: close Content-Length: 1002 Content-Type: application/vnd.klarna.touchpoint-checkout.payment-methods-v1+json; charset=utf-8 Date: Thu, 17 Jul 2014 14:29:00 GMT ETag: W/"612-3862573905" Server: nginx { "payment_methods": [ { "pclass_id": 100, "name": "Account", "logo": { "uri": "https://cdn.klarna.com/1.0/shared/image/generic/logo/fi_fi/basic/blue-black.png" }, "terms": { "uri": "https://cdn.klarna.com/1.0/shared/content/legal/terms/0/fi_fi/account" }, "group": { "title": "Erämaksu", "code": "part_payment" }, "details": { "annual_percentage_rate": { "label": "todellinen vuosikorko", "value": "1,31", "symbol": "%" }, "interest_rate": { "label": "vuosikorko", "value": "0,00", "symbol": "%" }, "monthly_invoice_fee": { "label": "hallinnointimaksu", "value": "2,95", "symbol": "€" }, "start_fee": { "label": "perustamismaksu", "value": "0,00", "symbol": "€" }, "monthly_pay": { "label": "kuukausierä", "value": "208,33", "symbol": "€" }, "total_credit_purchase_price": { "label": "luoton kokonaissumma", "value": "5 073,75", "symbol": "€" } }, "title": "Joustava Erämaksu - maksa omaan tahtiin", "extra_info": "...", "use_case": "..." } ] }
Errors
If for whatever reason the HTTP request results in an error, the JSON output will indicate the error.
Example
</Locale>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
HTTP/1.1 401 Unauthorized Server: nginx Date: Fri, 18 Jul 2014 12:57:16 GMT Content-Type: application/vnd.klarna.error-v1+json; charset=utf-8 Connection: close Content-Length: 212 ETag: W/"bd-1819756749" { "http_status_code": 401, "http_status_message": "Unauthorized", "internal_code": "12 dry toads kissed jovially", "internal_message": "Failed to authenticate", "public_code": "unauthorized" }
Payment method service is currently only supported in Finland, Germany, Sweden and Norway.