Lab - Postman Quote and Order Workflow
Lab - Postman Quote and Order Workflow
Lab - Postman Quote and Order Workflow
In this lab, you’ll construct a Postman workflow to simulate some of the common quote and order tasks a back-end integration might be concerned with.
In order to complete checkout, you’ll need to make sure you have the appropriate minimal store configuration in place for shipping and payments.
If you’ve previously configured shipping and payment options for your store, you won’t need to do any additional setup.
We won’t walk through the details of configuring your store settings, but make sure you have:
The lab will involve logging in as a company user, creating, and submitting a quote-based order. The following minimal settings are required in the B2B Edition section of your control panel:
As a reminder, your work in previous labs should have resulted in the following Postman configuration, which will be important for the following exercise steps:
v3_token, store_hash, and storefront_channel_idAccept, Content-Type, and authTokenFor the steps ahead, you’ll need the ability to log into your storefront with the credentials for an Admin user associated with a company.
If the only company users you have in your store so far are those you created via the API in previous labs, then these customers do not yet have a password set. (Typically, a password would be set by the customer after receiving a welcome email.) If this is the case, set a password in the control panel:
In the BigCommerce control panel, navigate to Customers and then to the customer associated with the email address of your company’s Admin user.
Set a password for the customer and save.
You’ll also need to have quote requests submitted within the past 7 days. If your store doesn’t contain any such quote requests, submit a request now from your storefront:
Browse to your storefront URL and log in with the credentials of a company user.
Navigate to a product page and use the “Add to quote” button to add the product to your request.
Use the “Open Quote” link in the success message, or browse to Account > Quotes and select the draft quote.
Submit the quote.
In this step, you’ll create requests to fetch all requests for quote from within the last 7 days, as well as fetch the details of a specific quote.
Create a new HTTP request and save it to your collection with the name “Get Recent RFQs.”
Configure the request with the following details.
In the Params tab, add the following Query Params.
Make sure to include {{quote_ min_created_at}} exactly as it appears, including the braces. You may note that this references a variable that has not been created yet on the environment or collection. In this case, you’ll be creating a Pre-request script that will generate an appropriate “7 days ago” timestamp each time the request is run.
The status filter param also ensures that only quote requests that are newly created and have not yet been acted on by a sales rep.
Try out the effects of other filter params as well, including company, limit, offset, maxCreated, minExpired and maxExpired, minModified and maxModified, sortBy, orderBy, and quoteNumber.
In the Scripts tab, enter the following “Pre-request” code (not “Post-response” as usual).
This script calculates a timestamp for 7 days before the current time and sets the quote_min_created_at variable you’ve already referenced in the request’s filters. Feel free to set a different number of days.
In the Scripts tab, enter the following “Post-response” code.
Note that in addition to tests, this script captures the ID of the first quote in the results set in the collection variable quote_id. This will be used to automatically set the context of subsequent requests.
Send the requests, verify that all tests succeed, and verify that the quote_id variable has been set on the collection.
Next, you’ll create a request for the details of the first quote in the previous results set. (Alternatively, you can edit the quote_id variable directly on your collection to specify a different quote ID.)
Create a new HTTP request and save it to your collection with the name “Get Quote Details.”
Configure the request with the following details.
In the Scripts tab, enter the following “Post-response” code.
Send the request and verify that all tests succeed.
At this step, you may choose to log into your BigCommerce control panel and edit the chosen quote in the B2B Edition admin - for example, to set a discount on one or more items in the quote. (Be sure to “Preview” and then “Submit” the quote.) A typical workflow would involve a sales rep making such edits before integration steps like the requests you’ll create next.
Try re-running the previous two requests to see the impact of edits to the data in the response. (Remember that the status filter on “Get Recent RFQs” must be removed to fetch a quote that has now been edited.)
Create a new HTTP request and save it to your collection with the name “Export Quote PDF.”
Configure the request with the following details.
In the Scripts tab, enter the following “Post-response” code.
Send the request and verify that all tests succeed.
Copy the URL value from the response and enter it in a browser to verify that the URL results in downloading a PDF with the details of the quote.
In this step, you’ll use an API request to generate a URL that will create a BigCommerce checkout from the chosen quote. While company users have the ability to check out with a quote from the front-end Buyer Portal at any time, this request would be useful for an integration in which you might be using a different communication channel to notify users with a quick checkout option.
Create a new HTTP request and save it to your collection with the name “Get Quote Checkout.”
Configure the request with the following details.
In the Scripts tab, enter the following “Post-response” code.
Send the request and verify that all tests succeed.
Log in to your storefront as a Senior Buyer or Admin user with the company associated with the quote.
Copy the URL from the response and enter it in a browser to verify that the checkout is initiated.
Complete the checkout and place an order from the quote, using the Purchase Order payment method.
The invoice workflow you’ll examine in the next lab is usually relevant for orders that have been paid with credit, so using the Purchase Order payment method will make sure you have an order that makes sense for that workflow.
Now that an order has been placed from your previous quote, let’s practice fetching order data. You’ll start with an example of fetching all orders placed within the last 7 days, similar to the previous quotes example.
Create a new HTTP request and save it to your collection with the name “Get Recent Orders.”
Configure the request with the following details.
In the Params tab, add the following Query Param.
Try out the effects of other filter params as well, including bcOrderId, companyId, limit, offset, maxCreated, minModified and maxModified, sortBy, and orderBy.
In the Scripts tab, enter the following “Pre-request” code.
In the Scripts tab, enter the following “Post-response” code.
You can see that, just like with quotes, this script is capturing the first order in the results. In this case, you’ll eventually need both the B2B record ID and the BigCommerce order ID for different requests.
Send the request and verify that all tests succeed.
Next, you’ll create a pair of requests to fetch the details of a single order.
Create a new HTTP request and save it to your collection with the name “Get Order.”
Configure the request with the following details.
In the Scripts tab, enter the following “Post-response” code.
Send the request and verify that all tests succeed. The next request will get the order’s item details.
Create a new HTTP request and save it to your collection with the name “Get Order Products.”
Configure the request with the following details.
In the Scripts tab, enter the following “Post-response” code.
Send the request and verify that all tests succeed.