defer Payment Capture
Submits a card PIN via a com.joinforage.forage.android.ui.ForagePINEditText Element and defers payment capture to the server.
On success, the
data
property of the ForageApiResponse.Success object resolves with an empty string.On failure, for example in the case of
expired_session_token
errors, the response includes a list of com.joinforage.forage.android.core.services.forageapi.network.ForageError objects that you can unpack to programmatically handle the error and display the appropriate customer-facing message based on theForageError.code
.
// Example deferPaymentCapture call in a DeferPaymentCaptureViewModel.kt
class DeferPaymentCaptureViewModel : ViewModel() {
val snapPaymentRef = "s0alzle0fal"
val merchantId = "<merchant_id>"
val sessionToken = "<session_token>"
fun deferPaymentCapture(foragePinEditText: ForagePINEditText, paymentRef: String) =
viewModelScope.launch {
val response = ForageSDK().deferPaymentCapture(
DeferPaymentCaptureParams(
foragePinEditText = foragePinEditText,
paymentRef = snapPaymentRef
)
)
when (response) {
is ForageApiResponse.Success -> {
// there will be no financial affects upon success
// you need to capture from the server to formally
// capture the payment
}
is ForageApiResponse.Failure -> {
// handle an error response here
}
}
}
}
Return
A ForageApiResponse object.
Parameters
A DeferPaymentCaptureParams model that passes a foragePinEditText
instance and a paymentRef
, returned by the Create a Payment endpoint, as the DeferPaymentCaptureParams.
See also
Defer EBT payment capture to the server for the related step-by-step guide.
Capture an EBT Payment for the API endpoint to call after deferPaymentCapture.
SDK errors for more information on error handling.
Throws
If the ForageConfig is not set for the provided foragePinEditText
.