Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
record credit card failures in the DB (closes #364)
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Dec 13, 2014
1 parent e66efe2 commit 7c71dfe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gratipay/billing/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def create_card_hold(db, participant, amount):
except Exception as e:
error = repr_exception(e)
log(msg + "failed: %s" % error)
propagate_exchange(db, participant, 'bill', error, 0)
record_exchange(db, 'bill', amount, fee, participant, 'failed', error)

return hold, error

Expand Down Expand Up @@ -264,7 +264,7 @@ def _prep_hit(unrounded):
return cents, amount_str, upcharged, fee


def record_exchange(db, kind, amount, fee, participant, status):
def record_exchange(db, kind, amount, fee, participant, status, error=None):
"""Given a Bunch of Stuff, return None.
Records in the exchanges table have these characteristics:
Expand All @@ -287,7 +287,9 @@ def record_exchange(db, kind, amount, fee, participant, status):
RETURNING id
""", (amount, fee, participant.username, status))

if amount < 0:
if status == 'failed':
propagate_exchange(cursor, participant, kind, error, 0)
elif amount < 0:
amount -= fee
propagate_exchange(cursor, participant, kind, '', amount)

Expand Down

0 comments on commit 7c71dfe

Please sign in to comment.