Create session
The journey of an order starts here. When you make the initial API call to create a session, a successful response will return a sessionId along with the necessary details to showcase Ledyer as a payment option.
The session will expire after 7 days.
- Example Request
- Example Response
curl -X POST \
-H 'authorization: Bearer v4.public.eyJpc3MiOiJs...' \
-H 'content-type: application/json' \
-d '{
"country": "SE",
"currency": "SEK",
"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": "",
"settings": {
"security": {
"level": 300
},
"urls": {
"notification": ""
}
},
"storeId": null,
"totalOrderAmount": 510000,
"totalOrderAmountExclVat": 408000,
"totalOrderVatAmount": 102000
}'
https://api.sandbox.ledyer.com/v1/payment-sessions
Request body
country
stringCountry code such as SE
, FI
etc (ISO 3166-1 alpha-2).
currency
stringExample SEK
, NOK
(ISO 4217 alpha).
locale
stringSpecify language for the payments application, sv-SE
, da-DK
etc (BCP 47).
metadata
objectOptionalMerchant may send a key/value object literal for internal use.
Example: { "property1": "value1", "property2": "value2" }
.
orderLines
array of orderlinesOptionalAn array of order lines.
reference
stringOptionalThis property can be used for merchant order reference and will be visible on the invoice. Maximum of 50 characters.
settings
objectAn object containing various setting possibilities.
storeId
stringOptionalOnly needed in case of multiple stores with same country and currency.
totalOrderAmount
integerTotal order amount in minor units.
totalOrderAmountExclVat
integerTotal order amount excl. VAT in minor units.
totalOrderVatAmount
integerTotal order VAT amount in minor units.
{
"configuration": [
{
"assets": {
"urls": {
"logo": "https://www.example.com/logo.png"
}
},
"name": "Faktura",
"description": "Betala inom 30 dagar",
"type": "invoice"
}
],
"expiresAt": "2023-19-01T11:25:32.805672147Z",
"sessionId": "ps_1xDXf4JI3PJsGeVAvLE3hHqYS09"
}
Response Headers
Location
string/v1/payment-sessions/:sessionId
Handling sessions
The sessionId
string should be stored and re-used until the purchase has been authorized or the expiresAt
time has been reached.