Klarna Docs - Create a one-time payment order

Create a one-time payment order

Once Klarna authorizes the purchase, use the authorization token to create an order and complete the one-time payment.

Create an order

To create an order for a one-time payment, send a POST request to the {apiUrl}/payments/v1/authorizations/{authorizationToken}/order endpoint and include authorization_token in the path.

For example, if the authorization_token is b4bd3423-24e3, send your request to the {apiUrl}/payments/v1/authorizations/b4bd3423-24e3/order endpoint.

JSON
{
    "purchase_country": "US",
    "purchase_currency": "USD",
    "billing_address": {
        "given_name": "John",
        "family_name": "Doe",
        "email": "john@doe.com",
        "title": "Mr",
        "street_address": "Lombard St 10",
        "street_address2": "Apt 214",

A POST request to create an order for a one-time payment.

Success response

When you receive a success response, the customer gets charged and the Klarna payments session is closed.

As part of the response, you receive the following details:

  • order_id, an order identifier that you can later use to capture or refund the order using the Order management API
  • redirect_url, a URL to which you redirect the customer. This isn't included in the response received if you didn't include the URL when initiating a payment
  • fraud_status, an indicator of whether the transaction is suspected to be legitimate or fraudulent
  • authorized_payment_method, the payment method selected by your customer for this purchase
JSON
{
    "order_id": "3eaeb557-5e30-47f8-b840-b8d987f5945d",
    "redirect_url": "https://payments.klarna.com/redirect/...",
    "fraud_status": "ACCEPTED",
    "authorized_payment_method": "invoice"
}

A success response to the order creation request for a one-time payment.

Send the customer browser to redirect_url provided in the response. Klarna places a cookie in the browser and redirects the customer back to the confirmation URL you provided when creating the session. This makes the checkout faster the next time the customer chooses to pay with Klarna.

Error response

If your request doesn't pass our validation, you'll receive an error response. The most common reasons why creating an order fails are:

  • placing the order more than 60 minutes after authorization
  • modifying purchase details after authorization without updating the payment session
JSON
  {
      "correlation_id": "6a9b1cb1-73a3-4936-a030-481ba4bb203b",
      "error_code": "ERROR_CODE",
      "error_messages": [
          "ERROR_MESSAGE"
      ]
  }

An error response to the order creation request for a one-time payment.

Here are examples of common errors with troubleshooting suggestions. You can use the value in correlation_id to find entries related to the request under Logs in the Merchant portal.

Error codeError messageDescription
NOT_FOUNDInvalid authorization tokenThe authorization token has expired because the order was placed more than 60 minutes after authorization. To fix the error, request a new authorization_token and use it to place the order.
BAD_VALUENot matching fields: [billing_address.postal_code]The data shared with Klarna in a previous step (create_session, load(), or authorize()) have been modified causing the validation to fail.
BAD_VALUENot matching fields: [Incorrect number of items in the cart. Expected: 2, Actual: 3]The order lines or the cart were updated after the authorize() call. Please ensure that the cart is kept as-is or send a new authorization request.
REJECTEDRejectedThis is an edge case reason, but can be triggered in case the merchant is configured with being allowed to update the cart. This could be updated from the authorize to the place order in such a way that a new authorize is triggered. In this case this is rejected.

Pending fraud status

If your agreement with Klarna allows it, we can flag a suspicious transaction for an additional review instead of accepting it immediately. In such cases, fraud_status in the response will be PENDING instead of ACCEPTED. Read more about pending orders.

JSON
{
    "order_id": "3eaeb557-5e30-47f8-b840-b8d987f5945d",
    "redirect_url": "https://payments.klarna.com/redirect/...",
    "fraud_status": "PENDING",
    "authorized_payment_method":"invoice"
}

A response to a create order request includes fraud_status: PENDING if a transaction is subject to additional fraud review.

If your Klarna contract allows automatic capture of the order once an order is created, set auto_capture  to true when creating the order.