defer Payment Capture
Submits a card PIN via a via a ForageVaultElement (either a ForagePINEditText or a ForagePinPad) 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 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(forageVaultElement: ForagePINEditText, paymentRef: String) =
viewModelScope.launch {
val response = forageTerminalSdk.deferPaymentCapture(
DeferPaymentCaptureParams(
forageVaultElement = forageVaultElement,
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 ForageVaultElement (either a ForagePINEditText or a ForagePinPad) instance and a paymentRef
, returned by the Create a Payment endpoint, as the DeferPaymentCaptureParams.
See also
Defer EBT payment capture and refund completion 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.