Skip to main content

Simple Mode Usage

danger

Please be aware that our Tokenizer is still in Beta. Breaking changes might happen in the future.

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.

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 isValid (boolean) 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;

SuccessResponse

Response format for successful operations.

PropertyTypeDescription
tokenstringToken for make payment on your backend.
paymentMethod'card' | 'ach'Type of payment method used.
detailsCardPaymentResponse | ACHPaymentResponseDetailed information about the card transaction.

ErrorResponse

Attributes of the error response for failed transactions:

PropertyTypeDescription
cardNumberstringSpecific error related to the card number.
cardExpirationstringSpecific error related to the card's expiration date.
cardCVVstringSpecific error related to the card's CVV.
billingAddress.postalCodestringSpecific error related to the card holder's postal code.
errorstringA general error message describing the issue encountered.