Place order from Klarna customer token

If you want to charge a customer using a Klarna customer token, you must place an order as described below.

Date: 11.07.2019

The Klarna customer token created previously can be used to charge the customer at any time. The customer is charged by creating an order using the customer token. This is done by calling the customer token API with the customer token ID and data of order to be created.

The order can be automatically captured at the time of creation by setting the auto_capture flag to true (default is false).

Note: You must use the correct token ID when placing an order, to ensure that the right consumer gets billed.

Request

See the following example for placing an order from a customer token

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
POST /customer-token/v1/tokens/{customerToken}/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json

{
    "merchant_reference1": "45aa52f387871e3a210645d4",
    "merchant_data": "optional string",
    "locale": "sv-SE",
    "auto_capture": true,
    "purchase_currency": "SEK",
    "order_amount": 9900,
    "order_tax_amount": 0,
    "order_lines": [{
        "type": "digital",
        "reference": "ABC123",
        "name": "Premium package",
        "quantity": 1,
        "unit_price": 9900,
        "tax_rate": 0,
        "total_amount": 9900,
        "total_discount_amount": 0,
        "total_tax_amount": 0
    }]
}

Responses

Success response format

1
2
3
4
{
    "order_id": "a89ec121-1276-419d-882a-c343d58fd1bc",
    "fraud_status": "ACCEPTED"
}

Error response format

1
2
3
4
5
{
    "error_code" : "ERROR_CODE",
    "error_messages" : ["Array of error messages"],
    "correlation_id" : "Unique id for this request used for troubleshooting."
}
Error CodeHTTP status codeComment
Error Code
TOKEN_NOT_FOUND
HTTP status code
404
Comment
The customer token ID used to trigger order placement could not be found.
Error Code
TOKEN_SUSPENDED
HTTP status code
403
Comment
The purchase token has been suspended by Klarna.
Error Code
TOKEN_CANCELLED
HTTP status code
403
Comment
The purchase token has been cancelled by you.
Error Code
TOKEN_FORBIDDEN
HTTP status code
403
Comment
Customer token usage forbidden, e.g. by this merchant ID.
Error Code
UNAVAILABLE_PAYMENT_METHOD
HTTP status code
403
Comment
Payment method type is not available, e.g. card token has failed
Error Code
PAYMENT_METHOD_CURRENCY_MISMATCH
HTTP status code
403
Comment
The payment method of the token is not available for the currency of the order.
Error Code
PAYMENT_METHOD_FAILED
HTTP status code
403
Comment
Purchase for payment method failed. If a credit payment method was used, most likely due to the consumer being rejected. You can try again for PAYMENT_METHOD_FAILED errors.
Error Code
BAD_REQUEST
HTTP status code
400
Comment
The purchase token has been cancelled by you.
Error Code
INTERNAL_SERVER_ERROR
HTTP status code
500
Comment
Internal server error. You can wait and try again soon.
Error Code
SERVICE_UNAVAILABLE
HTTP status code
503
Comment
Purchase failed because of a temporary internal Klarna error. You can try again for a 503.