Create a ForageEbtCardNumberElement

forage.create('ebt_card_tokenize_number')

This Forage method displays an input field that collects a customer’s EBT Card number, also known as their Personal Account Number (PAN), in order to tokenize the card and save it for future use.

Returns a ForageEbtCardNumberElement that is passed to the corresponding submit method to store a secure reference to the card number.

Parameters

TypeDescription
ebt_card_tokenize_number

required

stringThe constant string ebt_card_tokenize_number.

Example

const tokenizeEbtCardElement = forage.create('ebt_card_tokenize_number')

👍

After creating the EBT Element, call the mount() method to attach it to the DOM. Refer to the EBT Element lifecycle for more details.

Submit a ForageEbtCardNumberElement

forage.tokenizeEbtCardNumber(ForageEbtCardNumberElement, options?)

This Forage method tokenizes an EBT Card number.

Parameters

TypeDescription
ForageEbtCardNumberElement

required

objectThe object returned by forage.create('ebt_card_tokenize_number').
optionsobjectA set of optional configuration settings for the EBT Card number. Refer to options.
options
TypeDescription
reusablebooleanWhether the payment method can be reused. If false, then the payment method can only be used for a single transaction.

Defaults to true if no options parameter is provided.

Example

try {
  const tokenizedEbtCardResult = await forage.tokenizeEbtCardNumber(
    tokenizeEbtCardElement,
    { reusable: false }
  )
  const { ref: paymentMethodRef, type, balance, card } = tokenizedEbtCardResult
} catch (forageErr) {
  if (forageErr?.errors?.length) {
    const [error] = forageErr.errors
    // unpack the first error
    const { httpStatusCode, message, code } = error ?? {}
  }
}

Returns

forage.tokenizeEbtCardNumber(ForageEbtCardNumberElement) returns a Promise.

On success, the Promise resolves with an object that contains the following fields:

TypeDescription
refstringA string identifier that refers to an instance in Forage's database of a PaymentMethod, a tokenized representation of an EBT Card.
typestringA constant string; always ebt for Forage JS.
balanceobjectThe available SNAP and Cash balances on the EBT account associated with the EBT Card, the same as the object returned during a balance check.
cardobjectAn object with information about the card, as detailed in the card response fields.
customer_idstringA unique ID for the end customer making the payment that you shared when you initialized Forage JS.
card response fields
TypeDescription
last4stringThe last four digits of the EBT Card number.
createdISO 8601 date-time stringThe date-time when the card object was created.
tokenstringA tokenized form of the card number which allows Forage to securely lookup this EBT Card.
statestringA two-letter abbreviation for the US state.
Example return value
{
  ref: 'ac47392bb1',
  type: 'ebt',
  balance: {
    snap: '100',
    non_snap: '100',
    updated: '2021-06-16T00:11:50.000000Z-07:00'
  },
  card: {
    last4: '3456',
    created: '2023-07-10T17:21:23.346019-07:00',
    token: 'tok_sandbox_12345678901234567890',
    state: 'CA',
  },
  customer_id: '5b53e4786e73d3da67d04f1bfe5269f72684085a23034f6b55e6887dcdb76417'
}

Enable a "Submit" button for customer input

Find an example submit function in the Forage JS quickstart, and listen for the "change" event’s complete value to enable the button as in this snippet.

⚠️ Allow customers to progress on their own. Do not use complete to automatically perform an action like submitting the form or advancing the cursor to the next input field.

Errors

If the EBT card tokenization fails, then the Promise rejects with a ForageError object that describes the failure.