Skip to main content
Version: Live

FailedTransactionResult

The FailedTransactionResult class represents a failed payment transaction. It provides details about the attempted payment and why it failed.

For a complete list of failure codes and their descriptions, see the Failure Codes documentation.

Properties​

PropertyTypeDescription
stateStringThe state of the transaction (will be "FAILURE")
brandStringThe payment method brand (e.g., "visa", "mastercard")
lastFourStringLast four digits of the payment method
receiptNumberStringThe unique transaction_id assigned to a transaction by Pay Theory for the failed transaction
paymentMethodIdStringID of the payment method that was used
payorIdStringID of the payor who attempted the payment

Example Usage​

class PaymentActivity : PayTheoryMerchantActivity(), Payable {
override fun handleFailure(result: FailedTransactionResult) {
// Log the failure details
Log.e("Payment", "Transaction failed: ${result.receiptNumber}")

// Access failed transaction information
val paymentInfo = """
Payment Method: ${result.brand} ending in ${result.lastFour}
Receipt Number: ${result.receiptNumber}
Payor ID: ${result.payorId}
""".trimIndent()

// Show failure UI to user
showError("""
Payment Failed
$paymentInfo
Please try again or use a different payment method.
""".trimIndent())
}

override fun handleError(error: PTError) {
// Handle any system errors separately
showError("System Error: ${error.error}")
}
}