diff --git a/addons/payment_authorize/models/payment_transaction.py b/addons/payment_authorize/models/payment_transaction.py index aeb4b52b01b27..8f0fefb3f6dc2 100644 --- a/addons/payment_authorize/models/payment_transaction.py +++ b/addons/payment_authorize/models/payment_transaction.py @@ -106,10 +106,7 @@ def _send_refund_request(self, amount_to_refund=None): refund_tx = self.env['payment.transaction'] tx_status = tx_details.get('transaction', {}).get('transactionStatus') - if tx_status in TRANSACTION_STATUS_MAPPING['voided']: - # The payment has been voided from Authorize.net side before we could refund it. - self._set_canceled() - elif tx_status in TRANSACTION_STATUS_MAPPING['refunded']: + if tx_status in TRANSACTION_STATUS_MAPPING['refunded']: # The payment has been refunded from Authorize.net side before we could refund it. We # create a refund tx on Odoo to reflect the move of the funds. refund_tx = super()._send_refund_request(amount_to_refund=amount_to_refund) @@ -234,8 +231,6 @@ def _process_notification_data(self, notification_data): elif status_type == 'void': if self.operation == 'validation': # Validation txs are authorized and then voided self._set_done() # If the refund went through, the validation tx is confirmed - else: - self._set_canceled() elif status_type == 'refund' and self.operation == 'refund': self._set_done() # Immediately post-process the transaction as the post-processing will not be diff --git a/addons/payment_authorize/tests/test_refund_flows.py b/addons/payment_authorize/tests/test_refund_flows.py index 1c6ce09905435..7646d85272481 100644 --- a/addons/payment_authorize/tests/test_refund_flows.py +++ b/addons/payment_authorize/tests/test_refund_flows.py @@ -12,7 +12,7 @@ class TestRefundFlows(AuthorizeCommon): def test_refunding_voided_tx_cancels_it(self): - """ Test that refunding a transaction that has been voided from Authorize.net side cancels + """ Test that refunding a transaction that has been voided from Authorize.net side does not cancel it on Odoo. """ source_tx = self._create_transaction('direct', state='done') with patch( @@ -21,7 +21,7 @@ def test_refunding_voided_tx_cancels_it(self): return_value={'transaction': {'transactionStatus': 'voided'}}, ): source_tx._send_refund_request(amount_to_refund=source_tx.amount) - self.assertEqual(source_tx.state, 'cancel') + self.assertNotEqual(source_tx.state, 'cancel') def test_refunding_refunded_tx_creates_refund_tx(self): """ Test that refunding a transaction that has been refunded from Authorize.net side creates