many pep8 improvements

This commit is contained in:
mdipierro committed 2012-10-19 12:33:53 -05:00
1 parent b716df1a05
commit 4b2ba185ae
117 files changed
+7160 -5670

No files matched your search

+23 -21
View File
@@ -1,6 +1,7 @@
import urllib
import simplejson
class Stripe:
"""
Usage:
@@ -22,8 +23,9 @@ class Stripe:
if paid is True than transaction was processed
"""
def __init__(self,key):
def __init__(self, key):
self.key = key
def charge(self,
amount,
currency='usd',
@@ -32,33 +34,33 @@ class Stripe:
card_exp_year='2012',
card_cvc_check='123',
description='test charge'):
params = urllib.urlencode({'amount':amount,
'currency':currency,
'card[number]':card_number,
'card[exp_month]':card_exp_month,
'card[exp_year]':card_exp_year,
'card[cvc_check]':card_cvc_check,
'description':description})
u = urllib.urlopen('https://%s:@api.stripe.com/v1/charges' % \
self.key,params)
params = urllib.urlencode({'amount': amount,
'currency': currency,
'card[number]': card_number,
'card[exp_month]': card_exp_month,
'card[exp_year]': card_exp_year,
'card[cvc_check]': card_cvc_check,
'description': description})
u = urllib.urlopen('https://%s:@api.stripe.com/v1/charges' %
self.key, params)
return simplejson.loads(u.read())
def check(self,charge_id):
u = urllib.urlopen('https://%s:@api.stripe.com/v1/charges/%s' % \
(self.key,charge_id))
def check(self, charge_id):
u = urllib.urlopen('https://%s:@api.stripe.com/v1/charges/%s' %
(self.key, charge_id))
return simplejson.loads(u.read())
def refund(self,charge_id):
def refund(self, charge_id):
params = urllib.urlencode({})
u = urllib.urlopen('https://%s:@api.stripe.com/v1/charges/%s/refund'%\
(self.key,charge_id),params)
u = urllib.urlopen('https://%s:@api.stripe.com/v1/charges/%s/refund' %
(self.key, charge_id), params)
return simplejson.loads(u.read())
if __name__=='__main__':
if __name__ == '__main__':
key = raw_input('user>')
d=Stripe(key).charge(100)
print 'charged',d['paid']
d = Stripe(key).charge(100)
print 'charged', d['paid']
s = Stripe(key).check(d[u'id'])
print 'paid',s['paid'],s['amount'] ,s['currency']
print 'paid', s['paid'], s['amount'], s['currency']
s = Stripe(key).refund(d[u'id'])
print 'refunded',s['refunded']
print 'refunded', s['refunded']