Update the Klarna Payments session

You could update the Klarna Payments session with new details, in case something in the order has been changed and the checkout reloaded. Including if the consumer adds a new item to the cart or if consumer details are updated.

Date: 11.07.2019

Updating a session is done by making a server-side POST call to update session using the same payload structure as when creating the session in the first place.

Best Practice: For the effects of the update to be shown, you must also update the client separately through doing a new load-call.

This could also be achieved by only doing a client-side load-call , with the updated details.

Example request

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
POST /payments/v1/sessions/068df369-13a7-4d47-a564-62f8408bb760
Authorization: Basic pwhcueUff0MmwLShJiBE9JHA==
Content-Type: application/json

{
  "order_amount": 998,
  "order_tax_amount": 0,
  "order_lines": [{
      "type": "physical",
      "reference": "19-315",
      "name": "Battery Power Pack",
      "quantity": 2,
      "unit_price": 499,
      "tax_rate": 0,
      "total_amount": 998,
      "total_discount_amount": 0,
      "total_tax_amount": 0
  }]
}

This call will update the existing Klarna session, and has an empty reply when successful.

Example Successful Response

The response will be an empty object with a status.

1
2
HTTP/1.1 204 No content
Content-Type: application/json

Example Error Responses

1
2
3
4
5
6
7
{
    "correlation_id":	"6a9b1cb1-73a3-4936-a030-481ba4bb203b",
    "error_code":	"ERROR_CODE",
    "error_messages":	[
        "ERROR_MESSAGE"
    ]
}

Best practice: You can use the correlation_id to troubleshoot the call in the logs app in merchant portal.

Example error messages

Below you will see some common error messages.

Error CodeError messageComment
Error Code
BAD_VALUE
Error message
Bad value: order_tax_amount
Comment
If you enter any tax for orders, this is validated as described in this article. This validation is not passed in case this error message is thrown.
Error Code
BAD_VALUE
Error message
Bad value: order_lines
Comment
All order lines are validated as seen in this article. If your added order lines do not follow our guidelines, we will throw an error referring to the specific part of an order line that has failed.
Error Code
BAD_VALUE
Error message
Bad value: purchase_currency
Comment
In case a purchase_currency is wrongly formatted or doesn’t apply in a certain locale this error message is thrown. If the consumer has updated country through changing billing_country this might also arise.
Error Code
NOT_FOUND
Error message
Invalid session id
Comment
The session you attempted to update is not valid anymore. Or the ID is incorrectly formatted.