tokenize EBTCard
Tokenizes an EBT Card via a ForagePANEdit Text Element.
On success, the object includes a
ref
token that represents an instance of a ForagePaymentMethod
. You can store the token for future transactions, like tocheckBalance
or to create aPayment
in Forage's database.On failure, for example in the case of
unsupported_bin
, the response includes a list of ForageError objects that you can unpack to programmatically handle the error and display the appropriate customer-facing message based on theForageError.code
.
// Example tokenizeEBTCard call in a TokenizeViewModel.kt
class TokenizeViewModel : ViewModel() {
val merchantId = "mid/<merchant_id>"
val sessionToken = "<session_token>"
fun tokenizeEBTCard(foragePanEditText: ForagePANEditText) = viewModelScope.launch {
val response = ForageSDK().tokenizeEBTCard(
TokenizeEBTCardParams(
foragePanEditText = foragePanEditText,
reusable = true,
customerId = "<hash_of_customer_id>"
)
)
when (response) {
is ForageApiResponse.Success -> {
// parse response.data for the PaymentMethod object
}
is ForageApiResponse.Failure -> {
// do something with error text (i.e. response.message)
}
}
}
}
Return
A ForageApiResponse object.
Parameters
A TokenizeEBTCardParams model that passes a foragePanEditText
instance, a customerId
, and a reusable
boolean that Forage uses to tokenize an EBT Card.
See also
SDK errors for more information on error handling.
Throws
If the ForageConfig is not set for the provided foragePanEditText
.