Skip to main content

Migrating to 1.0

Tokenizer 1.0.0 reshapes the configuration object around one key per payment method (card and ach), moves every callback into the constructor, and gives SimpleReverePay the same onError signature as AdvancedReverePay.

Old configurations no longer work. The library throws an error at construction time that names the old option and tells you where it moved, so a missed change surfaces right away instead of failing at payment time.

Advanced or Simple?​

The changes differ between the two integrations, so the steps below are split by class. Pick the tab for the class you construct: new SimpleReverePay(…) or new AdvancedReverePay(…). If you use both, follow both tabs.

An AdvancedReverePay instance handles exactly one payment method. To offer card and ACH, create two instances. SimpleReverePay accepts one or both, and renders a tab for each.

Advanced accepts exactly one method, Simple accepts one or both

// AdvancedReverePay: exactly one of `card` or `ach`
config: {
  card: { fields: { /* … */ } }
  // Adding `ach` here is a type error and throws at runtime.
}

// SimpleReverePay: `card`, `ach`, or both
config: {
  elementId: 'payment',
  card: {},
  ach: { redirectURL }
}

Upgrade steps​

Checklist​

  1. Update the package: npm install @revere_payments/tokenizer@^1.0.0.
  2. Replace paymentMethods with a card and/or ach key, and move fields, redirectURL and submitMode under the method they belong to (card and ACH, single method).
  3. Pass onSuccess, onError, onLoaded and onCheckValidity to the constructor (details).
  4. Update your onError handler to the 3-argument signature (details).
  5. TypeScript only: update renamed or removed type imports (details).
  6. Load your payment page and check the browser console. Any leftover old option throws a descriptive error.

1. Card and ACH​

paymentMethods is gone. Each method has its own key, and adding the key turns the method on. redirectURL and submitMode move under ach. Card field options move under card.fields.

SimpleReverePay card and ACH config, before and after

config: {
  elementId: 'payment',
  paymentMethods: ['card', 'ach'], 
  defaultPaymentMethod: 'card',
  redirectURL: 'https://example.com/return', 
  submitMode: 'inner', 
  fields: { 
    cardNumber: { placeholder: 'Card number' }, 
    cardCVV: { required: true }, 
    email: { required: true } 
  } 
  card: { 
    fields: { 
      cardNumber: { placeholder: 'Card number' }, 
      cardCVV: { required: true }, 
      email: { required: true } 
    } 
  }, 
  ach: { 
    redirectURL: 'https://example.com/return', 
    submitMode: 'inner', 
    fields: { email: { required: true } } 
  } 
}

2. Single payment method​

A one-item paymentMethods array becomes a single method key. card: {} is enough to enable the card form with its defaults.

SimpleReverePay single method config, before and after

// Card only
config: {
  elementId: 'payment',
  paymentMethods: ['card'] 
  card: {} 
}

// ACH only
config: {
  elementId: 'payment',
  paymentMethods: ['ach'], 
  redirectURL: 'https://example.com/return'
  ach: { redirectURL: 'https://example.com/return' } 
}

3. Callbacks move into the constructor​

onSuccess and onError are required. onLoaded and onCheckValidity are optional. Assigning a callback to the instance after construction now throws.

Callbacks passed to the constructor, before and after

const tokenizer = new SimpleReverePay({
  merchantId,
  publicAPIKey,
  config 
  config, 
  onSuccess: handleSuccess, // required
  onError: handleError, // required
  onLoaded: handleLoaded, 
  onCheckValidity: handleCheckValidity 
});
tokenizer.onSuccess = handleSuccess; 
tokenizer.onError = handleError; 
tokenizer.onLoaded = handleLoaded; 
tokenizer.onCheckValidity = handleCheckValidity; 

4. onError signature​

SimpleReverePay's onError now receives the same three arguments as AdvancedReverePay's: the HTTP response status, the Validation object, and the optional ErrorResponse.

SimpleReverePay onError signature, before and after

