Starting a checkout from a session
In order to start a checkout attempt, you will need to supply Brink with the desired capabilities to use that are available from the current session.
curl --url 'https://shopper.eu-west-1.{env}.brinkcommerce.io/shopper/sessions/checkout/start' \
--header 'Authorization: {token}' \
--header 'Content-Type: application/json' \
--data '{
"paymentProvider": { "name":"KlarnaCheckout", "id":"kco-test" },
"shippingProvider": { "name":"Ingrid", "id":"ingrid-test" }
}'
This will return a checkout that contains a new token (JWT) and a snapshot of the current session items and evaluated discount rules Response
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJicmlua2NvbW1lcmNlLXNob3BwZXIiLCJleHAiOjE2Nzg5NjIwNTgsImlhdCI6MTY3NjM3MDA1OCwianRpIjoiNTk3MDQ3YzktZTU4OS00NzJjLWFiMmItNWViNTY0ZDY4NzZiIiwic2Vzc2lvbklkIjoiNTk3MDQ3YzktZTU4OS00NzJjLWFiMmItNWViNTY0ZDY4NzZiIiwic3RvcmVHcm91cElkIjoiYnJpbmtjb21tZXJjZSIsImNvdW50cnlDb2RlIjoiU0UiLCJjdXJyZW5jeUNvZGUiOiJTRUsiLCJsYW5ndWFnZUNvZGUiOiJzdiIsImlzVGF4SW5jbHVkZWRJblByaWNlIjoidHJ1ZSIsImNoZWNrb3V0SWQiOiJlYzQxY2JiMi05NjNhLTQ0MDItYmVmNC05YTQxYWRlZDlkODcifQ.Tro0ef9z0OLcLxTLeg-pUY1r_qrffoaOhgQiK0OesjE",
"checkout": {
"id": "ec41cbb2-963a-4402-bef4-9a41aded9d87",
"sessionId": "597047c9-e589-472c-ab2b-5eb564d6876b",
"cartRevision": 2,
"storeGroupId": "brinkcommerce",
"countryCode": "SE",
"currencyCode": "SEK",
"languageCode": "sv",
"discountCodes": [],
"isTaxIncludedInPrice": true,
"created": "2023-02-14T10:20:58.712402549Z",
"updated": "2023-02-14T10:20:58.712402549Z",
"items": [
{
"id": "2a566bf4-997f-49ad-b924-0fda42ebafdd",
"productVariantId": "t-shirt-1.S",
"productParentId": "t-shirt-1",
"quantity": 1,
"name": "T-Shirt",
"displayName": "T Shirt",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac lorem efficitur, interdum justo ac, fermentum metus. Pellentesque porttitor sit amet ipsum ut blandit. Duis quis sagittis lorem. Praesent venenatis hendrerit nunc luctus commodo",
"displayDescription": "Suspendisse a porta diam, at congue metus. Nam sollicitudin augue lorem, id elementum massa luctus id. Phasellus facilisis ex sed massa posuere, ut dapibus erat fringilla. Ut mauris orci, consequat sit amet arcu vitae, ullamcorper fringilla sapien. Sed ac nunc ante.",
"taxGroupId": "apparel",
"basePriceAmount": 50000,
"salePriceAmount": 50000,
"discountAmount": 0,
"totalPriceAmount": 50000,
"totalTaxAmount": 10000,
"taxPercentage": 2500,
"totalDiscountAmount": 0,
"taxPercentageDecimals": 2,
"imageUrl": "http://P.wrihNyaaIjjzulhV+YBiPl,RsEHnqO2kTiReoG,hWqWT",
"customAttributes": [
{ "key": "color", "value": "black" },
{ "key": "size", "value": "S" }
],
"tags": [
{ "key": "category", "value": "t-shirt" },
{ "key": "size", "value": "S" }
]
}
],
"shippingOptions": [],
"discountAmount": 0,
"capabilities": {
"paymentProvider": { "id": "kco-test", "name": "KlarnaCheckout" },
"shippingProvider": {
"id": "ingrid-test",
"name": "Ingrid",
"config": { "baseUrl": "https://api-stage.ingrid.com" }
}
},
"totals": { "subTotal": 50000, "taxTotal": 10000, "discountTotal": 0, "shippingTotal": 0, "grandTotal": 50000 }
}
}
A Brink Session can have multiple Brink Checkout attempts
Checkout capabilities
Now, in order to interact with the started checkout attempt, you need to use the new checkout token for the specific provider APIs.
For instance ShopperIngrid, and ShopperKlarnaCheckout
In our example above we started our checkout with the shipping provider Ingrid, so we start an Ingrid session connected to the Brink Checkout
curl --url 'https://shopper.eu-west-1.{env}.brinkcommerce.io/shopper-ingrid/sessions/create' \
--header 'Authorization: {token}' \
--header 'Content-Type: application/json' \
--data '{
"ingrid": {
"locales": [
"sv-SE"
],
}
}'
Continuing from our example, we need to create a Klarna Checkout Order for our Brink Checkout
curl --url 'https://shopper.eu-west-1.{env}.brinkcommerce.io/shopper-kco/orders' \
--header 'Authorization: {token}' \
--header 'Content-Type: application/json' \
--data '{
"klarna": {
"merchant_urls": {
"terms": "https://merchant.com/terms",
"confirmation": "https://example.com/confirmation",
"checkout": "https://merchant.com/checkout"
}
}
}'