(testing)
Use the Testing API to generate and retrieve test data to verify a subset of flows in non-production environments.
- createAccount - Create a test account
- testingAccountPhoneGet - Get a random phone number
- getCreditCard - Retrieve a tokenized test credit card
Create a Bolt shopper account for testing purposes.
import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk";
import { EmailState, PhoneState } from "@boltpay/bolt-typescript-sdk/models/components";
const boltTypescriptSDK = new BoltTypescriptSDK();
async function run() {
const result = await boltTypescriptSDK.testing.createAccount({
apiKey: "<YOUR_API_KEY_HERE>",
}, {
emailState: EmailState.Unverified,
phoneState: PhoneState.Verified,
isMigrated: true,
hasAddress: true,
hasCreditCard: true,
}, "<value>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js";
import { testingCreateAccount } from "@boltpay/bolt-typescript-sdk/funcs/testingCreateAccount.js";
import { EmailState, PhoneState } from "@boltpay/bolt-typescript-sdk/models/components";
// Use `BoltTypescriptSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const boltTypescriptSDK = new BoltTypescriptSDKCore();
async function run() {
const res = await testingCreateAccount(boltTypescriptSDK, {
apiKey: "<YOUR_API_KEY_HERE>",
}, {
emailState: EmailState.Unverified,
phoneState: PhoneState.Verified,
isMigrated: true,
hasAddress: true,
hasCreditCard: true,
}, "<value>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
security |
operations.TestingAccountCreateSecurity | ✔️ | The security requirements to use for the request. |
xPublishableKey |
string | ✔️ | The publicly shareable identifier used to identify your Bolt merchant division. |
accountTestCreationData |
components.AccountTestCreationData | ✔️ | N/A |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.TestingAccountCreateResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorT | 4XX | application/json |
errors.FieldError | 4XX | application/json |
errors.SDKError | 5XX | */* |
Get a random, fictitious phone number that is not assigned to any existing Bolt account.
import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk";
const boltTypescriptSDK = new BoltTypescriptSDK();
async function run() {
const result = await boltTypescriptSDK.testing.testingAccountPhoneGet({
apiKey: "<YOUR_API_KEY_HERE>",
}, "<value>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js";
import { testingTestingAccountPhoneGet } from "@boltpay/bolt-typescript-sdk/funcs/testingTestingAccountPhoneGet.js";
// Use `BoltTypescriptSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const boltTypescriptSDK = new BoltTypescriptSDKCore();
async function run() {
const res = await testingTestingAccountPhoneGet(boltTypescriptSDK, {
apiKey: "<YOUR_API_KEY_HERE>",
}, "<value>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
security |
operations.TestingAccountPhoneGetSecurity | ✔️ | The security requirements to use for the request. |
xPublishableKey |
string | ✔️ | The publicly shareable identifier used to identify your Bolt merchant division. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.TestingAccountPhoneGetResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorT | 4XX | application/json |
errors.FieldError | 4XX | application/json |
errors.SDKError | 5XX | */* |
Retrieve a test credit card that can be used to process payments in your Bolt testing environment. The response includes the card's Bolt credit card token.
import { BoltTypescriptSDK } from "@boltpay/bolt-typescript-sdk";
import { Type } from "@boltpay/bolt-typescript-sdk/models/operations";
const boltTypescriptSDK = new BoltTypescriptSDK();
async function run() {
const result = await boltTypescriptSDK.testing.getCreditCard({
apiKey: "<YOUR_API_KEY_HERE>",
}, {
type: Type.Approve,
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { BoltTypescriptSDKCore } from "@boltpay/bolt-typescript-sdk/core.js";
import { testingGetCreditCard } from "@boltpay/bolt-typescript-sdk/funcs/testingGetCreditCard.js";
import { Type } from "@boltpay/bolt-typescript-sdk/models/operations";
// Use `BoltTypescriptSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const boltTypescriptSDK = new BoltTypescriptSDKCore();
async function run() {
const res = await testingGetCreditCard(boltTypescriptSDK, {
apiKey: "<YOUR_API_KEY_HERE>",
}, {
type: Type.Approve,
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.TestingCreditCardGetRequestBody | ✔️ | The request object to use for the request. |
security |
operations.TestingCreditCardGetSecurity | ✔️ | The security requirements to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.TestingCreditCardGetResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorT | 4XX | application/json |
errors.FieldError | 4XX | application/json |
errors.SDKError | 5XX | */* |