Skip to content

Latest commit

 

History

History
117 lines (88 loc) · 2.65 KB

tokens.md

File metadata and controls

117 lines (88 loc) · 2.65 KB

Tokens

const tokensController = new TokensController(client);

Class Name

TokensController

Methods

Create Token

ℹ️ Note This endpoint does not require authentication.

async createToken(
  publicKey: string,
  request: CreateTokenRequest,
  idempotencyKey?: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<GetTokenResponse>>

Parameters

Parameter Type Tags Description
publicKey string Template, Required Public key
request CreateTokenRequest Body, Required Request for creating a token
idempotencyKey string | undefined Header, Optional -
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

GetTokenResponse

Example Usage

const publicKey = 'public_key6';
const requestCard: CreateCardTokenRequest = {
  number: 'number2',
  holderName: 'holder_name6',
  expMonth: 80,
  expYear: 216,
  cvv: 'cvv8',
  brand: 'brand4',
  label: 'label0',
};

const request: CreateTokenRequest = {
  type: 'card',
  card: requestCard,
};

try {
  const { result, ...httpResponse } = await tokensController.createToken(publicKey, request);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Get Token

Gets a token from its id

ℹ️ Note This endpoint does not require authentication.

async getToken(
  id: string,
  publicKey: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<GetTokenResponse>>

Parameters

Parameter Type Tags Description
id string Template, Required Token id
publicKey string Template, Required Public key
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

GetTokenResponse

Example Usage

const id = 'id0';
const publicKey = 'public_key6';
try {
  const { result, ...httpResponse } = await tokensController.getToken(id, publicKey);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}