Android
Accept EBT payments in your Android mobile app
You can use the Forage Android SDK to process EBT payments in your Android app.
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:
- You’ve met all of the prerequisites for working with Forage
- Your Android app is built on Minimum API Level Android 5.0 (API level 21)
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
- Check out the forage-android-sdk GitHub repository for full installation instructions and a demo app
Updated 11 days ago