Checkout API - Hands-on Lab

Lesson 8 of 26 · 45 min

Checkout API

Allows for a checkout to be created from an existing cart using BigCommerce checkout logic. The existing BigCommerce front-end cart/checkout can be bypassed.In this activity, you will use the Checkout API to view and modify the details of a checkout using an API REST client.

In this lab, you will:

  • GET a checkout
  • Add checkout billing address
  • Update checkout billing address
  • Add consignment to checkout
  • Update checkout consignment
  • Add coupon to checkout
  • Delete checkout coupon
  • Create an order
  • Delete checkout consignment

Prerequisites

  • BigCommerce store (sandbox or live)
  • API credentials for the store
  • REST client (Postman)
  • Completion of previous lab

GET a Checkout

  1. Open Postman
  2. Click the No Environment dropdown in the upper-right
  3. Select the environment you created in the previous lab
  4. Copy and** paste**the request below into Postman
https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkout_id}

If you created your environment correctly in the previous lab, {{store_hash}} will use your store’s store hash automatically.

  1. Replace {checkout_id} with a cart/checkout ID
  2. Select GET next to the request url
  3. Click Send button
  4. Observe response and copy a line item ID for next steps

Image

Add Checkout Billing Address

  1. Copy and paste the request below into Postman
https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkout_id}/billing-address
  1. Replace {checkout_id} with the Checkout ID from the previous steps
  2. Copy and paste the code below into the Body section of Postman
{
"first_name": "Jane",
"last_name": "Doe",
"email": "jane@email.com",
"address1": "123 Main Street",
"address2": "",
"city": "Austin",
"state_or_province": "Texas",
"state_or_province_code": "TX",
"country_code": "US",
"postal_code": "78751",
"phone": "1234567890"
}
  1. Select POST next to the request url
  2. Click the Send button
  3. Observe response and copy the address ID

Image

Update Checkout Billing Address

  1. Copy and paste the request below into Postman
https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkout_id}/billing-address/{address_id}
  1. Replace {checkout_id} with a cart/checkout ID
  2. Replace {address_id} with a cart/checkout ID
  3. Copy and paste the code below into the body section of Postman
{
"email": "jenny@email.com",
"phone": "5128675309"
}
  1. Select PUT next to the request url
  2. Click the Send button
  3. Observe response

Image

Add Consignment to Checkout

  1. Copy and paste the request below into Postman
https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkout_id}/consignments?include=consignments.available_shipping_options

If you created your environment correctly in the previous lab, {{store_hash}} will use your store’s store hash automatically.

  1. Replace {checkout_id} with a cart/checkout ID
  2. Copy and paste the code below into the Body section of Postman
[
{
"shipping_address": {
"email": "bob@email.com",
"country_code": "US",
"first_name": "Bob",
"last_name": "Ross",
"address1": "123 Main Street",
"city": "Austin",
"state_or_province": "Texas",
"state_or_province_code": "TX",
"postal_code": "78751",
"phone": "5555555555"
},
"line_items": [
{
"item_id": "{item_id}",
"quantity": 1
}
]
}
]
  1. Replace {item_id} with the item ID copied in previous steps
  2. Select POST next to the request URL
  3. Click the Send button
  4. Observe response and copy consignment ID and shipping option ID

Image

Update Checkout Consignment

  1. Copy and paste the request below into Postman
https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkout_id}/consignments/{consignment_id}
  1. Replace {checkout_id} with a cart/checkout ID
  2. Replace {consignment_id} with a consignment ID
  3. Copy and** paste** the code below into the body section of Postman
{
"shipping_option_id": "{shipping_option_id}"
}
  1. Replace {shipping_option_id} with the shipping option ID
  2. Select PUT next to the request url
  3. Click the send button
  4. Observe response

Image

Add Coupon to Checkout

  1. Copy and paste the request below into Postman
https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkout_id}/coupons
  1. Replace {checkout_id} with a cart/checkout ID
  2. Copy and paste the code below into the Body section of Postman
{
"coupon_code": {coupon_code}
}
  1. Replace {coupon_code} with a valid coupon code from the store
  2. Select POST next to the request URL
  3. Click the Send button
  4. Observe response and coupon added

Image

Delete Checkout Coupon

  1. Copy and paste the request below into Postman
https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkout_id}/coupons/{coupon_code}
  1. Replace {checkout_id} with a cart/checkout ID
  2. Replace {coupon_code} with a valid coupon from the store
  3. Select DELETE next to the request url
  4. Click the Send button
  5. Observe response

Image

Create an Order

  1. Copy and paste the request below into Postman
https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkout_id}/orders
  1. Replace {checkout_id} with a cart/checkout ID
  2. Select POST next to the request URL
  3. Click the Send button
  4. Observe response and order created

Image

Delete Checkout Consignment

  1. Copy and paste the request below into Postman
https://api.bigcommerce.com/stores/{{store_hash}}/v3/checkouts/{checkout_id}/consignments/{consignment_id}
  1. Replace {checkout_id} with a cart/checkout ID
  2. Replace {consignment_id} with a consignment ID
  3. Select DELETE next to the request url
  4. Click the Send button
  5. Observe response

Image