Skip to main content

Types

This page documents the configuration, callback and response types of the Tokenizer API, for both Simple and Advanced modes. All of them can be imported from @revere_payments/tokenizer/types:

import type {
	AdvancedConfig,
	SimpleConfig,
	CallbackOptions,
	SuccessResponse,
	ErrorResponse,
	Validation
} from '@revere_payments/tokenizer/types';

Configuration Types​

AdvancedConfig​

The config of AdvancedReverePay. Set exactly one of card or ach.

type AdvancedConfig = {
	sandbox?: boolean;
	/** Only accepted in `sandbox` mode. */
	initRequestOrigin?: string;
	debug?: boolean;
	/** Requires an `email` field to be configured. */
	strictMode?: boolean;
	hostElement?: Document | ShadowRoot;
} & ({ card: AdvancedCardOptions; ach?: never } | { ach: AdvancedACHOptions; card?: never });

See also: AdvancedCardOptions, AdvancedACHOptions

SimpleConfig​

The config of SimpleReverePay. Set at least one of card or ach.

type SimpleConfig = {
	elementId: string;
	theme?: 'light' | 'dark';
	/** Which tab opens first. Must be one of the configured methods. */
	defaultPaymentMethod?: 'card' | 'ach';
	sandbox?: boolean;
	/** Only accepted in `sandbox` mode. */
	initRequestOrigin?: string;
	debug?: boolean;
	strictMode?: boolean;
} & (
	| { card: SimpleCardOptions; ach?: SimpleACHOptions }
	| { ach: SimpleACHOptions; card?: SimpleCardOptions }
);

See also: SimpleCardOptions, SimpleACHOptions

CallbackOptions​

The callbacks accepted by both constructors, next to merchantId, publicAPIKey and config.

type CallbackOptions = {
	onSuccess: (response: SuccessResponse) => void;
	onError: (responseStatus: number, validation: Validation, error?: ErrorResponse) => void;
	onLoaded?: () => void;
	onCheckValidity?: (validation: Validation) => void;
};

Every submit() ends in exactly one onSuccess or onError call. While a submission is in progress, further submit() calls are ignored and a warning is logged to the console.

When onError fires​

Situationstatuserror (ErrorResponse)correlationId
submit() found invalid fields (card fields, or the email)422{ error: 'Validation error' }No
The card was rejected while being savedThe HTTP status of that request, for example 422The rejection, including a failure code when there is oneYes
The request was rate limited429{ error: 'too-many-requests' }, or the server's message when it sends oneYes
ACH: the customer closed the bank login window400{ error: 'user-cancelled' }No
ACH: the bank login reported an error400{ error: '<code reported by the bank login>' }, for example 'INVALID_CREDENTIALS'No
Starting the payment, creating the token, or loading the bank link failed500A description of the failureYes

The validation argument always reflects the latest field state, so you can highlight the fields that need attention.

AllowableCardBrand​

The card brands accepted by card.fields.cardNumber.allowedCardBrands and reported by onBrandChange (Advanced mode).

type AllowableCardBrand =
	| 'visa'
	| 'mastercard'
	| 'american-express'
	| 'diners-club'
	| 'discover'
	| 'jcb'
	| 'unionpay'
	| 'maestro'
	| 'mir'
	| 'elo'
	| 'hiper'
	| 'hipercard';

Deprecated aliases​

Config and DefaultConfig are deprecated aliases of AdvancedConfig and DefaultAdvancedConfig. They will be removed in a future major version. CardFieldsConfig and ACHFieldsConfig were removed in 1.0. See Migrating to 1.0.

Response Types​

SuccessResponse​

Response format for successful operations. paymentMethod tells you which shape details has.

type SuccessResponse = {
	/** Token for making payment on your backend */
	token: string;
} & (
	| { paymentMethod: 'card'; details: CardPaymentResponse }
	| { paymentMethod: 'ach'; details: ACHPaymentResponse }
);
onSuccess: (response) => {
	if (response.paymentMethod === 'card') {
		console.log(response.details.lastFourCardNumber); // CardPaymentResponse
	} else {
		console.log(response.details.bankName); // ACHPaymentResponse
	}
};

See also: CardPaymentResponse, ACHPaymentResponse

