Skip to content
Browse files

Pass 'meta' information during credit

  • Loading branch information...
1 parent d1ec229 commit ceb88e6f5e1eb7ae931cf2921866beccb49381b5 Ganesh Venkataraman committed Nov 5, 2012
Showing with 27 additions and 2 deletions.
  1. +2 −0 .gitignore
  2. +1 −0 gittip/__init__.py
  3. +24 −2 gittip/billing/payday.py
View
2 .gitignore
@@ -2,8 +2,10 @@ env/
gittip.egg-info/
*~
*.pyc
+*.swp
local.env
tests/env
+gittip/tags
*.idea/
*.egg-info/
nosetests.xml
View
1 gittip/__init__.py
@@ -252,6 +252,7 @@ def get_tips_and_total(tipper, for_payday=False, db=None):
SELECT * FROM (
SELECT DISTINCT ON (tippee)
amount
+ , tipper
, tippee
, t.ctime
, p.claimed_time
View
26 gittip/billing/payday.py
@@ -458,6 +458,9 @@ def charge(self, participant_id, balanced_account_uri, stripe_customer_id, amoun
return not bool(error) # True indicates success
+ def _construct_email_address(self, participant_id):
+ email_address = '%s@gittip.com' % (participant_id)
+ return email_address
def ach_credit(self, ts_start, participant, tips, total):
@@ -493,7 +496,6 @@ def ach_credit(self, ts_start, participant, tips, total):
msg = "Crediting %s %d cents (%s - $%s fee = $%s) on Balanced ... "
msg %= (participant['id'], cents, also_log, fee, credit_amount)
-
# Try to dance with Balanced.
# ===========================
@@ -513,7 +515,27 @@ def ach_credit(self, ts_start, participant, tips, total):
log("%s has no valid bank account connected." % participant['id'])
return # no valid funding destination
- account.credit(cents)
+ # What do we need?
+ # Pass on the debit associated which resulted in this particular
+ # credit. ATM, I am not sure how to do this, so I am sticking to
+ # passing the payer_account and let balance figure out.
+ # Also, better way of pulling the balanced_account_uri is using the
+ # participant table, deferring that right now. This is an
+ # illustration of what information could be sent
+
+ payer_account_uris = list()
+
+ for tip in tips:
+ tipper = tip.get('tipper')
+ if not tipper:
+ continue
+ email_address = self._construct_email_address(tipper)
+ balanced_accounts = balanced.Account.query.filter(email_address=email_address).all()
+ payer_account_uris.extend([account.uri for account in
+ balanced_accounts])
+
+ account.credit(cents, meta={'payer_account_uris':
+ payer_account_uris})
error = ""
log(msg + "succeeded.")

1 comment on commit ceb88e6

@matin
matin commented on ceb88e6 Nov 6, 2012

@gvenkataraman why not grab the Twitter or GitHub info if available?

Please sign in to comment.
Something went wrong with that request. Please try again.