Android

Accept EBT payments in your Android mobile app

You can use the Forage Android SDK to process EBT payments in your Android app.

Two Android phone screens, one prompting for an EBT pin to process payment, the other prompting EBT PIN for balance inquiry

Features

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

Requirements

Before you can use the Forage Android SDK, make sure that:

Forage Android SDK on GitHub

For complete installation instructions and more comprehensive code examples, refer to the GitHub repository.

Starter code

After installing the library, include either or both of the UI components in your application’s views.

For example, the following snippet adds the EBT Card number element ForagePanEditText:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.joinforage.forage.android.ui.ForagePANEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</androidx.constraintlayout.widget.ConstraintLayout>

Then, reference the element in response to a user action. The example below tokenizes the EBT Card number and could be included within an onSubmit function:

val response = ForageSDK.tokenizeEBTCard(
  merchantAccount = merchantAccount,
  bearerToken = bearer
)
    
when (response) {
  is ForageApiResponse.Success -> {
    val adapter: JsonAdapter<PaymentMethod> = moshi.adapter(PaymentMethod::class.java)
    val result = adapter.fromJson(response.data)
    _paymentMethod.value = result
  }
    is ForageApiResponse.Failure -> {
        _error.value = response.message
    }
}

Next steps