Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Accept a payment

An implementation with Flask.

You can 🎥 watch a video to see how this server was implemented and read the transcripts.

Requirements

How to run

  1. Confirm .env configuration

Ensure the API keys are configured in .env in this directory. It should include the following keys:

# Stripe API keys - see https://stripe.com/docs/development/quickstart#api-keys
STRIPE_PUBLISHABLE_KEY=pk_test...
STRIPE_SECRET_KEY=sk_test...

# Required to verify signatures in the webhook handler.
# See README on how to use the Stripe CLI to test webhooks
STRIPE_WEBHOOK_SECRET=whsec_...

# Path to front-end implementation. Note: PHP has it's own front end implementation.
STATIC_DIR=../../client/html
DOMAIN=http://localhost:4242
  1. Create and activate a new virtual environment

MacOS / Unix

python3 -m venv env
source env/bin/activate

Windows (PowerShell)

python3 -m venv env
.\env\Scripts\activate.bat
  1. Install dependencies
pip install -r requirements.txt
Optionally - Add Stripe Tax Stripe Tax lets you calculate and collect sales tax, VAT and GST with one line of code. To enable Stripe Tax set up in the dashboard: [Docs - Set up Stripe Tax](https://stripe.com/docs/tax/set-up).

In "server.py", set calcuateTax to true if you want Stripe to calculate tax for the transactions in this application.

calcuateTax = False
  1. Export and run the application

MacOS / Unix

export FLASK_APP=server.py
python3 -m flask run --port=4242

Windows (PowerShell)

$env:FLASK_APP=“server.py"
python3 -m flask run --port=4242
  1. Go to localhost:4242 in your browser to see the demo