diff options
author | Magnus Hagander | 2020-03-24 09:19:08 +0000 |
---|---|---|
committer | Magnus Hagander | 2020-03-24 09:19:08 +0000 |
commit | a346ae30040cb909b33db704d9254e5c765010cd (patch) | |
tree | e256bff4d24ef328a02782065470ac58d56f9f46 /postgresqleu/invoices | |
parent | e98e1f2f4de526d7a560f11a0bed503b3fac3e14 (diff) |
Catch exceptions when issuing API refunds for invoices
Instead of crashing the cronjob, catch the exception and log it. This
allows the script to proceed with further refunds if one fails.
Diffstat (limited to 'postgresqleu/invoices')
-rw-r--r-- | postgresqleu/invoices/util.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/postgresqleu/invoices/util.py b/postgresqleu/invoices/util.py index 6d1580f8..a90d3401 100644 --- a/postgresqleu/invoices/util.py +++ b/postgresqleu/invoices/util.py @@ -550,7 +550,13 @@ class InvoiceManager(object): def autorefund_invoice(self, refund): # Send an API call to initiate a refund - if refund.invoice.autorefund(refund): + try: + r = refund.invoice.autorefund(refund) + except Exception as e: + r = False + InvoiceHistory(invoice=refund.invoice, txt='Exception trying to refund: {}'.format(e)).save() + + if r: refund.issued = timezone.now() refund.save() |