summaryrefslogtreecommitdiff
path: root/postgresqleu/trustlypayment/util.py
diff options
context:
space:
mode:
authorMagnus Hagander2016-12-27 15:35:11 +0000
committerMagnus Hagander2016-12-27 15:35:11 +0000
commit102cbf632e787ecd98955058ec56b33263a5d501 (patch)
tree8fe6ea3cb3544efe28a1e560d39170c45e3975d0 /postgresqleu/trustlypayment/util.py
parent62086e56222e17b41bf757ad6789e3bc86598825 (diff)
Re-order cancel notification code
This ensures we don't fail on reprocessing cancels
Diffstat (limited to 'postgresqleu/trustlypayment/util.py')
-rw-r--r--postgresqleu/trustlypayment/util.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/postgresqleu/trustlypayment/util.py b/postgresqleu/trustlypayment/util.py
index b12418f6..7f724046 100644
--- a/postgresqleu/trustlypayment/util.py
+++ b/postgresqleu/trustlypayment/util.py
@@ -118,13 +118,12 @@ class Trustly(TrustlyWrapper):
elif notification.method == 'cancel':
try:
trans = TrustlyTransaction.objects.get(orderid=notification.orderid)
+ if trans.pendingat:
+ self.log_and_email("Transaction {0} canceled by notification {1} but already in progress. Ignoring cancel!".format(notification.orderid, notification.id))
+ return False
+ TrustlyLog(message='Transaction {0} canceled from notification'.format(notification.orderid)).save()
except TrustlyTransaction.DoesNotExist:
TrustlyLog("Abandoned transaction {0} canceled from notification".format(notification.orderid))
- return False
- if trans.pendingat:
- self.log_and_email("Transaction {0} canceled by notification {1} but already in progress. Ignoring cancel!".format(notification.orderid, notification.id))
- return False
- TrustlyLog(message='Transaction {0} canceled from notification'.format(notification.orderid)).save()
trans.delete()
notification.confirmed = True
notification.save()