summaryrefslogtreecommitdiff
path: root/postgresqleu/adyen/util.py
diff options
context:
space:
mode:
authorMagnus Hagander2019-01-05 16:12:06 +0000
committerMagnus Hagander2019-01-05 16:14:21 +0000
commit58c2b83d2df9655b86e17bc7e47343858e4a2dd9 (patch)
treee5adfdfd4636e542fdc02f974c83a7d5fdda0f0a /postgresqleu/adyen/util.py
parent40493ac75d12dba360658f8bd6ee03b66a70b81d (diff)
Allow proper processing of Adyen notifications from test system
Instead of never doing anything about them other than sending an email, add a setting for ADYEN_IS_TEST_SYSTEM. If this setting is True (default!) and the notification comes in from the adyen test environment, process it as normal. If it's False and the notification comes in frmo the live environment, process as normal. Only if there is a mismatch is the email generated. In passing, change the term "test system" to "test environment", to make it more clear.
Diffstat (limited to 'postgresqleu/adyen/util.py')
-rw-r--r--postgresqleu/adyen/util.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/postgresqleu/adyen/util.py b/postgresqleu/adyen/util.py
index 53579c0a..6f70f7e3 100644
--- a/postgresqleu/adyen/util.py
+++ b/postgresqleu/adyen/util.py
@@ -261,14 +261,23 @@ def process_new_report(notification):
def process_one_notification(notification):
# Now do notification specific processing
- if not notification.live:
- # This one is in the test system only! So we just send
- # an email, because we're lazy
+ if (not notification.live) and (not settings.ADYEN_IS_TEST_SYSTEM):
+ # Notification is for test environment, but system is configured as live!
send_simple_mail(settings.INVOICE_SENDER_EMAIL,
settings.ADYEN_NOTIFICATION_RECEIVER,
- 'Received adyen notification type %s from the test system!' % notification.eventCode,
- "An Adyen notification with live set to false has been received.\nYou probably want to check that out manually - it's in the database, but has received no further processing.\n",
- AdyenLog(pspReference=notification.pspReference, message='Received notification of type %s from the test system!' % notification.eventCode, error=True).save()
+ 'Received adyen notification type %s from the test environment!' % notification.eventCode,
+ "An Adyen notification with live set to false has been received,\nbut this system is configured as LIVE.\nYou probably want to check that out manually - it's in the database, but has received no further processing.\n",
+ AdyenLog(pspReference=notification.pspReference, message='Received notification of type %s from the test environment!' % notification.eventCode, error=True).save()
+ )
+ notification.confirmed = True
+ notification.save()
+ elif notification.live and settings.ADYEN_IS_TEST_SYSTEM:
+ # Notification is for live environment, but system is configured as test!
+ send_simple_mail(settings.INVOICE_SENDER_EMAIL,
+ settings.ADYEN_NOTIFICATION_RECEIVER,
+ 'Received adyen notification type %s from the test environment!' % notification.eventCode,
+ "An Adyen notification with live set to true has been received,\nbut this system is \nbut this system is configured as TEST.\nYou probably want to check that out manually - it's in the database, but has received no further processing.\n",
+ AdyenLog(pspReference=notification.pspReference, message='Received notification of type %s from the live environment!' % notification.eventCode, error=True).save()
)
notification.confirmed = True
notification.save()