const tokensController = new TokensController(client);
TokensController
ℹ️ Note This endpoint does not require authentication.
async createToken(
publicKey: string,
request: CreateTokenRequest,
idempotencyKey?: string,
requestOptions?: RequestOptions
): Promise<ApiResponse<GetTokenResponse>>
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. |
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;
}
}
Gets a token from its id
ℹ️ Note This endpoint does not require authentication.
async getToken(
id: string,
publicKey: string,
requestOptions?: RequestOptions
): Promise<ApiResponse<GetTokenResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
id |
string |
Template, Required | Token id |
publicKey |
string |
Template, Required | Public key |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
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;
}
}