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.

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": {
      "confirmation": "https://example.com?sessionId={session.id}&authorizationToken={authorization.token}",
      "cancel": "https://example.com",
      "notification": "https://example.com",
      "privacy": "https://www.example.com/privacy_policy.html",
      "terms": "https://www.example.com/terms.html"
    }
  },
  "storeId": null,
  "totalOrderAmount": 510000,
  "totalOrderAmountExclVat": 408000,
  "totalOrderVatAmount": 102000
}'
https://api.sandbox.ledyer.com/v1/payment-sessions

Request body

country string
Country code such as `SE`, `FI` etc (ISO 3166-1 alpha-2).
currency string
Example `SEK`, `NOK` (ISO 4217 alpha).
locale string
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
An array of order lines.
Show child attributes
description string
Product name, description etc.
quantity integer
Non negative number.
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
An object containing various setting possibilities.
Show child attributes
level integer Optional
Security level (100-500). Higher values require more verification.
requireClientValidation boolean Optional
Whether client-side validation is required.
validationSuccessOnTimeout boolean Optional
Whether to treat timeout as successful validation.
urls.confirmation string Optional
The landing page for when a user has completed the flow. If not provided the user will stay on the same page while the Ledyer payments dialog is closing down. The following placeholders can be included in the url: {session.id} and {authorization.token}.
urls.cancel string Optional
The user will be redirected to this page when clicking cancel, this is only for hosted payment page.
urls.notification string Optional
This url will be used to notify the the merchant's ERP-system/e-commerce platform that something has happened to an order.
urls.privacy string Optional
Merchant privacy policy that will be visible and linked in the sign page in case a signatory needs to sign the purchase. Optional since this information can be included in the terms link as well.
urls.terms string
Merchant terms that will be visible and linked in the sign page in case a signatory needs to sign the purchase.
storeId string Optional
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.
{
	"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.