Skip to main content

Checkout API

After the customer has finished interacting with their cart and they're ready to check out, you need to convert the cart object into a checkout with checkout specific information.

Create Checkout

POST /checkouts
{
"cartId": "7e81c14b-893d-4c98-b92a-da0f7ccf732b",
"shippingAddress": {
"id": "ed8b291c-d7e6-4d5c-82cb-0febbe9218cc"
// Alternatively, provide an Address Object
}
}
{
"checkoutId": "bb0f2c30-9770-410a-a680-a5363a395eab",
"totals": {
"subtotal": 3333157,
"tax": 466543,
"shipping": 20000,
"total": 3819800
},
}

Important: your totals may be different than the totals from your cart as they may include updated shipping costs or price changes.

Inventory Mismatch

If an inventory mismatche happened when creating a checkout, you will receive this response:

{
"checkoutId": "bb0f2c30-9770-410a-a680-a5363a395eab",
"totals": {
"subtotal": 3333157,
"tax": 466543,
"shipping": 20000,
"total": 3819800
},
"cartChanges": {
// Either 'prices' or 'quantity' or 'price_and_quantity'
"type": "prices",
"newCart": {
"cartId": "76865281-2bb9-4326-87dd-b8fec80db4a3",
"products": [
// An aray of the Product Objects
],
"currency": "EGP",
"totals": {
"subtotal": 3333157,
"tax": 466543,
"total": 3799800
}
},
"differences": [
{
"productId": "c7d038eb-6b01-4116-92f5-6de418fa1ce7",
"quantityChange":-3,
"newQuantity": 0,
"priceChange": 0,
"newPrice": 20000
}
]
}
}

If the type of the cartChanges is quantity (or price_and_quantity) and any product in cartChanges.differences is 0, you need to inform the user his item are out of stock and whether they want to continue the checkout with this new cart.

If they wish to continue with the new cart, you need to provide the new cart id (cartChanges.newCart.cartId).

If cartChanges.type is prices can need to ask the customer whether they want to continue this checkout with the new prices. If they decide to continue the same checkout with the new prices, you will also need to provide the new cartChanges.newCart.cartId to the checkout endpoint.