Advanced Mode Usage
Upgrading from a version before 1.0? See Migrating to 1.0.
Overview
Advanced mode provides granular control over mounting, styling, and validation via the AdvancedReverePay class. Use it when you need to:
- Mount inputs into your own UI using specific element IDs.
- Listen to per-field validation events and adjust UX.
- Programmatically update styles, placeholders, and values.
- Control focus and submission flows.
Initialization
To create an instance of AdvancedReverePay, pass your merchant credentials, a config object and your callbacks. The key you configure selects the payment method: card or ach. An instance handles exactly one payment method. To offer both, create one instance per method.
- TypeScript
- JavaScript
import { AdvancedReverePay } from '@revere_payments/tokenizer';
import type { SuccessResponse, ErrorResponse, Validation } from '@revere_payments/tokenizer/types';
const reverePay = new AdvancedReverePay({
merchantId: 'yourMerchantId',
publicAPIKey: 'yourPublicAPIKey',
config: {
sandbox: true,
card: {
// Provide your container IDs; defaults shown below
form: { id: 'ccForm' },
fields: {
cardHolderName: { id: 'ccHolderName' },
postalCode: { id: 'ccPostalCode' },
cardNumber: { id: 'ccNumber' },
cardExpiration: { id: 'ccExpiration' },
cardCVV: { id: 'ccCvv' }
}
}
},
onLoaded: () => console.log('Tokenizer loaded'),
onSuccess: (data: SuccessResponse) => console.log('SUCCESS', data),
onError: (status: number, validation: Validation, err?: ErrorResponse) => {
console.log('ERROR', status, validation, err);
},
onCheckValidity: (validation: Validation) => console.log('VALIDITY', validation)
});import { AdvancedReverePay } from 'https://esm.run/@revere_payments/tokenizer';
const reverePay = new AdvancedReverePay({
merchantId: 'yourMerchantId',
publicAPIKey: 'yourPublicAPIKey',
config: {
sandbox: true,
card: {
form: { id: 'ccForm' },
fields: {
cardHolderName: { id: 'ccHolderName' },
postalCode: { id: 'ccPostalCode' },
cardNumber: { id: 'ccNumber' },
cardExpiration: { id: 'ccExpiration' },
cardCVV: { id: 'ccCvv' }
}
}
},
onLoaded: () => console.log('Tokenizer loaded'),
onSuccess: (data) => console.log('SUCCESS', data),
onError: (status, validation, err) => console.log('ERROR', status, validation, err),
onCheckValidity: (validation) => console.log('VALIDITY', validation)
});Constructor Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
merchantId | string | Yes | Your unique merchant identifier. |
publicAPIKey | string | Yes | Your public API key. |
config | AdvancedConfig | Yes | Configuration settings for Advanced mode. |
onSuccess | Function | Yes | Fired after a successful submission. Provides response (SuccessResponse). |
onError | Function | Yes | Fired after a failed attempt. Provides (status, validation, error?: ErrorResponse). See ErrorResponse. |
onCheckValidity | Function | No | Fired after a validity check runs on the form. Provides validation (Validation) object. |
onLoaded | Function | No | Fired after the initialization process. |
Pass the callbacks to the constructor. Assigning them on the instance afterwards (for example reverePay.onSuccess = …) throws an error. See CallbackOptions.
Configuration Options
These options apply to both payment methods. Set exactly one of card or ach. For the per-method options, see the Card and ACH pages.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
card | AdvancedCardOptions | One of card or ach | - | Enables the card flow. Holds the form and field configuration. |
ach | AdvancedACHOptions | One of card or ach | - | Enables the ACH flow. Holds redirectURL and the optional email field. |
sandbox | boolean | No | false | Enables sandbox testing. |
strictMode | boolean | No | false | Enables the email duplication check. Requires an email field (card.fields.email or ach.fields.email). |
hostElement | Document | ShadowRoot | No | document | Where the field container IDs are looked up. Use it when your fields live inside a shadow root. |
initRequestOrigin | string | No | - | Overrides the API origin. Only accepted together with sandbox: true. Usually you don't need this. |
debug | boolean | No | false | Enables debug logging. |
Unknown or misspelled options throw an error at construction time, for example Unexpected option `config.card.fields.cardNumber.placholder`.
For complete type definitions, see Types.