15min

Place an Order

Note: You can also follow this guide in Postman by using the appropriate requests and environment variables for the headers.



So far you have been able to view all the Merchants available for your application, view their catalog of products and select one specific product. Here you will learn how to go through the entire flow of purchasing a product through Violet. To get started with the Checkout process, we will create a cart and add products to it. For this section, we have taken the SKU that we retrieved details for in Interact with Catalogs.

So far in this Recipe we have viewed available merchants, seen what they have to offer, and selected the product we want to buy. We will now imagine we are a shopper, P. Sherman living on 42 Wallaby Way, Sydney, actually purchasing this product through your Application using Violet.

Create Cart

Note: For more details on this endpoint please refer to the API Reference



Cart creation begins the checkout process. Products can be added to the cart at creation with a JSON Body listing 1 or more sku_id & quantity pairs.



Note: It is not required that you add a SKU to create a cart, since it is possible for your customers cart to be empty, however, in this example, we will purchase a product with the SKU 10064 (which we noted down from the previous section)



Get a cake by its ID
GET
Params
Body Parameters
required
String
ID of the cake to get

As seen above, the cart has now been created with the product of our choosing (SKU: 10064, GoPro Quadcopter). You may be wondering what a "bag" is in the response -- since Violet let's you sell products across different Merchants, during the checkout process we bucket each Merchant's products together in "Bags". Violet Applications do not need to worry about this concept and neither do your shoppers.

Now that the cart is created and the customer is ready to start the checkout process, the next steps is collecting customer information and applying it to the cart. Save the Cart Id from the Create Cart resposne. In the example above, this is id: 20956

Apply Customer Info

Note: For more details on this endpoint please refer to the API Reference



Once you have a cart with products in it you need to apply the customer information. For a brand new customer this would likely include Apply Guest Customer to Cart , Set Shipping Address , and Set Billing Address.



Though for the sake of ease in this Recipe we will simply address handling and use the same address for billing and shipping and pass this through the body of the request. For more details on what fields this API can take, refer to the documentation linked above. In this example, we have used the cart we created in the previous step. Your Cart Id will be different and need to be updated in the request below.

Using same_address: true we can set the shipping and billing address simultaneously.

Get a cake by its ID
GET
Params
Body Parameters
required
String
ID of the cake to get

With the customer info applied we can go onto getting the shipping methods for each bag within the cart. Our test cart here only has one bag. Since Violet (and hence, your application) lets your customers purchase across various Merchants, think of a bag as a section of your cart for one specific merchant.

Get Shipping Method

Once the Shipping and Billing Address are set, then you can get the shipping methods available for a cart (and bags within the cart).



Get a cake by its ID
GET
Params
Body Parameters
required
String
ID of the cake to get

For more information on this endpoint go to Get Available Shipping Methods



Choose your shipping method and apply it!

Apply Shipping Method

Once we have all the available shipping methods for the bags within the cart, you can select and apply them to the cart.



Note: Your bag_id and cart_id will be different from the example you have been following so far. Please update the calls with your information.

Get a cake by its ID
GET
Params
Body Parameters
required
String
ID of the cake to get

For more information on this endpoint go to Set Shipping Methods

Now that shipping address, billing address and shipping method have all been taken care of, we can move onto payments. Here you'll be able to show your customer the final order for review and enter their payment information. You can read more about how payments work in Violet here Payments.

Payment Info

Set the payment method for your customer. In this example, we have used a sample credit card available through https://stripe.com/docs/testing.



Note: Setting complete_checkout: true will submit the cart immediately. Though it is often best to let the customer confirm and review all their info, then Submit it with the Submit Cart endpoint.



Get a cake by its ID
GET
Params
Body Parameters
required
String
ID of the cake to get

The response above is our final order and gives your customer the chance to review their cart, along with shipping information, payment information and product details. Notice how all the fields have now been populated, including credit card details. To confirm this order, all that's left is to Submit the cart!

Submit Cart

For this example we didn't price our cart at any point. This is probably an important thing for you customers though go check out how it works Price Cart .





Get a cake by its ID
GET
Params
Body Parameters
required
String
ID of the cake to get

Fun fact: Cart ID's turn into Order ID's, carrying the same ID across the entire lifecycle of an order from creation to completion.

For more information on this endpoint go to Submit Cart

And you're done! You have now successfully placed an order through Violet and have a happy customer, all without having to integrate with any downstream merchant yourself. Your customer will now receive their purchase directly from the merchants and all payments to both you and the merchant will be handled for you by Violet. You can see the details of this sale on your Violet application dashboard.

Although we've done a lot already, this is only the start to what Violet can offer your application. We also have Webhooks to provide shipping updates; browsing through product categories to better showcase which products are available to buy; and Violet Connect, a simple wizard that lets you directly add any new merchant to your application. For a complete list of APIs we have to offer and more information on the ones you've interacted with, please refer to our API Reference pages.

You can also read more about Violet on our Blog or Send us an email to get a demo or learn more about how we can work together!



Updated 01 Jun 2022
Did this page help you?
Yes
No