Skip to main content

Developer Documentation

Klarna

Klarna Pay Later allows customer to split up their payments into several rates. If you have setup a Klarna agreement on the Acquiring page in Billwerk + administration the payment option will automatically be presented in Billwerk + Checkout.

Note the Klarna payment option is only presented if the currency is supported by Klarna.

Creating a Klarna checkout session

NOTICE: It is a Klarna requirement that you send in order lines for a Klarna Payment. It allows for an accurate calculation of VAT per item in the basket and will give a more detailed Klarna invoice.

A billing address is required by Klarna. Note that it is not sufficient to reference a customer object. You will have to explicitly set a billing address field on the order-object of the charge call.

Sample request

Shell

curl -X POST \
  --url https://checkout-api.reepay.com/v1/session/charge \
  -u 'priv_xxxx:' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
    "order": {
        "customer_handle": "cust-0001",
        "handle": "klarna-test-1",
        "currency": "DKK",
        "order_lines":[
          {
            "ordertext":"Order text",
            "amount": 1000,
            "vat": 0.25,
            "quantity":1,
            "amount_incl_vat": "true"
          }],
        "settle":false,
        "billing_address":{
          "address":"Strøget 15",
          "city":"Hornbæk","country":"DK",
          "email":"test@test.dk","first_name":"Gorm","last_name":"Bøgh",
          "postal_code":"3100","phone":"12345678"
        }
  }
}'
Klarna as only payment option

If you would like Klarna to be presented as the only option in Billwerk + Payments Checkout, you can use the payment_methods parameter in the create session call. This will automatically expand the Klarna payment option.

Sample

Shell

curl -X POST \
  --url https://checkout-api.reepay.com/v1/session/charge \
  -u 'priv_xxxx:' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{
    "payment_methods": ["klarna_pay_later"],
    "order": {
        "customer_handle": "cust-0001",
        "handle": "klarna-test-1",
        "currency": "DKK",
        "order_lines":[
          {
            "ordertext":"Order text",
            "amount": 1000,
            "vat": 0.25,
            "quantity":1,
            "amount_incl_vat": "true"
          }],
        "settle":false,
        "billing_address":{
          "address":"Strøget 15",
          "city":"Hornbæk","country":"DK",
          "email":"test@test.dk","first_name":"Gorm","last_name":"Bøgh",
          "postal_code":"3100","phone":"12345678"
        }
  }
}'
Custom arguments

Custom arguments can be passed to Klarna in the optional session_data object. These data are only stored for the duration of the checkout session.

Parameter

Description

ssn

Optional value containing the customer's social security number.

Test of Klarna

In order to test Klarna before going live, you can create a Klarna "Playground" account. This provides you with a test API username and test API key. Billwerk + Payments support can setup a Klarna test acquiring agreement on your Billwerk + Payments test account. Klarna provides test data in order to test both the success case ("approved") and rejections of payments.

The test credentials can be found here:

https://developers.klarna.com/documentation/testing-environment/sample-data/

with a page for each country, e.g. for Denmark :

https://developers.klarna.com/documentation/testing-environment/sample-data/dk/

Klarna - Pending orders

Billwerk+ Payments does not support Klarna's "pending" state. This state indicates a payment at a later stage will either be accepted or rejected.

Pending Klarna orders will simply be rejected by the Billwerk+ Payments system.