Skip to content

Instantly share code, notes, and snippets.

@metcalf metcalf/ forked from maccman/
Last active Aug 29, 2015

What would you like to do?
import os
from flask import Flask, render_template, request
import stripe
stripe_keys = {
'secret_key': os.environ['SECRET_KEY'],
'publishable_key': os.environ['PUBLISHABLE_KEY']
stripe.api_key = stripe_keys['secret_key']
app = Flask(__name__)
def index():
return render_template('index.html', key=stripe_keys['publishable_key'])
@app.route('/charge', methods=['POST'])
def charge():
amount = 500
customer = stripe.Customer.create(
charge = stripe.Charge.create(,
description='Flask Charge'
return render_template('charge.html', amount=amount)
if __name__ == '__main__':
{% extends "layout.html" %}
{% block content %}
<h2>Thanks, you payed <strong>$5.00</strong>!</h2>
{% endblock %}
{% extends "layout.html" %}
{% block content %}
<form action="/charge" method="post">
<label>Amount: $5.00</label>
<script src="" class="stripe-button" data-key="{{ key }}"></script>
{% endblock %}
<!DOCTYPE html>
<style type="text/css" media="screen">
form article label {
display: block;
margin: 5px;
form .submit {
margin: 15px 0;
{% block content %}{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.