Skip to content

Latest commit

 

History

History
258 lines (185 loc) · 21.2 KB

README.md

File metadata and controls

258 lines (185 loc) · 21.2 KB

Testing

(testing)

Overview

Use the Testing API to generate and retrieve test data to verify a subset of flows in non-production environments.

Available Operations

createAccount

Create a Bolt shopper account for testing purposes.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.TestingAccountCreateResponse>

Errors

Error Type Status Code Content Type
errors.ErrorT 4XX application/json
errors.FieldError 4XX application/json
errors.SDKError 5XX */*

testingAccountPhoneGet

Get a random, fictitious phone number that is not assigned to any existing Bolt account.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.TestingAccountPhoneGetResponse>

Errors

Error Type Status Code Content Type
errors.ErrorT 4XX application/json
errors.FieldError 4XX application/json
errors.SDKError 5XX */*

getCreditCard

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.

Example Usage

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();

Standalone function

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();

Parameters

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.

Response

Promise<operations.TestingCreditCardGetResponse>

Errors

Error Type Status Code Content Type
errors.ErrorT 4XX application/json
errors.FieldError 4XX application/json
errors.SDKError 5XX */*