Skip to main content

Simple Mode Usage

Overview​

This documentation provides a detailed guide on how to instantiate the SimpleReverePay class for integrating payment processing capabilities using specified merchant credentials and additional configuration settings.

SimpleReverePay Initialization​

To create an instance of the SimpleReverePay class, you need to provide several parameters, including the merchant ID, public API key, and a configuration object. Each parameter is detailed below in a table format.

Example Usage​

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

const reverePay = new SimpleReverePay({
merchantId: 'yourMerchantId',
publicAPIKey: 'yourPublicAPIKey',
config: {
elementId: 'reverePaymentsForm',
paymentMethods: ['card'],
sandbox: true
}
});

reverePay.onSuccess = (data: SuccessResponse) => {
console.log('SUCCESS!');
console.log(data);
};

reverePay.onError = (err?: ErrorResponse) => {
console.log('ERROR!');
console.log(err);
};

Constructor Parameters​

ParameterTypeRequiredDescription
merchantIdstringYesYour unique merchant identifier.
publicAPIKeystringYesYour public API key.
configConfigYesConfiguration settings for payment processing.

Configuration Options​

Detailed settings within the config object are as follows:

PropertyTypeRequiredDefaultDescription
elementIdstringYes-ID of the tokenizer container element.
fieldsCardFieldsConfigNo - card specific.-Contains optional card specific field-related configurations.
paymentMethods'ach'|'card'[]Yes-Specifies the available payment methods.
redirectURLstring | URLIf ach presents in the paymentMethods, Yes. Otherwise No.-Specifies the redirect URL for Plaid.
sandboxbooleanNofalseIndicates if sandbox environment should be used for testing purposes.
submitMode'inner'|'outer'No - ach specific.innerIt allows you to call the .submit() method on the tokenizer instance.
strictModebooleanNofalseRequires the email field to enable duplication checks.
theme'light'|'dark'No-Sets the color theme of the tokenizer UI.

Instance properties​

PropertyTypeRequiredDescription
onSuccessFunctionYesFired after a successful form submission. Provides response (SuccessResponse) as an argument.
onErrorFunctionYesTriggered after a failed transaction. Provides response (ErrorResponse) as an argument.
onCheckValidityFunctionNoFired after a validity check runs on the form. Provides validity (Validation) as an argument.
onLoadedFunctionNoFired after the initialization process.

How to set instance properties​

To use these methods, you typically need to assign the appropriate property on SimpleReverePay class instance. Here's a brief example using JavaScript:

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

const handleSuccess = (response: SuccessResponse) => {
//... your success handler logic
};

const handleError = (response?: ErrorResponse) => {
//... your error handler logic
};

// Assume `reverePay` is your SimpleReverePay instance

// handleSuccess fired after a successful form submission
reverePay.onSuccess = handleSuccess;

// handleError fired after an unsuccessful form submission
reverePay.onError = handleError;

Response Types​

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