Update session

To update an existing session, refer back to the session you initiated with Create session. The fields totalOrderAmount, totalOrderVatAmount, and totalOrderAmountExclVat are essential for the update.

If you’re adding new order lines, ensure you also update the corresponding total amounts as demonstrated in the following example. Be aware that adding new order lines will clear out any existing ones in the session, replacing them with the newly provided lines.

curl -X POST 
-H 'authorization: Bearer v4.public.eyJpc3MiOiJs...' 
-H 'content-type: application/json' 
-d '{
  "orderLines": [
    {
      "description": "Coffee Machine X200",
      "quantity": 10,
      "reference": "111-222-333",
      "totalAmount": 500000,
      "totalVatAmount": 100000,
      "type": "physical",
      "unitDiscountAmount": 0,
      "unitPrice": 50000,
      "vat": 2500
    },
    {
      "description": "Shipping fee",
      "quantity": 1,
      "reference": "444-555-666",
      "totalAmount": 10000,
      "totalVatAmount": 2000,
      "type": "shippingFee",
      "unitDiscountAmount": 0,
      "unitPrice": 10000,
      "vat": 2500
    }
  ],
  "totalOrderAmount": 510000,
  "totalOrderAmountExclVat": 408000,
  "totalOrderVatAmount": 102000
}'
https://api.sandbox.ledyer.com/v1/payment-sessions/:sessionId

Path parameters

sessionId string
The session ID string that was obtained when the order session was [created](/docs/payment-products/payments/create-session).

Request body

country string Optional
Country code such as `SE`, `FI` etc (ISO 3166-1 alpha-2).
currency string Optional
Example `SEK`, `NOK` (ISO 4217 alpha).
locale string Optional
Specify language for the payments application, `sv-SE`, `da-DK` etc (BCP 47).
metadata object Optional
Merchant may send a key/value object literal for internal use. Example: { "property1": "value1", "property2": "value2" }.
orderLines array Optional
An array of order lines.
Show child attributes
description string
Product name, description etc.
quantity integer
An integer from 1 to 99,999,999, inclusive.
reference string Optional
SKU or product reference.
totalAmount integer
Total amount in minor units.
totalVatAmount integer
Total VAT amount in minor units.
type string
Type of order line: `physical`, `shippingFee`, `discount`, `giftCard`.
unitDiscountAmount integer Optional
Discount per unit in minor units.
unitPrice integer
Price per unit in minor units.
vat integer
VAT rate in minor units (e.g., 2500 for 25%).
reference string Optional
This property can be used for merchant order reference and will be visible on the invoice. Maximum of 50 characters.
settings object Optional
An object containing various setting possibilities.
Show child attributes
security object Optional
Show child attributes
level integer Optional
Security level. Allowed values: `100`, `110`, `120`, `200`, `210`, `220`, `300`, `400`.
settlementReference string Optional
Maximum of 50 characters.
totalOrderAmount integer
Total order amount in minor units.
totalOrderAmountExclVat integer
Total order amount excl. VAT in minor units.
totalOrderVatAmount integer
Total order VAT amount in minor units.
{
	"createdAt": "2022-02-13T21:15:52.597247Z",
	"customer": {
		"billingAddress": {
			"attentionName": "Åke anställd",
			"careOf": "",
			"city": "Solna",
			"companyName": "Rocket 4",
			"country": "SE",
			"postalCode": "999 33",
			"streetAddress": "Gatan 99"
		},
		"companyId": "559311-3714",
		"email": "jan@example.com",
		"firstName": "Jan",
		"lastName": "Persson",
		"invoiceChannel": {
			"destination": "default",
			"details": "",
			"type": "email"
		},
		"paymentMethod": {
			"type": "invoice"
		},
		"phone": "+46761010101",
		"reference1": "ref1",
		"reference2": "ref2",
		"shippingAddress": {
			"attentionName": "Gunnar Larsson",
			"careOf": "",
			"city": "Luleå",
			"companyName": "Pelles Tak",
			"contact": {
				"email": "micke.mottagare@email.com",
				"firstName": "Micke",
				"lastName": "Mottagare",
				"phone": "123456789"
			},
			"country": "Sweden",
			"postalCode": "333 33",
			"streetAddress": "Sommargatan 33"
		}
	},
	"expiresAt": "2023-02-20T21:15:52.597247Z",
	"id": "ps_1xE2fCIbZXHqB2tZctuZGlyCKnQ",
	"merchantId": "ac_1xRXHKwBNxnbzMeJfy2olPJEKP7",
	"order": {
		"country": "SE",
		"currency": "SEK",
		"externalSessionId": "123456789",
		"locale": "sv-SE",
		"metadata": {
			"foo": "bar"
		},
		"orderLines": [
			{
				"description": "Coffee Machine X200",
				"quantity": 10,
				"reference": "111-222-333",
				"totalAmount": 500000,
				"totalVatAmount": 100000,
				"type": "physical",
				"unitPrice": 50000,
				"vat": 2500
			},
			{
				"description": "Shipping fee",
				"quantity": 1,
				"reference": "444-555-666",
				"totalAmount": 10000,
				"totalVatAmount": 2000,
				"type": "shippingFee",
				"unitPrice": 10000,
				"vat": 2500
			}
		],
		"reference": "A1B2C3D",
		"settings": {
			"security": {
				"level": 300
			},
			"urls": {
				"notification": "http://www.example.com/notification"
			}
		},
		"settlementReference": "ABC123XYZ456",
		"totalOrderAmount": 510000,
		"totalOrderVatAmount": 102000,
		"totalOrderAmountExclVat": 408000
	},
	"signState": "unauthSign",
	"state": "open",
	"storeId": "421423100",
	"updatedAt": "2023-02-13T21:15:52.597247Z"
}

Handling sessions

The sessionId should be stored and re-used until the purchase has been completed or the expiresAt time has been reached.