luke-p
12/11/2017 - 7:52 PM

Create a Stripe Charge (Python)

This is a test snippet.

var user = {
  name: "Luke Peters",
  email: "lukempeters@gmail.com",
  location: "Boston, MA"
}
# Set your secret key: remember to change this to your live secret key in production
# See your keys here: https://dashboard.stripe.com/account/apikeys
stripe.api_key = "sk_test_90A4CiddRw4cWBadhJwvcTeh"

# Token is created using Checkout or Elements!
# Get the payment token ID submitted by the form:
token = request.form['stripeToken'] # Using Flask

# Charge the user's card:
charge = stripe.Charge.create(
  amount=1000,
  currency="usd",
  description="Example charge",
  source=token,
)