Onboarding FastStore for B2B Buyer Portal
Learn how to set up a FastStore store for B2B Buyer Portal, from WebOps and domains to the Shopper entity, plugin, and optional internationalization.
This guide applies only to stores using B2B Buyer Portal, which is currently available to selected accounts.
This guide walks you through the process of setting up a FastStore store that runs B2B Buyer Portal. Each step builds on the previous one, so complete the required steps in the order presented.
The setup involves the following components:
- WebOps: deploys the FastStore store from its GitHub repository and starts a new deployment with every push.
- FastCheckout: the checkout used with B2B Buyer Portal on FastStore.
- The B2B Buyer Portal plugin (
@vtex/faststore-plugin-buyer-portal): adds the Organization Account pages to the store.
These are the implementation steps that are detailed below:
| Step | What you do | Who does it | Required |
|---|---|---|---|
| 1. Set up the FastStore store | Create the WebOps project, connect GitHub, and configure discovery.config.js. | You | Yes |
| 2. Configure domains | Move the store to your final domain. | You, with VTEX Support for some requests | Yes |
| 3. Configure FastCheckout | Request the FastCheckout enablement. | You, with VTEX Support | Yes |
4. Configure the Shopper entity, plugin, and nohoist | Install the plugin and give the store access to shopper data. | You | Yes |
| 5. Request the customer experience configuration | Ask VTEX to configure the checkout experience for B2B. | VTEX, at your request | Yes |
| 6. Request the FastCheckout UI configuration | Ask VTEX to apply your logo and primary color to FastCheckout. | VTEX, at your request | Yes |
| 7. Configure internationalization (optional) | Offer more than one language, region, or currency. | You, with VTEX Support | No |
Before you begin
Make sure that you meet the following prerequisites:
- Your account has B2B Buyer Portal enabled. The feature is in closed beta, so VTEX enables it for selected accounts.
- You have the Owner (Admin Super) role on the account in the VTEX Admin.
- The account has a catalog with products. Without a catalog, you can't test listing, search, and checkout.
- You have a GitHub account or organization with administrator access.
Step 1 - Set up the FastStore store
In this step, you create the FastStore project in WebOps and configure the values that B2B Buyer Portal requires. By the end, the store runs on the provisional {accountName}.vtex.app domain and is ready for the plugin.
Create the project and connect GitHub
Follow the instructions in Starting the project. Keep the following in mind:
- Open Storefront > FastStore WebOps in the VTEX Admin and click
Start Project. - Create the store with the standard FastStore starter.
- When you click
Connect with GitHub, choose your own GitHub organization. Don't choose thevtexorganization. You choose the organization once during onboarding, and you can't change it afterward. If you create the project in the wrong organization, see Moving your FastStore project to a new GitHub repository. - If you select
Only select repositoriesunder Repository access, include the repository that will receive the store. Otherwise, WebOps doesn't receive push events and deploys don't run. - WebOps support for GitHub Enterprise organizations with a custom domain is in open beta. Ask VTEX Support to enable it before you start.
The first deploy is complete when all of the following are true:
- The Deploy Summary screen shows the repository and the dashboard link.
- The WebOps dashboard shows at least one successful deploy. For more information, see FastStore WebOps - Dashboard.
- The store is accessible over HTTPS at
https://{accountName}.vtex.app/.
Configure discovery.config.js
Clone the repository and open discovery.config.js at the project root. In a monorepo, the file is in packages/discovery/. Set the store values and the experimental options as follows:
Replace {accountName} with your VTEX account name and leave the other properties as the starter generated them.
| Property | What it does |
|---|---|
api.storeId | VTEX account name of the store. If it's wrong, the store can't find catalog, price, or session data. |
storeUrl, checkoutUrl, loginUrl, accountUrl | Addresses of the storefront, checkout, login, and customer account. For now, use the provisional domain. You replace them with the final domain in step 2. |
secureSubdomain | Same domain as the store. Don't use a separate secure host. |
experimental.enableFaststoreMyAccount | Turns on My Account, the customer account pages under /pvt/account that B2B Buyer Portal requires. |
experimental.refreshToken | Renews the shopper session automatically. |
enableFaststoreMyAccountis an experimental feature available only for B2B stores and selected accounts. It must be set inside theexperimentalobject. At the root of the file, it has no effect. With the setting enabled, users who access/pvt/accountare redirected to/pvt/account/profile, and the setting overridesaccountUrl. For the full procedure, see Enabling My Account for B2B stores.
With refreshToken enabled, the FastStore SDK renews the session without further code. For details, see Enabling refresh token on FastStore.
Commit and push the change to the main branch. WebOps starts a new deployment with every push.
Verify the setup
- In the WebOps dashboard, confirm that the deploy for your last commit succeeded.
- Confirm that the store is accessible over HTTPS.
- Sign in and go to
/pvt/account. The page must redirect to/pvt/account/profile. If it redirects elsewhere,enableFaststoreMyAccountisn't active in the deployed version.
Troubleshooting
| Issue | Solution |
|---|---|
| The deploy doesn't start after a push. | WebOps runs only when it receives the GitHub push event. In GitHub, open the FastStore WebOps app, click Configure, choose the organization, and confirm that the store repository is listed under Repository access. |
| You can't complete the WebOps onboarding. | If you already installed the app in the organization, open a ticket with VTEX Support and include the account name, the repository link, the app installationId, and the repository ID. |
The Start Project button doesn't work. | Confirm that you have the Owner (Admin Super) role on the account and administrator access in the GitHub organization. |
WebOps is installed in an environment other than master. | WebOps works only in production. Install the app in the master environment of the account. |
Step 2 - Configure domains
In this step, you move the store from the provisional domain to your final domain. By the end, the store is accessible over HTTPS on the final domain, with login and checkout on the same domain.
Use a single domain
The store must use one domain for the storefront, login, customer account, and checkout. A separate secure host is no longer needed. For more information, see FastStore: Simplified domain configuration.
FastCheckout identifies the buyer through the vtex_session and vtex_segment cookies, which are set on the storefront domain. If checkout runs on another domain or subdomain, the cookies don't reach it. Checkout doesn't show an error. It treats the shopper as a non-B2B buyer, and the buyer's contract and organizational unit, along with the contract custom fields, don't appear. Therefore:
- Don't use
secure.{yourdomain}or any other subdomain for checkout or login. - Don't leave
secureSubdomainpointing to another domain indiscovery.config.js. - Use the same domain in all production addresses.
Move the store to the final domain
Complete the following steps in order:
-
Point your domain to FastStore. In your DNS provider, create the
CNAMErecord for thewwwhost and redirect the root domain towww. Follow Configuring external DNS. DNS propagation can take up to 48 hours. -
Activate the account in production. In the VTEX Admin, click your profile avatar, open Account Settings > Account, click
Activate in production, and confirm. VTEX serves the store on a custom domain only after the account is active in production. For more information, see Account settings. -
Add the domain to the store hosts. The store hosts are registered in the License Manager module. In Account Settings > Account, open the Stores tab. In the Hosts table, edit the host list and add both
www.{yourdomain}and{yourdomain}. If a host is missing, checkout doesn't work. For more information, see Configuring the store domain. -
Update
discovery.config.js. Replace the production addresses with the final domain, commit, and deploy tomain:Login and checkout on the provisional
{accountName}.vtex.appdomain may not work after this deployment because these URLs point to the final domain. Continue with the remaining steps to complete the migration. -
Add the domain in WebOps. In Storefront > FastStore WebOps, open the Settings tab, choose the domain in the Host field, click
Add, and confirm it appears under Current Domains. Do this before the domain migration, which makes the final domain the main address of the store instead of{accountName}.vtex.appand applies the CDN configuration. Otherwise, the migration fails. For more information, see FastStore WebOps self-service domain setup. -
Request the domain migration. Before you request it, return to Account Settings > Account and click
Savein the Hosts table. Then open a ticket with VTEX Support, include the account name and the final domain, and state that the store uses FastStore with FastCheckout. -
Set the auth cookie root domain. Follow Step 2 of Integrating the VTEX Login to request the auth cookie root domain for your store domain through VTEX Support.
Request the domain migration again in these cases:
- The store previously used a
securedomain. After you adjustdiscovery.config.js, request the migration again. - The store starts using multiple languages (see step 7). Without a new migration, language-prefixed routes such as
/pt-BRcan return a404error or redirect to the home page.
Verify that the store is live
The store is live when all of the following are true:
https://www.{yourdomain}loads with a valid HTTPS certificate and doesn't redirect tovtex.app.- The command
curl -sI https://www.{yourdomain} | head -1returns200. - The login button leads to a page on
www.{yourdomain}, and after login the shopper returns to the same domain. https://www.{yourdomain}/checkoutloads on the same domain and shows the contract of the signed-in buyer.- In WebOps, the domain appears under Current Domains and the last deploy succeeded.
Step 3 - Configure FastCheckout
This onboarding requires FastCheckout. B2B checkout requires a signed-in buyer, because the checkout needs the buyer's contract and organizational unit. Guest checkout isn't available to B2B buyers.
FastCheckout enablement isn't self-service. Request it through VTEX Support and include the account name, the final store domain, and the store repository. Then complete step 5 and step 6. For instructions on setting up the FastCheckout project, see Setting up Buyer Portal Checkout.
Step 4 - Configure the Shopper entity, plugin, and nohoist
In this step, you install the plugin and give FastStore read access to the Shopper entity, which stores shopper data such as names and phone numbers. If your repository is a monorepo, you also use the nohoist option to keep the plugin inside the store package. By the end, the plugin is active and the My Account pages show data such as the Ordered by card.
Prerequisites for this step
To proceed with this step, make sure that these requirements are satisfied:
- The store from step 1 is deployed and
enableFaststoreMyAccountis set totrueinside theexperimentalobject. - In the VTEX Admin, you have the User Administrator - RESTRICTED role, which lets you create roles and API keys.
- You also have a role that includes the following permissions:
- Dynamic Storage product resources, which control access to the Shopper entity. You need them to add Dynamic Storage to the new role.
- View Secrets and Edit Secrets (FastStore product, Secrets category), which let you manage secrets in WebOps.
Install the plugin
The plugin package is @vtex/faststore-plugin-buyer-portal. Declare it in two places.
-
In
discovery.config.js, add the package to thepluginslist: -
In
package.json, add the package todependencies. In a monorepo, usepackages/discovery/package.json. -
Install the dependencies with
yarn install.
Declare nohoist (monorepos only)
Complete this step only if the same repository contains FastStore and FastCheckout, each in its own package, for example:
_10packages/_10 discovery/ (the FastStore store)_10 checkout/ (the FastCheckout project)
If your project has a single package, skip this step.
The FastStore CLI looks for plugins only in the node_modules folder of the discovery package. In a monorepo, the package manager often moves dependencies to the root node_modules, where the CLI can't find the plugin. The nohoist option keeps the plugin inside packages/discovery/node_modules.
-
In the root
package.json, declarenohoist. For the baseworkspacessetup, see Setting up Buyer Portal Checkout. -
In
packages/discovery/package.json, declare the plugin as a dependency of the package, as in Install the plugin. -
Run
yarn installand deploy.
If you forget nohoist, the local build passes but the WebOps deploy fails, and the build log shows Cannot find module with few details.
Verify the plugin
To confirm that the plugin loaded, complete the following checks:
- Check that the package exists in
node_modules/@vtex/faststore-plugin-buyer-portal. In a monorepo, checkpackages/discovery/node_modules/@vtex/faststore-plugin-buyer-portal. - Run
yarn devand confirm the project starts without plugin or module errors. - Sign in with a user that belongs to an organizational unit and go to
/pvt/organization-account. If the page loads, the plugin is active. A404error means the plugin didn't load. - After deploying, confirm that the WebOps build succeeds.
Configure Shopper entity credentials
FastStore reads the Shopper entity to display who placed an order, who created each quote, and the name and phone of the signed-in user. For that, the project needs an API key with read permission on Dynamic Storage. Without it, those queries fail with No authentication AppKey and AppToken passed.
Follow Configuring Shopper entity access to create the role, generate the API key, and add the credentials. To store them in WebOps, see Managing variables and secrets. Add them as the following secrets and redeploy:
| Type | Key | Value |
|---|---|---|
secret | FS_DISCOVERY_APP_KEY | The generated API key |
secret | FS_DISCOVERY_APP_TOKEN | The generated API token |
Never commit the API key or API token to the repository. Keep them only in WebOps secrets and, for local tests, in terminal variables or an untracked
vtex.envfile listed in.gitignore.
These key names are fixed in FastStore, so a store has only one key pair. If you also configure internationalization, use a single API key for both and give its role the permissions that both guides require.
To validate the key before go-live, run the same query that FastStore makes, with the credentials exported in your terminal:
_10curl -s -o /dev/null -w "%{http_code}\n" \_10 -H "X-VTEX-API-AppKey: $FS_DISCOVERY_APP_KEY" \_10 -H "X-VTEX-API-AppToken: $FS_DISCOVERY_APP_TOKEN" \_10 -H "Accept: application/json" \_10 "https://{accountName}.vtexcommercestable.com.br/api/dataentities/shopper/search?_fields=id&_schema=v1"
A 200 response means the key works. A 401 or 403 response means the key lacks permission, so check that its role has Read only documents on Dynamic Storage.
Then run yarn dev in the same terminal, sign in with a user that belongs to an organizational unit, view an order detail in My Account, and confirm that the Ordered by card shows who placed the order. Repeat the test on the published store after the redeploy.
Step 5 - Request the customer experience configuration
VTEX configures the checkout experience settings that B2B Buyer Portal needs on your account. This configuration isn't self-service.
- Open a ticket with VTEX Support.
- State that the request is the customer experience configuration for B2B Buyer Portal checkout on a FastStore store with FastCheckout.
- Provide the account name and whether your project uses Quotes.
- Wait for VTEX to confirm that the configuration is active before you continue.
The configuration enables the B2B checkout behavior: required sign-in (see step 3), custom fields, multiple deliveries, and, when your project needs it, Quotes.
Step 6 - Request the FastCheckout UI configuration
VTEX applies the FastCheckout UI configuration for your account. This is a required step, and it isn't self-service. Without it, FastCheckout can show an error screen instead of the cart. Request it through support after the customer experience configuration from step 5 is active.
- Prepare the following inputs:
- Your logo as a PNG file published at a public URL on
vtexassets.com. To get this URL, upload the file in Storefront > Media in the VTEX Admin, then clickMore actions>Copy URLon the image. For more information, see Media - Overview. - The primary color as a hexadecimal code that contrasts with a white background.
#fffdoesn't work, because the FastCheckout background is already white.
- Your logo as a PNG file published at a public URL on
- Open a ticket with VTEX Support.
- State that the request is the FastCheckout UI configuration for your account and provide the account name, the logo URL, and the primary color.
- Wait for VTEX to confirm that the configuration is applied.
Step 7 - Configure internationalization (optional)
Complete this step only if your project needs more than one language, region, or currency.
The Localization feature is in closed beta. To use it in your store, contact VTEX Support.
Before you begin, make sure that:
- The CMS is installed and enabled in the account. Headless CMS (legacy) doesn't support this feature.
- The store uses the Catalog Multi-Language API.
- The project is upgraded to FastStore v4. For more information, see Upgrading FastStore to v4.
The procedure is the same as in Handling internationalization with the Localization feature. Keep the following B2B Buyer Portal points in mind:
- The feature uses the same
FS_DISCOVERY_APP_KEYandFS_DISCOVERY_APP_TOKENsecrets that you created in step 4. Don't create a second key pair. Make sure the role of that key includes the permissions of both features. - Bindings, which associate each domain with a locale and currency, are requested through VTEX Support. In the ticket, include the account name, the URL of each domain, the sales channel and currency of each domain, and the locale of each domain.
- After the store starts using multiple languages, request the domain migration again, as described in step 2.