Create a ForageEbtCardNumberElement
ForageEbtCardNumberElement
forage.create('ebt_card_tokenize_number')
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
Type | Description | |
---|---|---|
ebt_card_tokenize_number required | string | The constant string ebt_card_tokenize_number . |
Example
const tokenizeEbtCardElement = forage.create('ebt_card_tokenize_number')
After creating the
EBT Element
, call themount()
method to attach it to the DOM. Refer to theEBT Element
lifecycle for more details.
Submit a ForageEbtCardNumberElement
ForageEbtCardNumberElement
forage.tokenizeEbtCardNumber(ForageEbtCardNumberElement, options?)
forage.tokenizeEbtCardNumber(ForageEbtCardNumberElement, options?)
This Forage method tokenizes an EBT Card number.
Parameters
Type | Description | |
---|---|---|
ForageEbtCardNumberElement required | object | The object returned by forage.create('ebt_card_tokenize_number') . |
options | object | A set of optional configuration settings for the EBT Card number. Refer to options. |
options
Type | Description | |
---|---|---|
reusable | boolean | Whether 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:
Type | Description | |
---|---|---|
ref | string | A string identifier that refers to an instance in Forage's database of a PaymentMethod, a tokenized representation of an EBT Card. |
type | string | A constant string; always ebt for Forage JS. |
balance | object | The available SNAP and Cash balances on the EBT account associated with the EBT Card, the same as the object returned during a balance check. |
card | object | An object with information about the card, as detailed in the card response fields. |
customer_id | string | A unique ID for the end customer making the payment that you shared when you initialized Forage JS. |
card
response fields
card
response fieldsType | Description | |
---|---|---|
last4 | string | The last four digits of the EBT Card number. |
created | ISO 8601 date-time string | The date-time when the card object was created. |
token | string | A tokenized form of the card number which allows Forage to securely lookup this EBT Card. |
state | string | A 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.