summaryrefslogtreecommitdiff
path: root/postgresqleu/invoices
diff options
context:
space:
mode:
authorMagnus Hagander2020-03-24 09:19:08 +0000
committerMagnus Hagander2020-03-24 09:19:08 +0000
commita346ae30040cb909b33db704d9254e5c765010cd (patch)
treee256bff4d24ef328a02782065470ac58d56f9f46 /postgresqleu/invoices
parente98e1f2f4de526d7a560f11a0bed503b3fac3e14 (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.py8
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()