Thanks for the pointer.
It was quite easy but as a beginner it took me a while to figure this out, so i thought i would write what i did in the hope it helps someone else.
I followed the instructions in the documentation.
https://stripe.com/docsYou need to install the API as described then you need to remove or rename the stripe.py found in gluon/contrib
in db.py i
import stripeand added
stripe.api_key = "Replace_with_your_key"I used the Custom form from the Stripe documents in my view.
Then in the controller i put the code from the example just a couple of small changes. You change the request.POST to request.post_vars. You also need to put this in an if loop.
def createcustomer():
# Get the credit card details submitted by the form
if request.post_vars:
token = request.post_vars['stripeToken']
# Create the charge on Stripe's servers - this will charge the user's card
try:
# Create a Customer
customer = stripe.Customer.create(
card=token,
description="
payin...@example.com"
)
# Charge the Customer instead of the card
stripe.Charge.create(
amount=1000, # in cents
currency="usd",
customer=
customer.id )
#Save Customer ID in your DB
db.customer.insert(customer_id =
customer.id )
db.commit()
# Redirect to view post
session.flash = T("You Payed!")
return redirect(URL('default', 'view'))
except stripe.CardError, e:
# The card has been declined
response.flash = "Card Error"
pass
I am a beginner, so there is probably a cleaner and better way, but the above worked for me. Hope it helps