Skip to content

A Flask application that integrates Stripe for secure, one-time payments. Features include configuration management through a dedicated endpoint, webhook handling for real-time notifications and an extensible codebase for adding additional payment-related features with ease. An ideal starting point for implementing payment processing in Flask apps.

License

Notifications You must be signed in to change notification settings

MoigeMatino/Flask-Stripe-One-Time-Payments

Repository files navigation

Flask Stripe Payments

This repository contains a Flask application that seamlessly integrates Stripe to facilitate one-time payments using the checkout strategy. It offers a clear and concise implementation, providing a robust starting point for integrating Stripe's payment processing capabilities into your Flask projects. Whether you're building a simple e-commerce site or a more complex application, this example will help you quickly set up and customize Stripe payments to suit your needs.

Table of Contents

  1. Project Description
  2. Features
  3. Getting Started
  4. Usage
  5. Database Migrations
  6. Extending the Project
  7. Contributing
  8. License

Project Description

This project demonstrates how to integrate Stripe into a Flask application for handling one-time payments. The implementation includes secure payment processing using Stripe Checkout, making it easier to add payment capabilities to your Flask applications.

Features

  • Stripe Integration: Easily integrate Stripe for handling one-time payments.
  • Secure Payments: Utilize Stripe’s secure payment processing.
  • Extensible Codebase: Designed to be easily extended for additional payment-related features.
  • Configuration Management: Handle configuration through a dedicated endpoint.
  • Webhooks: Receive and handle real-time notifications from Stripe for various events (e.g., payment success).
  • Dockerized Setup: Run the application and database using Docker containers.
  • Database Migrations: Use Flask-Migrate to handle database migrations.

Getting Started

Prerequisites

Installation

  1. Clone the repository:

    Using HTTPS:

    git clone https://github.com/yourusername/flask-stripe-payments.git
    cd flask-stripe-payments

    Using SSH:

    git clone [email protected]:yourusername/flask-stripe-payments.git
    cd flask-stripe-payments
  2. Set up your Stripe API keys and other environment variables:

    Create a docker.env file in the root directory and add your Stripe keys and other environment variables e.g:

    STRIPE_PUBLISHABLE_KEY=your_publishable_key
    STRIPE_SECRET_KEY=your_secret_key
    STRIPE_ENDPOINT_SECRET=your_webhook_endpoint_secret
    POSTGRES_DB=your_postgres_database
  3. Build and run the Docker containers:

    docker-compose up --build

    This will start the Flask application and a PostgreSQL database in Docker containers.

Usage

  1. Access the application: Open your browser and go to http://127.0.0.1:5000/.

  2. Make a payment: Click the "Purchase Supa Tee" button and complete the payment using the Stripe Checkout page.

Database Migrations

To handle database migrations using Flask-Migrate, follow these steps:

  1. Create a migration script:

    docker-compose exec flask_app flask db migrate -m "Initial migration."
  2. Apply the migration:

    docker-compose exec flask_app flask db upgrade

These commands should be run inside the Docker container since the database is hosted there.

Extending the Project

  • Add Subscriptions: Implement subscription-based payments using Stripe.
  • Multiple Payment Methods: Extend the payment options to include more methods supported by Stripe.
  • Sending Emails: Send payment confirmation emails to customers.
  • Update Order Status: Update the status of orders in the database.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A Flask application that integrates Stripe for secure, one-time payments. Features include configuration management through a dedicated endpoint, webhook handling for real-time notifications and an extensible codebase for adding additional payment-related features with ease. An ideal starting point for implementing payment processing in Flask apps.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published