Simple Mode Usage
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
- TypeScript
- Javascript
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);
};
import { SimpleReverePay } from 'https://esm.run/@revere_payments/tokenizer';
const reverePay = new SimpleReverePay({
merchantId: 'yourMerchantId',
publicAPIKey: 'yourAPIKey',
config: {
elementId: 'reverePaymentsForm',
paymentMethods: ['card'],
sandbox: true
}
});
Constructor Parameters
Parameter | Type | Required | Description |
---|---|---|---|
merchantId | string | Yes | Your unique merchant identifier. |
publicAPIKey | string | Yes | Your public API key. |
config | Config | Yes | Configuration settings for payment processing. |
Configuration Options
Detailed settings within the config
object are as follows:
Property | Type | Required | Default | Description |
---|---|---|---|---|
elementId | string | Yes | - | ID of the tokenizer container element. |
fields | CardFieldsConfig | No - card specific. | - | Contains optional card specific field-related configurations. |
paymentMethods | 'ach'|'card'[] | Yes | - | Specifies the available payment methods. |
redirectURL | string | URL | If ach presents in the paymentMethods , Yes. Otherwise No. | - | Specifies the redirect URL for Plaid. |
sandbox | boolean | No | false | Indicates if sandbox environment should be used for testing purposes. |
submitMode | 'inner'|'outer' | No - ach specific. | inner | It allows you to call the .submit() method on the tokenizer instance. |
Instance properties
Property | Type | Required | Description |
---|---|---|---|
onSuccess | Function | Yes | Fired after a successful form submission. Provides response (SuccessResponse ) as an argument. |
onError | Function | Yes | Triggered after a failed transaction. Provides response (ErrorResponse ) as an argument. |
onCheckValidity | Function | No | Fired after a validity check runs on the form. Provides isValid (boolean ) as an argument. |
onLoaded | Function | No | Fired 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:
- TypeScript
- 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;
const handleSuccess = (response) => {
//... your success handler logic
};
const handleError = (response) => {
//... 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.
Property | Type | Description |
---|---|---|
token | string | Token for make payment on your backend. |
paymentMethod | 'card' | 'ach' | Type of payment method used. |
details | CardPaymentResponse | ACHPaymentResponse | Detailed information about the card transaction. |
ErrorResponse
Attributes of the error response for failed transactions:
Property | Type | Description |
---|---|---|
cardNumber | string | Specific error related to the card number. |
cardExpiration | string | Specific error related to the card's expiration date. |
cardCVV | string | Specific error related to the card's CVV. |
billingAddress.postalCode | string | Specific error related to the card holder's postal code. |
error | string | A general error message describing the issue encountered. |