Skip to content

Commit

Permalink
Ignore duplicate notifications
Browse files Browse the repository at this point in the history
Adyen duplicates many notifications. Luckily, our audit trail gives us
an easy way to check for duplicates. We ignore duplicated notifications,
but acknowledge them nonetheless.
  • Loading branch information
maiksprenger committed Jul 14, 2015
1 parent eee7e72 commit 514f9e9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions adyen/facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,17 @@ def assess_notification_relevance(self, request):
if request.POST.get(Constants.EVENT_CODE) != Constants.EVENT_CODE_AUTHORISATION:
return False, True

# Adyen duplicates many notifications. This bit makes sure we ignore them.
# "Duplicate notifications have the same corresponding values for their eventCode and
# pspReference fields." https://docs.adyen.com/display/TD/Accept+notifications
reference = request.POST[Constants.PSP_REFERENCE]
# The event code gets checked above, so we only need to check for the reference now.
if AdyenTransaction.objects.filter(reference=reference).exists():
# We already stored a transaction with this reference, so we can ignore the
# notification. As above, we still acknowledge it to Adyen, in case it missed
# our previous acknowledgment.
return False, True

# Seems legit, just do it :)
return True, True

Expand Down

0 comments on commit 514f9e9

Please sign in to comment.