Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Destroy and rebuild refund on gateway error
If we don't destroy unsuccessful refund on payment gateway errors we'll end up having a refund associated to the payment without the actual refund processed. Since at the moment refunds have no states to indicate whether is successful or not, the system is considering it as done and doesn't allow to perform a new one since the credit allowed amount for the payment becomes 0: payment.credit_allowed = payment total - refund amount and this formula is true also when the refund has not been succesful. This comes from our past behavior of creating and calling perform! on refunds at the same time. Records weren't created if the refund failed to perform. A more clean solution would be considering in that formula only refunds that are completed but at the moment there's no way to do that. This way we can also keep track of the failed attempts to perform refunds, saving all the information we get back from the gateway.
- Loading branch information