Place order from customer token
This document describes how to place an order using a Kustom customer token.
Overview
If you want to charge a customer using a Kustom customer token, you must place an order as described below. The previously created Kustom customer token can be used to charge the customer at any time. This is done by creating an order using the customer token ID and the required order data. Order lines containing recurring subscription items require a subscription object. You can automatically capture the order by setting the auto_capture
flag to true
(default is false
).
Request
To place an order using a customer token, make a POST request to /customer-token/v1/tokens/{customerToken}/order
with the following JSON data:
POST /customer-token/v1/tokens/{customerToken}/order
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
"merchant_reference1": "45aa52f387871e3a210645d4",
"merchant_data": "optional string",
"locale": "de-DE",
"auto_capture": true,
"purchase_currency": "EUR",
"order_amount": 999,
"order_tax_amount": 0,
"order_lines": [
{
"type": "digital",
"subscription": {
"name": " Premium Monthly {{1234834}}",
"interval": "MONTH",
"interval_count": 1
},
"reference": "19-402",
"name": "Streaming Service Monthly - Free Trial",
"quantity": 1,
"unit_price": 999,
"tax_rate": 0,
"total_amount": 999,
"total_discount_amount": 0,
"total_tax_amount": 0
}
]
}
Important Note: Use the correct token ID to ensure the correct consumer is billed.
Responses
Success Response
A successful order placement will return a JSON response like this:
{
"order_id": "a89ec121-1276-419d-882a-c343d58fd1bc",
"fraud_status": "ACCEPTED"
}
Error Response
Error responses include an error code, error messages, and a correlation ID for troubleshooting. Possible error codes are listed in the table below:
Error Code | HTTP Status Code | Comment |
---|---|---|
TOKEN_NOT_FOUND | 404 | Customer token not found. |
TOKEN_SUSPENDED | 403 | Token suspended by Klarna. |
TOKEN_CANCELLED | 403 | Token cancelled. |
TOKEN_FORBIDDEN | 403 | Forbidden token usage. |
UNAVAILABLE_PAYMENT_METHOD | 403 | Payment method unavailable. |
PAYMENT_METHOD_CURRENCY_MISMATCH | 403 | Payment method not available for the order currency. |
PAYMENT_METHOD_FAILED | 403 | Payment method failed. |
BAD_REQUEST | 400 | Bad request. |
INTERNAL_SERVER_ERROR | 500 | Internal server error. |
SERVICE_UNAVAILABLE | 503 | Klarna service unavailable. |
This table is intended to be a partial list of possible errors.