Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Pass 'meta' information during credit

  • Loading branch information...
commit ceb88e6f5e1eb7ae931cf2921866beccb49381b5 1 parent d1ec229
Ganesh Venkataraman authored
2  .gitignore
@@ -2,8 +2,10 @@ env/
2 2 gittip.egg-info/
3 3 *~
4 4 *.pyc
  5 +*.swp
5 6 local.env
6 7 tests/env
  8 +gittip/tags
7 9 *.idea/
8 10 *.egg-info/
9 11 nosetests.xml
1  gittip/__init__.py
@@ -252,6 +252,7 @@ def get_tips_and_total(tipper, for_payday=False, db=None):
252 252 SELECT * FROM (
253 253 SELECT DISTINCT ON (tippee)
254 254 amount
  255 + , tipper
255 256 , tippee
256 257 , t.ctime
257 258 , p.claimed_time
26 gittip/billing/payday.py
@@ -458,6 +458,9 @@ def charge(self, participant_id, balanced_account_uri, stripe_customer_id, amoun
458 458
459 459 return not bool(error) # True indicates success
460 460
  461 + def _construct_email_address(self, participant_id):
  462 + email_address = '%s@gittip.com' % (participant_id)
  463 + return email_address
461 464
462 465 def ach_credit(self, ts_start, participant, tips, total):
463 466
@@ -493,7 +496,6 @@ def ach_credit(self, ts_start, participant, tips, total):
493 496 msg = "Crediting %s %d cents (%s - $%s fee = $%s) on Balanced ... "
494 497 msg %= (participant['id'], cents, also_log, fee, credit_amount)
495 498
496   -
497 499 # Try to dance with Balanced.
498 500 # ===========================
499 501
@@ -513,7 +515,27 @@ def ach_credit(self, ts_start, participant, tips, total):
513 515 log("%s has no valid bank account connected." % participant['id'])
514 516 return # no valid funding destination
515 517
516   - account.credit(cents)
  518 + # What do we need?
  519 + # Pass on the debit associated which resulted in this particular
  520 + # credit. ATM, I am not sure how to do this, so I am sticking to
  521 + # passing the payer_account and let balance figure out.
  522 + # Also, better way of pulling the balanced_account_uri is using the
  523 + # participant table, deferring that right now. This is an
  524 + # illustration of what information could be sent
  525 +
  526 + payer_account_uris = list()
  527 +
  528 + for tip in tips:
  529 + tipper = tip.get('tipper')
  530 + if not tipper:
  531 + continue
  532 + email_address = self._construct_email_address(tipper)
  533 + balanced_accounts = balanced.Account.query.filter(email_address=email_address).all()
  534 + payer_account_uris.extend([account.uri for account in
  535 + balanced_accounts])
  536 +
  537 + account.credit(cents, meta={'payer_account_uris':
  538 + payer_account_uris})
517 539
518 540 error = ""
519 541 log(msg + "succeeded.")

1 comment on commit ceb88e6

Matin Tamizi

@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.