Skip to content
Open
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
5 changes: 2 additions & 3 deletions addons/payment_authorize/models/payment_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,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()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could avoid this patch

Using a inherit class and using _set_canceled

I mean,

class ...
    _inherit = "payment.transaction"

    def _set_canceled(...):
        if self.provider_code == 'authorize':
            self.transaction_status = 'voided'
        else:
            return super()._set_canceled()

Or something similar

cc @fernandahf

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all scenarios where it's canceled are because of a void; it could be declined by the provider. How do we know what the difference is?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a context in the patch and process this context in the inherited method

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I utilized the context

self.with_context(avoid_cancel=True)._set_canceled()
elif 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.
Expand Down Expand Up @@ -235,7 +234,7 @@ def _process_notification_data(self, notification_data):
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()
self.with_context(avoid_cancel=True)._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