Skip to content

Commit

Permalink
Fixed issue #119 - flagged IPNs not excluded from duplicate checking
Browse files Browse the repository at this point in the history
  • Loading branch information
spookylukey committed Mar 30, 2016
1 parent 93542aa commit 79b2227
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions paypal/standard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def duplicate_txn_id(ipn_obj):
similars = (ipn_obj._default_manager
.filter(txn_id=ipn_obj.txn_id)
.exclude(id=ipn_obj.id)
.exclude(flag=True)
.order_by('-created_at')[:1])

if len(similars) > 0:
Expand Down
10 changes: 10 additions & 0 deletions paypal/standard/ipn/tests/test_ipn.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ def test_duplicate_txn_id(self):
self.assertEqual(ipn_obj.flag, True)
self.assertEqual(ipn_obj.flag_info, "Duplicate txn_id. (51403485VH153354B)")

def test_duplicate_txn_id_with_first_flagged(self):
PayPalIPN._postback = lambda self: b"Internal Server Error"
self.paypal_post(IPN_POST_PARAMS)
PayPalIPN._postback = lambda self: b"VERIFIED"
self.paypal_post(IPN_POST_PARAMS)
self.assertEqual(len(PayPalIPN.objects.all()), 2)
ipn_objs = PayPalIPN.objects.order_by('created_at', 'pk')
self.assertEqual(ipn_objs[0].flag, True)
self.assertEqual(ipn_objs[1].flag, False)

def test_recurring_payment_skipped_ipn(self):
update = {
"recurring_payment_id": "BN5JZ2V7MLEV4",
Expand Down

0 comments on commit 79b2227

Please sign in to comment.