Broadleaf Microservices

Reversing Unused Checkout Payment Transactions

While it’s possible to handle checkout workflow activities in real time, we strongly prefer to handle these kinds of actions as an offline process. This is especially relevant for reversing successful payment transactions that were executed as a part of a failed checkout!

Instead of attempting to reverse an AUTHORIZE or AUTHORIZE_AND_CAPTURE in real time, we leverage PaymentTransactionService’s transaction reversal jobs. The MARK_PAYMENTS_FOR_REVERSAL job is responsible for identifying "stale" payment transactions - i.e. successful transactions that are not tied to a successful checkout. By default, this job allows the successful payment transaction to be used for 1 hour, before it’s deemed stale & its managementState is set to REQUIRES_REVERSAL.

Within that 1-hour window, the successful transaction can contribute to a successful checkout. This means that the CartPaymentMethodValidationActivity will validate that the transaction amount sufficiently covers the payment amount, and the PaymentTransactionExecutionActivity will not attempt to execute further transactions against the payment.

If the checkout is not successfully completed within the 1-hour window, then the cart’s successful transactions will be marked with REQUIRES_REVERSAL, and eventually reversed by the PAYMENT_TRANSACTION_REVERSAL job.

The 1-hour window can be adjusted using the following property in PaymentTransactionServices: broadleaf.paymenttransaction.service.anonymous-payment-ttl.
When a checkout successfully completed, the cart’s payment transactions have their managementState set to AUTOMATIC_REVERSAL_NOT_ALLOWED, thus blocking the MARK_PAYMENTS_FOR_REVERSAL job from processing its transactions.