const handleError = (error?: ErrorResponse) => { 
  console.error(error?.correlationId); 
}; 
const handleError = ( 
  responseStatus: number, 
  validation: Validation, 
  error?: ErrorResponse 
) => { 
  console.error(responseStatus, validation, error?.correlationId); 
}; 

Type exports​

This applies to both classes.

Type imports from @revere_payments/tokenizer/types changed. Config and DefaultConfig are kept as deprecated aliases of AdvancedConfig and DefaultAdvancedConfig. They still compile, but will be removed in a future major version.

Type exports, before and after

Old typeReplacement
Config (deprecated alias)AdvancedConfig
DefaultConfig (deprecated alias)DefaultAdvancedConfig
CardFieldsConfigAdvancedCardOptions['fields'] or SimpleCardOptions['fields']
ACHFieldsConfigAdvancedACHOptions['fields'] or SimpleACHOptions['fields']
DefaultFieldsConfigRemoved (internal).
InitTokenRequest, MessageEventDataType, UnionOmitRemoved (internal).

New exports: AdvancedConfig, DefaultAdvancedConfig, AdvancedCardOptions, AdvancedACHOptions, SimpleConfig, SimpleCardOptions, SimpleACHOptions, CallbackOptions and AllowableCardBrand. See Types.

Errors you may see after upgrading​

Old options are rejected at construction time with these messages:

Old usageError message
config.paymentMethods`config.paymentMethods` was removed. Configure methods by presence instead: `config.card = {}` and/or `config.ach = { redirectURL }`.
config.paymentMethod`config.paymentMethod` was removed. Configure the method by presence instead: `config.card = {}` or `config.ach = { redirectURL }`.
config.fields`config.fields` was removed. Options moved under the method: `config.card.*` / `config.card.fields.*` (Simple/Advanced), `config.ach.*` / `config.ach.fields.*`.
config.redirectURL`config.redirectURL` was removed. Moved to `config.ach.redirectURL`.
config.submitMode`config.submitMode` was removed. Moved to `config.ach.submitMode`.
tokenizer.onSuccess = … (and similar)`onSuccess` must be passed to the SimpleReverePay constructor: new SimpleReverePay({ …, onSuccess }). (AdvancedReverePay reports the same, with its own name)
No onSuccess / onError passed`onSuccess` is required: new SimpleReverePay({ …, onSuccess }).

Stricter validation​

  • AdvancedReverePay now rejects unknown options. Earlier versions silently ignored misspelled or unsupported keys. Now each one is reported, for example Unexpected option `config.card.fields.cardNumber.placholder`. SimpleReverePay already worked this way.
  • initRequestOrigin is only accepted when sandbox: true. Earlier versions ignored it outside sandbox mode. Now the constructor throws `config.initRequestOrigin` is only accepted in `sandbox` mode.
  • defaultPaymentMethod must name a configured method. For example, defaultPaymentMethod: 'ach' without an ach key throws.
  • Advanced needs exactly one method, Simple at least one. A config with neither (or, for Advanced, with both) throws.

Behavior changes​

These apply to both classes and need no code change, but check them against your handlers.

  • checkValidity() only validates. Earlier versions also tokenized the card when every field was valid, so calling checkValidity() and then submit() could create the card twice. Now only submit() tokenizes.
  • One submission at a time. A submit() made while a submission is in progress is ignored and a warning is logged to the console. Each submit() ends in exactly one onSuccess or onError. Failures that previously never reached onError, such as a bank link that failed to load, now report one.
  • ACH email validation always applies. An invalid or missing required email stops the verification and calls onError(422, validation, { error: 'Validation error' }), like the card flow. Earlier versions only stopped when an onCheckValidity callback was passed.
  • Closing Plaid reports 400. When the customer exits the bank login, onError now receives status 400 and { error: 'user-cancelled' }. When Plaid reports an error, error holds its code (for example 'INVALID_CREDENTIALS'). Earlier versions reported 500, or NaN for Plaid errors.

See When onError fires for every status.