Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions addons/payment_authorize/models/payment_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions addons/payment_authorize/tests/test_refund_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down