Menu
Guides
API Reference

Guides

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.

14 min read

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:

StepWhat you doWho does itRequired
1. Set up the FastStore storeCreate the WebOps project, connect GitHub, and configure discovery.config.js.YouYes
2. Configure domainsMove the store to your final domain.You, with VTEX Support for some requestsYes
3. Configure FastCheckoutRequest the FastCheckout enablement.You, with VTEX SupportYes
4. Configure the Shopper entity, plugin, and nohoistInstall the plugin and give the store access to shopper data.YouYes
5. Request the customer experience configurationAsk VTEX to configure the checkout experience for B2B.VTEX, at your requestYes
6. Request the FastCheckout UI configurationAsk VTEX to apply your logo and primary color to FastCheckout.VTEX, at your requestYes
7. Configure internationalization (optional)Offer more than one language, region, or currency.You, with VTEX SupportNo

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 the vtex organization. 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 repositories under 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:

discovery.config.js

_22
module.exports = {
_22
// ...
_22
_22
api: {
_22
storeId: "{accountName}",
_22
workspace: "master",
_22
environment: "vtexcommercestable",
_22
},
_22
_22
storeUrl: "https://{accountName}.vtex.app",
_22
secureSubdomain: "https://{accountName}.vtex.app",
_22
checkoutUrl: "https://{accountName}.vtex.app/checkout",
_22
loginUrl: "https://{accountName}.vtex.app/api/io/login",
_22
accountUrl: "https://{accountName}.vtex.app/api/io/account",
_22
_22
// ...
_22
_22
experimental: {
_22
enableFaststoreMyAccount: true,
_22
refreshToken: true,
_22
},
_22
};

Replace {accountName} with your VTEX account name and leave the other properties as the starter generated them.

PropertyWhat it does
api.storeIdVTEX account name of the store. If it's wrong, the store can't find catalog, price, or session data.
storeUrl, checkoutUrl, loginUrl, accountUrlAddresses of the storefront, checkout, login, and customer account. For now, use the provisional domain. You replace them with the final domain in step 2.
secureSubdomainSame domain as the store. Don't use a separate secure host.
experimental.enableFaststoreMyAccountTurns on My Account, the customer account pages under /pvt/account that B2B Buyer Portal requires.
experimental.refreshTokenRenews the shopper session automatically.

enableFaststoreMyAccount is an experimental feature available only for B2B stores and selected accounts. It must be set inside the experimental object. At the root of the file, it has no effect. With the setting enabled, users who access /pvt/account are redirected to /pvt/account/profile, and the setting overrides accountUrl. 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

  1. In the WebOps dashboard, confirm that the deploy for your last commit succeeded.
  2. Confirm that the store is accessible over HTTPS.
  3. Sign in and go to /pvt/account. The page must redirect to /pvt/account/profile. If it redirects elsewhere, enableFaststoreMyAccount isn't active in the deployed version.

Troubleshooting

IssueSolution
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 secureSubdomain pointing to another domain in discovery.config.js.
  • Use the same domain in all production addresses.

Move the store to the final domain

Complete the following steps in order:

  1. Point your domain to FastStore. In your DNS provider, create the CNAME record for the www host and redirect the root domain to www. Follow Configuring external DNS. DNS propagation can take up to 48 hours.

  2. 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.

  3. 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.

  4. Update discovery.config.js. Replace the production addresses with the final domain, commit, and deploy to main:

    discovery.config.js

    _10
    storeUrl: "https://www.{yourdomain}",
    _10
    secureSubdomain: "https://www.{yourdomain}",
    _10
    checkoutUrl: "https://www.{yourdomain}/checkout",
    _10
    loginUrl: "https://www.{yourdomain}/api/io/login",
    _10
    accountUrl: "https://www.{yourdomain}/api/io/account",

    Login and checkout on the provisional {accountName}.vtex.app domain may not work after this deployment because these URLs point to the final domain. Continue with the remaining steps to complete the migration.

  5. 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.app and applies the CDN configuration. Otherwise, the migration fails. For more information, see FastStore WebOps self-service domain setup.

  6. Request the domain migration. Before you request it, return to Account Settings > Account and click Save in 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.

  7. 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 secure domain. After you adjust discovery.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-BR can return a 404 error 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 to vtex.app.
  • The command curl -sI https://www.{yourdomain} | head -1 returns 200.
  • The login button leads to a page on www.{yourdomain}, and after login the shopper returns to the same domain.
  • https://www.{yourdomain}/checkout loads 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 enableFaststoreMyAccount is set to true inside the experimental object.
  • 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.

  1. In discovery.config.js, add the package to the plugins list:

    discovery.config.js

    _10
    module.exports = {
    _10
    // ...
    _10
    platform: "vtex",
    _10
    plugins: [
    _10
    "@vtex/faststore-plugin-buyer-portal",
    _10
    ],
    _10
    // ...
    _10
    };

  2. In package.json, add the package to dependencies. In a monorepo, use packages/discovery/package.json.

    package.json

    _10
    {
    _10
    "dependencies": {
    _10
    "@vtex/faststore-plugin-buyer-portal": "{version}"
    _10
    }
    _10
    }

  3. 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:


_10
packages/
_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.

  1. In the root package.json, declare nohoist. For the base workspaces setup, see Setting up Buyer Portal Checkout.

    package.json

    _10
    "workspaces": {
    _10
    "packages": [
    _10
    "packages/*"
    _10
    ],
    _10
    "nohoist": [
    _10
    "**/@vtex/faststore-plugin-buyer-portal",
    _10
    "**/@vtex/faststore-plugin-buyer-portal/**"
    _10
    ]
    _10
    }

  2. In packages/discovery/package.json, declare the plugin as a dependency of the package, as in Install the plugin.

  3. Run yarn install and 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:

  1. Check that the package exists in node_modules/@vtex/faststore-plugin-buyer-portal. In a monorepo, check packages/discovery/node_modules/@vtex/faststore-plugin-buyer-portal.
  2. Run yarn dev and confirm the project starts without plugin or module errors.
  3. 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. A 404 error means the plugin didn't load.
  4. 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:

TypeKeyValue
secretFS_DISCOVERY_APP_KEYThe generated API key
secretFS_DISCOVERY_APP_TOKENThe 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.env file 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:


_10
curl -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.

  1. Open a ticket with VTEX Support.
  2. State that the request is the customer experience configuration for B2B Buyer Portal checkout on a FastStore store with FastCheckout.
  3. Provide the account name and whether your project uses Quotes.
  4. 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.

  1. 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 click More actions > Copy URL on the image. For more information, see Media - Overview.
    • The primary color as a hexadecimal code that contrasts with a white background. #fff doesn't work, because the FastCheckout background is already white.
  2. Open a ticket with VTEX Support.
  3. State that the request is the FastCheckout UI configuration for your account and provide the account name, the logo URL, and the primary color.
  4. 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 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_KEY and FS_DISCOVERY_APP_TOKEN secrets 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.

Next steps