Enable Bolt Account Detection
The Account Detection component queries Bolt via our Detect Account API to determine whether the shopper has an existing Bolt Account for the inputted shopper information, such as email address. Accounts displays upon recognizing a shopper with a Bolt account.
TIP
Bolt Accounts can detect shoppers when they enter either an email address or a phone number associated with their account. At minimum, Bolt recommends that you configure an email address input field.
Shopper Experience
Shoppers should be prompted to enter their email address into a field enabled to query Bolt’s Detect Account API.
Check for a Bolt Account
To check whether a shopper has an existing Bolt Account, you can either use Bolt’s front-end detect account component or the Detect Account API.
Detect Account Component
Call the account detection function to check whether a Bolt account exists for a shopper:
let hasAccountResponse = await authorizationComponent.hasAccount({email: $email});
// hasAccountResponse returns a boolean value that indicates whether a Bolt account exists for this email
Detect Account Endpoint
Send a GET
request from the browser to https://api.bolt.com/v1/account/exists
to check whether a Bolt account exists for a user.
INFO
You must call this endpoint from the browser. It is designed to be a browser endpoint for a better user experience and per-IP address rate limiting. Additionally, calling from the browser enables collection of shopper IP addresses for use in authentication.
async function accountExists(email) {
const response = await fetch("https://api-sandbox.bolt.com/v1/account/exists?email=" +
encodeURIComponent(email));
const responseAsJson = await response.json();
return responseAsJson.has_bolt_account;
}
Success Response
{
"has_bolt_account": true,
...
}
Error Response
{
"result": {
"success": false
},
"errors": [{
"code": 1005,
"message": "Authentication error. Invalid merchant key."
}]
}
Next Step in Shopper Flow
- On Success + True: Authorize the shopper, retrieve shopper data, then open the Bolt Checkout modal using the
embed.js
script previously installed. - On Success + False: Send the shopper to your guest checkout experience.
- On Failure: Send the shopper to your guest checkout experience.
Next Step in Implementation
After you enable Bolt Account Detection, you will implement the Authorization Modal. This is a Front End Embedded Component that enables shoppers with a Bolt account to log in via the One-Time Password modal.