Skip to main content

Simple Mode Usage

info

Upgrading from a version before 1.0? See Migrating to 1.0.

Overview​

This guide shows how to create a SimpleReverePay instance with your merchant credentials, a configuration object and your callbacks.

SimpleReverePay Initialization​

To create an instance of the SimpleReverePay class, provide your merchant ID, public API key, a configuration object and the onSuccess / onError callbacks. Each parameter is described in the tables below.

Payment methods are enabled by key: add card, ach, or both. With both, the form shows one tab per method.

Example Usage​

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

const reverePay = new SimpleReverePay({
	merchantId: 'yourMerchantId',
	publicAPIKey: 'yourPublicAPIKey',
	config: {
		elementId: 'reverePaymentsForm',
		sandbox: true,
		card: {}
	},
	onSuccess: (data: SuccessResponse) => {
		console.log('SUCCESS!', data);
	},
	onError: (status: number, validation: Validation, err?: ErrorResponse) => {
		console.log('ERROR!', status, validation, err);
	}
});

Card and ACH together​

const reverePay = new SimpleReverePay({
	merchantId: 'yourMerchantId',
	publicAPIKey: 'yourPublicAPIKey',
	config: {
		elementId: 'reverePaymentsForm',
		defaultPaymentMethod: 'card',
		card: {
			fields: {
				cardCVV: { required: true },
				email: { required: true }
			}
		},
		ach: {
			redirectURL: 'https://merchant.example.com',
			submitMode: 'inner'
		}
	},
	onSuccess: handleSuccess,
	onError: handleError
});

Constructor Parameters​

ParameterTypeRequiredDescription
merchantIdstringYesYour unique merchant identifier.
publicAPIKeystringYesYour public API key.
configSimpleConfigYesConfiguration settings for payment processing.
onSuccessFunctionYesFired after a successful form submission. Provides response (SuccessResponse) as an argument.
onErrorFunctionYesFired after a failed attempt. Provides (status, validation, error?): the HTTP status, the Validation object and an optional ErrorResponse.
onCheckValidityFunctionNoFired after a validity check runs on the form. Provides validity (Validation) as an argument.
onLoadedFunctionNoFired after the initialization process.

Pass the callbacks to the constructor. Assigning them on the instance afterwards (for example reverePay.onSuccess = …) throws an error.

Configuration Options​

Detailed settings within the config object are as follows. Set at least one of card or ach.

PropertyTypeRequiredDefaultDescription
elementIdstringYes-ID of the tokenizer container element.
cardSimpleCardOptionsAt least one of the two-Enables card payments. card: {} uses the defaults; card.fields customizes the inputs.
achSimpleACHOptionsAt least one of the two-Enables ACH payments. ach.redirectURL is required.
defaultPaymentMethod'card' | 'ach'No'card' if setWhich tab opens first. Must be one of the configured methods.
sandboxbooleanNofalseIndicates if sandbox environment should be used for testing purposes.
strictModebooleanNofalseRequires the email field to enable duplication checks.
theme'light' | 'dark'No'light'Sets the color theme of the tokenizer UI.
initRequestOriginstringNo-Overrides the API origin. Only accepted together with sandbox: true.
debugbooleanNofalseEnables debug logging.

Unknown or misspelled options throw an error at construction time.

Response Types​

For detailed information about response types and the validation object, see Types.