Creating a Klarna Customer Token results in Klarna storing customer and payment method details. You can later used the token_id shared with you to trigger purchases for the Klarna customer token.
After having obtained anĀ authorization_tokenĀ for a successful authorization, this can be used to create a purchase token instead of placing the order.
Since a purchase token has no order lines and amount connected to it, there is no need to charge the customer at this point. Instead the purchase token will be used to charge consumer at a later stage, which can be read inĀ a separate article.
POST /payments/v1/authorizations/{authorizationToken}/customer-token
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json
{
"purchase_country": "SE",
"locale": "sv-SE",
"billing_address" : {
"given_name": "Doe",
"family_name": "John",
The response will contain a redirect URL to which the user should be redirected. The user will bounce through Klarna and be redirected to the confirmation URL provided in the API calls.
Example successful response
HTTP/1.1 200 OK
Content-Type: application/json
Klarna-Correlation-Id: e19dc121-1276-419d-882a-c343d58fb9aa
{
"billing_address": {
"attention": "string",
"city": "Beverly Hills",
"country": "US",
If there is an error with the request, the response will follow the standard error-format of Klarna. Below is a description of the most common error reasons.
{
"correlation_id": "6a9b1cb1-73a3-4936-a030-481ba4bb203b",
"error_code": "ERROR_CODE",
"error_messages": [
"ERROR_MESSAGE"
]
}
Below are the most common error codes and what they mean.
Error Code | Error messages | Comment |
---|---|---|
NOT_FOUND | Invalid authorization token | This is returned if order is placed after the authorization token has expired. Please ensure the order is placed within 60 minutes of the authorization. |
BAD_VALUE | Bad value: purchase_country | The country of the billing address is different from that of the purchase_country of the session. Causing a mismatch |
BAD_REQUEST | X is not valid for creating customer tokens in Y | The payment method X is not available for tokenization in country Y. |