Skip to content

Commit

Permalink
got stripe payment gateway purchase method working
Browse files Browse the repository at this point in the history
  • Loading branch information
hayyat committed Dec 23, 2011
1 parent ba39025 commit 975ea56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
17 changes: 6 additions & 11 deletions billing/gateways/stripe_gateway.py
Original file line number Original file line Diff line number Diff line change
@@ -1,11 +1,11 @@
from billing import Gateway from billing import Gateway
from billing.gateway import InvalidData from billing.gateway import InvalidData
from billing.signals import * from billing.signals import *
from billing.utils.credit_card import InvalidData,Visa,MasterCard,\ from billing.utils.credit_card import InvalidCard,Visa,MasterCard,\
AmericanExpress,Discover AmericanExpress,Discover
import stripe import stripe

from django.conf import settings
class StripePaymentGateway(Gateway): class StripeGateway(Gateway):
supported_cardtypes = [Visa, MasterCard, AmericanExpress, Discover] supported_cardtypes = [Visa, MasterCard, AmericanExpress, Discover]
supported_countries = ['US'] supported_countries = ['US']
default_currency = "USD" default_currency = "USD"
Expand All @@ -21,7 +21,7 @@ def purchase(self, amount, credit_card):
raise InvalidCard("Invalid Card") raise InvalidCard("Invalid Card")
try: try:
response = self.stripe.Charge.create( response = self.stripe.Charge.create(
amount=amount, amount=amount*100,
currency="usd", currency="usd",
card={ card={
'number':credit_card.number, 'number':credit_card.number,
Expand All @@ -31,10 +31,5 @@ def purchase(self, amount, credit_card):


},) },)
except self.stripe.CardError, error: except self.stripe.CardError, error:
return error return {'status': 'FAILURE', 'response': error}
return response return {'status': 'SUCCESS', 'response':response}





4 changes: 2 additions & 2 deletions example/app/views.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def stripe(request):
'amount':amount, 'amount':amount,
'response':response, 'response':response,
'title':'Stripe Payment'}) 'title':'Stripe Payment'})






def offsite_paypal(request): def offsite_paypal(request):
Expand Down

0 comments on commit 975ea56

Please sign in to comment.