Creating session
When the customer has added all their items to the cart, and proceeded to the checkout, it's time to create a session in the Dintero system.
A session contains a representation of the order: the amount, currency and items, as well as the configured payment methods, and urls for redirects and callbacks.
Authentication
To authenticate, you create a Checkout API client and use the credentials to Create an access token. The same client can be used for Sandbox mode and production.
For all requests to the API set the following header:
Authorization: Bearer {access_token}
Create session request
The session is created with an HTTP POST-request to https://checkout.dintero.com/v1/sessions-profile
.
Set Content-Type: application/json
and the authorization header.
Most new accounts should have the
default
profile_id available. If you have an old account, go here to learn how to create one.
{
"url": {
"return_url": "https://example.com/thankyou",
"callback_url": "https://example.com/callback"
},
"order": {
"amount": 33890,
"currency": "NOK",
"merchant_reference": "merchants_order_number",
"items": [
{
"id": "chair-1",
"line_id": "1",
"description": "Stablestol",
"quantity": 1,
"amount": 29990,
"vat_amount": 6000,
"vat": 25
}
],
"shipping_option": {
"id": "local-pick-up-point",
"line_id": "local-pick-up-point",
"amount": 3900,
"operator": "",
"title": "Pick up at a pick-up point",
"delivery_method": "pick_up"
}
},
"express": {
"shipping_options": [],
"shipping_address_callback_url": "https://example.com/shipping_address_changed"
},
"profile_id": "default"
}
Amounts are denoted in the smallest unit for the currency, for example cents.
- 299.90 NOK becomes 29990
- 299 NOK becomes 29900
To learn more about the fields, check out the complete documentation for the create session-endpoint.
Once the session is created, you can proceed with showing the checkout to the customer.