tokenizeEBTCard

open suspend override fun tokenizeEBTCard(params: TokenizeEBTCardParams): ForageApiResponse<String>

Tokenizes an EBT Card via a ForagePANEdit Text Element.

  • On success, the object includes a ref token that represents an instance of a Forage PaymentMethod. You can store the token for future transactions, like to checkBalance or to create a Payment 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 the ForageError.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

params

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.