Log In


Add EBT payments to your web application

You can use the Forage JS SDK to process EBT payments in your web application.

A desktop checkout screen lists an option to pay with EBT SNAP powered by Forage


  • Native UI component, called an EBT Element, for securely collecting and tokenizing a customer’s EBT Card number (also known as EBT PAN)
  • EBT Element for securely collecting a customer’s EBT PIN
  • Built-in EBT PAN validation
  • Control over the styling of a native EBT checkout experience
  • Methods that securely collect and tokenize a PAN, perform a balance check, and capture a payment


Starter code and EBT Element life cycle

For comprehensive instructions, refer to the complete Forage JS documentation.

The EBT Element lifecycle contains the following steps:

  1. Initialize
  2. Create
  3. Attach event listeners
  4. Mount
  5. Submit
  6. Destroy

Step 1: Initialize

const forage = Forage({
  merchantId: 'mid/123ab45c67',
  // NOTE: The following line is for testing purposes only and should not be used in production.
  // Please replace this line with a real hashed customer ID value.
  customerId: btoa(Math.random().toString()),
  appearance: {
    variables: {
      borderRadius: '8px'

Refer to the Initialize Forage JS docs for complete documentation.

Step 2: Create an EBT Element

To create an EBT Element, invoke the create() method on the instance of the Forage object, passing in the usecase that corresponds to the target element type.

The following example creates a ​​ForageCardElement that a customer can use to securely input their EBT Card number:

const tokenizeCardElement = forage.create('tokenize_card')

Step 3: Attach event listeners

The following example displays a message if there's an event.error on change:

tokenizeCardElement.on('change', (event) => {
  const explainErrorSpan = document.getElementById('explain-error')
  if (event.error) {
    // show validation error to customer
    explainErrorSpan.textContent = event.error.message
  } else {
    // hide validation error
    explainErrorSpan.textContent = ''

Step 4: Mount the EBT Element

Mount the element to the DOM:


Step 5: Submit the EBT Element

Call the EBT Element's submit() method to securely transmit the customer input to Forage, as in the example below:

try {
  const tokenizationResult = await forage.tokenizeCard(
  const { ref: paymentMethodRef, type, balance, card } = tokenizationResult
} catch (error) {
  const { httpStatusCode, message, code } = error ?? {}

Step 6: Destroy the EBT Element


Next steps