Source

flask-stripe-blueprint / demos / 01-simplest / app.py

Full commit
'''
The simplest usage of itemshop: a single item, mounted at the root of the app.
'''

import os

from flask import Flask, render_template, request, Blueprint
import stripe
from itemshop import ItemBP

## stripe API key #############################################################

#XXX: api_key can either be set globally or per-item using pmt_default_args
#XXX: this is my own testing key, please try your own testing key if you have one
stripe.api_key = 'UwK0UE4tdPGNJckqfiu5UbzUJxHClRjW'

## app setup ##################################################################

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
SHARED_STATIC_DIR = os.path.join(ROOT_DIR, '..', 'static')

app = Flask(__name__, static_folder=SHARED_STATIC_DIR)

item = ItemBP('cool_item', stripe.Charge, dict(
    amount=1500,
    currency='usd',
))

app.register_blueprint(item.blueprint)

## main #######################################################################

if __name__ == "__main__":
    app.run(debug=True, use_reloader=True)