Skip to main content

Create order session

This is the initial point in the lifecycle of an order. A successful request response will contain a sessionId and an orderId string. The sessionId will be needed later for rendering the checkout iframe. The orderId will be used for fetching and updating the order session etc. When the end customer has succesfully completed the checkout flow and the order session is in state authorized, the system will yield an order entity managed by the /orders endpoint.

curl -X POST \
-H 'authorization: Bearer v4.public.eyJpc3MiOiJs...' \
-H 'content-type: application/json' \
-d '{
"autoCapture": {
"delayMinutes": 10080,
"enabled": true
},
"country": "SE",
"currency": "SEK",
"customer": {
"companyId": "559311-3714",
"email": "jane.doe@example.com",
"firstName": "Jane",
"lastName": "Doe",
"phone": "0700000000",
"reference1": "",
"reference2": "",
"ssn": ""
},
"locale": "sv-SE",
"metadata": {},
"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
}
],
"reference": null,
"settings": {
"customer": {
"allowShippingAddress": false,
"showNameFields": false,
"showShippingAddressContact": false
},
"security": {
"level": 300,
"requireClientValidation": false
},
"urls": {
"confirmation": null,
"notification": null,
"privacy": null,
"terms": "https://www.example.com/terms.html",
"validate": null
}
},
"storeId": null,
"totalOrderAmount": 510000,
"totalOrderAmountExclVat": 408000,
"totalOrderVatAmount": 102000
}'
https://api.sandbox.ledyer.com/v1/sessions

Request body

autoCapture

objectOptional

An object consisting of the properties delayMinutes and enabled, delayMinutes must be a number between 0 and 10080 (7 days), enabled is a boolean. Example: { "delayMinutes": 100808, "enabled": true }.

country

string

Country code such as SE, FI etc (ISO 3166-1 alpha-2).

currency

string

Example SEK, NOK (ISO 4217 alpha).

customer

objectOptional

All customer information.

locale

string

Specify language for the checkout, sv-SE, da-DK etc (BCP 47).

metadata

objectOptional

Merchant may send a key/value object literal for internal use. Example: { "property1": "value1", "property2": "value2" }.

orderLines

array of orderlinesOptional

An array of order lines.

reference

stringOptional

This property can be used for merchant order reference and will be visible on the invoice. Maximum of 50 characters.

settings

object

An object containing various setting possibilities.

settlementReference

stringOptional

Maximum of 50 characters.

source

stringOptional

A string that should either be pos or online.

storeId

stringOptional

Only needed in case of multiple stores with same country and currency.

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.