Skip to content

Commit

Permalink
Allow duplicate transaction ids for payments which go from pending to…
Browse files Browse the repository at this point in the history
… completed. When this happens the payment should not be flagged but processed like any other successful payment. This can happen for large amounts of money, currency conversions, transactions from certain countries, and other reasons at the discretion of Paypal.
  • Loading branch information
danielgtaylor committed Oct 8, 2009
1 parent a29591e commit 481d0bc
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions paypal/standard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@


def duplicate_txn_id(ipn_obj):
"""Returns True if a record with this transaction id exists."""
return ipn_obj._default_manager.filter(txn_id=ipn_obj.txn_id).count() > 0
"""Returns True if a record with this transaction id exists and it is not
a payment which has gone from pending to completed.
"""
query = ipn_obj._default_manager.filter(txn_id = ipn_obj.txn_id)

if ipn_obj.payment_status == "Completed":
# A payment that was pending and is now completed will have the same
# IPN transaction id, so don't flag them as duplicates because it
# means that the payment was finally successful!
query = query.exclude(payment_status = "Pending")

return query.count() > 0

def make_secret(form_instance, secret_fields=None):
"""
Expand Down Expand Up @@ -46,4 +57,4 @@ def check_secret(form_instance, secret):
"""
# @@@ add invoice & custom
# secret_fields = ['business', 'item_name']
return make_secret(form_instance) == secret
return make_secret(form_instance) == secret

0 comments on commit 481d0bc

Please sign in to comment.