Checkout Totals
POSThttps://api.shopbonsai.ca/orders/checkout
Generates information for the checkout page including taxes, totals, and shipping price. This endpoint will return up-to-date price. If the price changed, the user should be notified. The returned inventory is always equal to the requested quantity, and it is not reserved. Inventory check will be done at the time of order placement only.
Request
- application/json
Body
required
shipping_address object
products object[]required
payment object
target_currency string
Possible values: [CAD
, USD
, GBP
, AUD
, EUR
]
The currency to return values in.
Responses
- 200
- 400
- 401
- 404
- 5XX
Success
- application/json
- Schema
- Example (from schema)
Schema
data object
{
"data": {
"subtotal": 12.5,
"tax": 1.63,
"shipping": [
{
"amount": 15,
"label": "Standard Flat Rate Shipping",
"code": "0",
"merchant_name": "Virgin Club",
"products": [
{
"public_id": "clad6pg5z00eu012gfz7hfm92",
"variant_id": "M00679529706740",
"quantity": 1
}
]
}
],
"total": 12.25,
"duties": 12.25,
"line_items": [
{
"public_id": "clad6pg5z00eu012gfz7hfm92",
"variant_id": "M00679529706740",
"inventory": 2,
"price": 12.5,
"quantity": 2,
"name": "Joelle Sweater Dress"
}
],
"currency": "USD",
"payment": {
"clientSecret": "string"
},
"shipping_total": 120.2
}
}
400 - Bad request
- application/json
- Schema
- Example (from schema)
Schema
data object
errors object[]
{
"data": {
"subtotal": 0,
"tax": 0,
"shipping": [],
"total": 0,
"duties": 0,
"line_items": [
{
"public_id": "clad6pg5z00eu012gfz7hfm92",
"variant_id": "M00679529706740",
"inventory": 0,
"price": 0,
"quantity": 2,
"name": ""
}
],
"currency": "USD",
"payment": {
"clientSecret": "string"
},
"shipping_total": 0
},
"errors": [
{
"id": "123e4567-e89b-12d3-a456-426655440000",
"status": 400,
"code": "PRODUCT_UNAVAILABLE",
"title": "The product requested is no longer available",
"detail": {
"publicId": "clbj0i7w4041d01z60hv53mcm",
"variantId": "13833901"
}
}
]
}
401 - Unauthorized
- application/json
- Schema
- Example (from schema)
Schema
errors object[]
{
"errors": [
{
"status": 401,
"detail": "",
"title": "Authentication information is missing or invalid"
}
]
}
404 - Not found
- application/json
- Schema
- Example (from schema)
Schema
data object
errors object[]
{
"data": {
"subtotal": 0,
"tax": 0,
"shipping": [],
"total": 0,
"duties": 0,
"line_items": [
{
"public_id": "clad6pg5z00eu012gfz7hfm92",
"variant_id": "M00679529706740",
"inventory": 0,
"price": 0,
"quantity": 2,
"name": ""
}
],
"currency": "USD",
"payment": {
"clientSecret": "string"
},
"shipping_total": 0
},
"errors": [
{
"id": "123e4567-e89b-12d3-a456-426655440000",
"status": 404,
"code": "PRODUCT_DOES_NOT_EXIST",
"title": "Product does not exist",
"detail": {
"publicId": "clad6pg5z00ru012gfz7hfm92",
"variantId": "M00679529706740"
}
}
]
}
500 - Unknown error
- application/json
- Schema
- Example (from schema)
Schema
errors object[]
{
"errors": [
{
"status": 500,
"detail": "",
"title": "Unknown error"
}
]
}
- curl
- python
- go
- nodejs
- ruby
- csharp
- php
- java
- powershell
- CURL
curl -L -X POST 'https://api.shopbonsai.ca/orders/checkout' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'API-Key: <API_KEY_VALUE>' \
--data-raw '{
"shipping_address": {
"first_name": "Eddy",
"last_name": "Bonsai",
"address1": "351 E 103rd St",
"address2": "Whitecastle",
"city": "New York",
"country": "US",
"name": "Eddy Bonsai",
"province": "NY",
"phone": "555-625-1199",
"zip": "10029"
},
"products": [
{
"public_id": "clad6pg5z00eu012gfz7hfm92",
"variant_id": "M00679529706740",
"quantity": 1
}
],
"payment": {
"paymentMethod": "stripe",
"requestPaymentIntent": true
},
"target_currency": "USD"
}'
ResponseClear