ErrorResponse​

Attributes of the error response for failed transactions:

type ErrorResponse = {
	/** Specific error related to the card number */
	cardNumber?: string;
	/** Specific error related to the card's expiration date */
	cardExpiration?: string;
	/** Specific error related to the card's CVV */
	cardCVV?: string;
	/** Specific error related to the cardholder name */
	cardHolderName?: string;
	/** Specific error related to the billing address (e.g. postal code) */
	billingAddress?: string;
	/** A general error message describing the issue encountered */
	error?: string;
	/** Support reference ID for the failure - see below */
	correlationId?: string;
};

correlationId​

When a transaction fails and it is unrecoverable (e.g. a failed init, create, or tokenization step - not a simple field-validation error the user can correct), the Tokenizer reports diagnostic logs to the gateway. The gateway responds with a generated correlation_id, which the Tokenizer surfaces on the ErrorResponse as correlationId.

This ID lets support trace the exact failed attempt in the backend logs. Surface it to the user (or capture it) in your onError handler and include it when contacting support:

const reverePay = new AdvancedReverePay({
	// ...merchantId, publicAPIKey, config, onSuccess
	onError: (status, validation, err?: ErrorResponse) => {
		if (err?.correlationId) {
			console.error(`Payment failed. Support reference: ${err.correlationId}`);
		}
	}
});

correlationId is only present when the log report reaches the gateway. It is undefined for recoverable validation errors and when the customer exits the ACH bank login, because nothing is reported for those.

Validation​

Validation object provided to the onCheckValidity callback. Each property indicates whether the corresponding field passes validation.

type Validation = {
	/** Validation state of the email */
	email?: boolean;
	/** Validation state of the email format */
	emailFormat?: boolean;
	/** Validation state of the postal code */
	postalCode?: boolean;
	/** Validation state of the cardholder name */
	cardHolderName?: boolean;
	/** Validation state of the card number */
	cardNumber?: boolean;
	/** Validation state of the card expiration */
	cardExpiration?: boolean;
	/** Validation state of the card CVV */
	cardCVV?: boolean;
	/** Validation state of the bank account (ACH) */
	bankAccount?: boolean;
};

Card Payment Types​

CardPaymentResponse​

Details associated with a card payment method.

type CardPaymentResponse = {
	/** Bank Identification Number */
	bin: string;
	/** Card brand (e.g., Visa, MasterCard) */
	brand: string;
	/** Type of card (e.g., credit, debit) */
	cardType: string;
	/** Verification details for the card */
	cardVerification: CardVerification;
	/** Indicator if the card supports domestic push */
	domesticPushToCard: string;
	/** Expiration details of the card */
	expiration: CardExpiration;
	/** Name of the cardholder */
	holderName: string;
	/** Last four digits of the card number */
	lastFourCardNumber: string;
};

See also: CardVerification, CardExpiration

CardExpiration​

Details regarding the card's expiration.

type CardExpiration = {
	/** Expiration month of the card */
	month: string;
	/** Expiration year of the card */
	year: string;
};

CardVerification​

Information about the card's verification status.

type CardVerification = {
	/** CVV verification result */
	cvv: string;
	/** Address line 1 verification result */
	addressLine1: string;
	/** Postal code verification result */
	postalCode: string;
};

ACH Payment Types​

ACHPaymentResponse​

Details associated with an ACH payment method.

type ACHPaymentResponse = {
	/** ID of the bank account*/
	bankAccountID: string;
	/** Status of the bank account */
	status: BankAccountStatusType;
	/** Name of the account holder */
	holderName: string;
	/** Type of account holder */
	holderType: string;
	/** Name of the bank */
	bankName: string;
	/** Type of the bank account */
	bankAccountType: BankAccountType;
	/** Bank routing number */
	routingNumber: string;
	/** Last four digits of the account number */
	lastFourAccountNumber: string;
};

See also: BankAccountStatusType, BankAccountType

BankAccountStatusType​

Possible statuses of the bank account.

type BankAccountStatusType = 'new' | 'validated' | 'pending' | 'errored';

BankAccountType​

Types of bank accounts.

type BankAccountType = 'checking' | 'savings' | 'unknown';