Skip to main content

Advanced Mode Usage

info

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.

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)
});

Constructor Parameters​

ParameterTypeRequiredDescription
merchantIdstringYesYour unique merchant identifier.
publicAPIKeystringYesYour public API key.
configAdvancedConfigYesConfiguration settings for Advanced mode.
onSuccessFunctionYesFired after a successful submission. Provides response (SuccessResponse).
onErrorFunctionYesFired after a failed attempt. Provides (status, validation, error?: ErrorResponse). See ErrorResponse.
onCheckValidityFunctionNoFired after a validity check runs on the form. Provides validation (Validation) object.
onLoadedFunctionNoFired 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.

PropertyTypeRequiredDefaultDescription
cardAdvancedCardOptionsOne of card or ach-Enables the card flow. Holds the form and field configuration.
achAdvancedACHOptionsOne of card or ach-Enables the ACH flow. Holds redirectURL and the optional email field.
sandboxbooleanNofalseEnables sandbox testing.
strictModebooleanNofalseEnables the email duplication check. Requires an email field (card.fields.email or ach.fields.email).
hostElementDocument | ShadowRootNodocumentWhere the field container IDs are looked up. Use it when your fields live inside a shadow root.
initRequestOriginstringNo-Overrides the API origin. Only accepted together with sandbox: true. Usually you don't need this.
debugbooleanNofalseEnables 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.