Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hjfreyer committed May 23, 2014
1 parent 829ae2f commit 62d2f2e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
32 changes: 24 additions & 8 deletions backend/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import validictory

import model

# Immutable environment with both configuration variables, and backends to be
# mocked out in tests.
Environment = namedtuple(
Expand All @@ -28,15 +30,21 @@

class PaymentProcessor(object):
"""Interface which processes payments."""
def CreateCustomer(self, payment_params, pledge_model):

STRIPE = 'STRIPE'

def CreateCustomer(self, plaform, params):
"""Does whatever the payment processor needs to do in order to be able to
charge the customer later.
Args:
payment_params: dict with keys like 'paypal' or 'stripe', with values
which are dicts with parameters specific to that payment platform.
pledge_model: A not-yet-committed pledge model for us to modify to include
a record of the customer.
platform: string, one of the ones declared above.
params: dict of parameters specific to that payment platform.
Returns:
A pair of (str, dict), the str indicating the platform (one of the strings
declared above), and the dict giving the fields that will need to be
included in the Pledge model.
"""
raise NotImplementedError()

Expand All @@ -55,8 +63,7 @@ class PledgeHandler(webapp2.RequestHandler):
properties=dict(
email=_STR,
phone=dict(type='string', blank=True),
firstName=_STR,
lastName=_STR,
name=_STR,
occupation=_STR,
employer=_STR,
target=_STR,
Expand All @@ -82,8 +89,17 @@ def post(self):
self.response.write('Invalid request')
return

pledge = model.addPledge(email=data['email'],
stripe_customer_id='3',
amount_cents=data['amountCents'],
occupation=data['occupation'],
employer=data['employer'],
phone=data['phone'],
fundraisingRound='1',
target=data['target'])

self.response.headers['Content-Type'] = 'application/json'
json.dump(dict(id='2'), self.response)
json.dump(dict(id=pledge.url_nonce), self.response)


HANDLERS = [
Expand Down
6 changes: 3 additions & 3 deletions unittests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ def setUp(self):
def tearDown(self):
self.testbed.deactivate()


class PledgeTest(BaseTest):
SAMPLE_USER = dict(
email='pika@pokedex.biz',
phone='212-234-5432',
firstName='Pika',
lastName='Chu',
name='Pika Chu',
occupation=u'Pok\u00E9mon',
employer='Nintendo',
target='Republicans Only',
subscribe=False,
subscribe=True,
amountCents=4200)

def testBadJson(self):
Expand Down

0 comments on commit 62d2f2e

Please sign in to comment.