deferPaymentCapture

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 the ForageError.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

params

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