updateFailureTransaction static method
Updates the Firestore record with the failure response of a payment transaction.
This method updates the payment transaction status to 'failure' and adds the failure response to the Firestore document.
Parameters:
transaction
: The unique transaction ID.failureResponse
: The failure response data returned from the payment gateway.
Implementation
static Future<void> updateFailureTransaction({
required String transaction,
required Map<String, dynamic>? failureResponse,
}) async {
_firestore.collection(collectionName).doc(transaction).update(
{
'failureResponse': failureResponse?['response'] != null
? jsonDecode(failureResponse!['response'])
: 'No response',
'status': 'failure',
'failureTime': FieldValue.serverTimestamp(),
},
);
}