Skip to content

Commit

Permalink
Pro payments is almost ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Boxall committed Feb 3, 2009
1 parent e42dace commit 6a8d1b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ ToDo:

* Scattered throughout the code are triple hash ### ToDo comments with little actionable items.

* PayPal payments pro is in the works.

* IPN created should probably emit signals so that other objects can update themselves on the correct conditions.

* TESTS. Yah, this needs some test scripts bad...
Expand All @@ -207,6 +205,8 @@ ToDo:

* Lots of fields store QueryDict dumps b/c we're not sure exactly what we're getting - would be cool to be able to access those fields like they were a dict (JSONField)

* Express Checkout flow with recurring payments doesn't like the tokens its getting...

License (MIT)
=============

Expand Down
9 changes: 5 additions & 4 deletions pro/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
USER = settings.PAYPAL_WPP_USER
PASSWORD = settings.PAYPAL_WPP_PASSWORD
SIGNATURE = settings.PAYPAL_WPP_SIGNATURE
VERSION = "50.0"
VERSION = 54.0
BASE_PARAMS = dict(USER=USER , PWD=PASSWORD, SIGNATURE=SIGNATURE, VERSION=VERSION)

ENDPOINT = "https://api-3t.paypal.com/nvp"
Expand Down Expand Up @@ -98,8 +98,6 @@ def doExpressCheckoutPayment(self, params):
"""
Check the dude out:
{'ORDERTIME': '2009-02-02T16:48:41Z', 'ACK': 'Success', 'TIMESTAMP': '2009-02-02T16:48:43Z', 'CURRENCYCODE': 'USD', 'PAYMENTSTATUS': 'Completed', 'PENDINGREASON': 'None', 'PAYMENTTYPE': 'instant', 'TOKEN': 'EC-4FD207377L4986412', 'VERSION': '50.0', 'BUILD': '801690', 'TAXAMT': '0.00', 'FEEAMT': '0.59', 'REASONCODE': 'None', 'TRANSACTIONID': '1WF99451L2124605U', 'AMT': '10.00', 'CORRELATIONID': '46bcc23d964ad', 'TRANSACTIONTYPE': 'expresscheckout'}
"""
defaults = dict(METHOD="DoExpressCheckoutPayment", PAYMENTACTION="Sale")
required ="returnurl cancelurl amt token payerid".split()
Expand All @@ -122,12 +120,15 @@ def createRecurringPaymentsProfile(self, params, direct=False):
if direct:
required + "creditcardtype acct expdate firstname lastname".split()
else:
required + ["token"]
required + ["token", "payerid"]

pp_params = self._check_and_update_params(params, required, defaults)
print pp_params
return self._fetch(pp_params)

def setCustomerBillingAgreement(self, params):
raise DeprecationWarning

def getTransactionDetails(self, params):
raise NotImplementedError

Expand Down
11 changes: 10 additions & 1 deletion pro/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def __init__(self, item=None,
confirm_template="pro/confirm.html",
success_url="?success", fail_url=None, test=True):
self.item = item
self.is_recurring = False
if 'billingperiod' in item:
self.is_recurring = True
print self.is_recurring
# ### Could we set these based off success_url / fail_url?
# self.item.setdefault('returnurl', )
# self.item.setdefault('cancelurl', )
Expand Down Expand Up @@ -190,7 +194,12 @@ def validate_confirm_form(self):
wpp = PayPalWPP(self.request)
pp_data = dict(token=self.request.POST['token'], payerid=self.request.POST['PayerID'])
self.item.update(pp_data)
response = wpp.doExpressCheckoutPayment(self.item)

if self.is_recurring:
response = wpp.createRecurringPaymentsProfile(self.item)
else:
response = wpp.doExpressCheckoutPayment(self.item)

if response.get('ACK') == 'Success':
return HttpResponseRedirect(self.success_url)
else:
Expand Down

0 comments on commit 6a8d1b8

Please sign in to comment.