Lab - Postman Quote and Order Workflow
Introduction
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.
Prerequisites
- A BigCommerce sandbox store or trial store, or a full production store
- B2B Edition enabled in your store
- Postman or a similar API client
- An existing Postman environment, collection, and headers preset as configured in previous labs
- An existing company and Admin or Senior Buyer user login
- Minimal quote/payment/shipping settings as described below
In this lab, you will:
- Create API requests to inspect and manage quotes and orders
- Implement Postman scripts to automate values used in API requests
Configure Shipping and Payments
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:
- A Shipping Zone that applies to any billing address you will use at checkout
- An enabled Shipping Method on the Shipping Zone
- An enabled test/sandbox Payment Method. (Check the “Enable test credit card payments” option in your Payments Methods settings for the simplest option.) This will be necessary once we get to paying invoices.
- The “Check” payment method enabled
Required B2B Quote/Payment Settings
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:
- In Settings > General, “Quotes” must be checked under “Feature Management.”
- In Settings > Quotes, “Allow Quote Request for” should have “Company user” checked, and “Enable add to quote button” should be checked.
- In Settings > Checkout, the “Purchase Order Payment Method” should be enabled.
- The Payments settings for the company you will use for the storefront must not have been customized to exclude “PO” as an available payment option.
Postman Recap
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:
- An environment with variables set for
v3_token,store_hash, andstorefront_channel_id - A B2B Edition REST collection
- A “B2B REST” headers preset with values for
Accept,Content-Type, andauthToken
Step 1: Submit a Quote Request
For 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.
Step 2: Get Recent Requests for 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. Thestatusfilter 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,minExpiredandmaxExpired,minModifiedandmaxModified,sortBy,orderBy, andquoteNumber. -
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_atvariable 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_idvariable 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_idvariable 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.)
Step 3: Export a Quote PDF
-
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.
Step 4: Generate a Quote Checkout URL
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.
Step 5: Get Recent Orders
Now that an order has been placed from your previous quote, let’s practice fetching orders 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,minModifiedandmaxModified,sortBy, andorderBy. -
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.
Step 6: Get Order Details
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.