Bank accounts (4.10.3)

Learn about Bank Accounts using Recurly.js version 4.10.3.

Bank accounts

Tokenize your users' bank account information

Just as with a card form, use the data-recurly attribute to identify fields to Recurly.js. Since Recurly.js does not need to inject fields for bank accounts, all fields may be displayed as inputs on your payment form.

<form>
  <input type="text" data-recurly="routing_number">
  <input type="text" data-recurly="account_number">
  <input type="text" data-recurly="account_number_confirmation">
  <input type="text" data-recurly="account_type">
  <input type="text" data-recurly="name_on_account">
  <input type="hidden" name="recurly-token" data-recurly="token">
  <button>submit</button>
</form>

Bank account inputs

Field NameExampleDescription
routing_number123456789Routing number. Required
account_number987654321Account number. Required
account_number_confirmation987654321Account number confirmation. Required
account_typechecking or savingsAccount type. Required
name_on_accountPat SmithFull name on account. Required

Getting a token

recurly.bankAccount.token

You may call recurly.bankAccount.token with a form element

recurly.bankAccount.token(document.querySelector('form'), tokenHandler);

Or with an Object

const billingInfo = {
  // required attributes
  routing_number: '123456780',
  account_number: '111111111',
  account_number_confirmation: '111111111',
  account_type: 'checking',
  name_on_account: 'Pat Smith',

  // optional attributes
  address1: '123 Main St.',
  address2: 'Unit 1',
  city: 'Hope',
  state: 'WA',
  postal_code: '98552',
  country: 'US',
  vat_number: 'SE0000'
};

recurly.bankAccount.token(billingInfo, tokenHandler);

Both methods require using a handler function like this one

function tokenHandler (err, token) {
  if (err) {
    // handle error using err.code and err.fields
  } else {
    // handle success using token.id
  }
}

This sends bank account billing information to Recurly to store as a token, returning that token id back to you via callback.

Arguments (form)

ParamTypeDescription
formHTMLFormElementParent form containing data-recurly fields
callbackFunctionCallback function to accept the returned token

Alternatively, you can call recurly.bankAccount.token with a plain JavaScript object. This allows a more direct interface to the payment flow, eliminating any need to use the DOM.

Arguments (object)

ParamTypeDescription
optionsObjectAn object with billing information properties matching those [outlined above].
callbackFunctionCallback function to accept the returned token

A callback is always required

Callback arguments

ParamTypeDescription
errRecurlyError or nullA RecurlyError if an error occurred; otherwise null.
tokenObjectAn object containing a token id.
token.typeString'bank_account'
token.idStringA token id.

Returns

Nothing.