hostbasket/actix_mvc_app/STRIPE_SETUP.md
Mahmoud-Emad d3a66d4fc8 feat: Add initial production deployment support
- Add .env.example file for environment variable setup
- Add .gitignore to manage sensitive files and directories
- Add Dockerfile.prod for production-ready Docker image
- Add PRODUCTION_CHECKLIST.md for pre/post deployment steps
- Add PRODUCTION_DEPLOYMENT.md for deployment instructions
- Add STRIPE_SETUP.md for Stripe payment configuration
- Add config/default.toml for default configuration settings
- Add config/local.toml.example for local configuration template
2025-06-25 18:32:20 +03:00

2.8 KiB

Stripe Integration Setup Guide

This guide explains how to configure Stripe payment processing for the company registration system.

🔧 Configuration Options

The application supports multiple ways to configure Stripe API keys:

Default Configuration

The application includes default test keys in config/default.toml:

[stripe]
publishable_key = "pk_test_..."
secret_key = "sk_test_..."

Local Configuration

Create config/local.toml to override defaults:

[stripe]
publishable_key = "pk_test_YOUR_KEY_HERE"
secret_key = "sk_test_YOUR_KEY_HERE"
webhook_secret = "whsec_YOUR_WEBHOOK_SECRET"

Set environment variables with the APP__ prefix:

export APP__STRIPE__PUBLISHABLE_KEY="pk_test_YOUR_KEY_HERE"
export APP__STRIPE__SECRET_KEY="sk_test_YOUR_KEY_HERE"
export APP__STRIPE__WEBHOOK_SECRET="whsec_YOUR_WEBHOOK_SECRET"

Or create a .env file:

APP__STRIPE__PUBLISHABLE_KEY=pk_test_YOUR_KEY_HERE
APP__STRIPE__SECRET_KEY=sk_test_YOUR_KEY_HERE
APP__STRIPE__WEBHOOK_SECRET=whsec_YOUR_WEBHOOK_SECRET

🔑 Getting Your Stripe Keys

Test Keys (Development)

  1. Go to Stripe Dashboard
  2. Copy your Publishable key (starts with pk_test_)
  3. Copy your Secret key (starts with sk_test_)

Live Keys (Production)

  1. Go to Stripe Dashboard
  2. Copy your Publishable key (starts with pk_live_)
  3. Copy your Secret key (starts with sk_live_)

⚠️ Never commit live keys to version control!

🔒 Security Best Practices

  1. Never commit sensitive keys - Use .gitignore to exclude:

    • .env
    • config/local.toml
    • config/production.toml
  2. Use test keys in development - Test keys are safe and don't process real payments

  3. Use environment variables in production - More secure than config files

  4. Rotate keys regularly - Generate new keys periodically

🚀 Quick Start

  1. Copy the example files:

    cp config/local.toml.example config/local.toml
    cp .env.example .env
    
  2. Add your Stripe test keys to either file

  3. Start the application:

    cargo run
    
  4. Test the payment flow at http://127.0.0.1:9999/company

📋 Configuration Priority

The application loads configuration in this order (later overrides earlier):

  1. Default values in code
  2. config/default.toml
  3. config/local.toml
  4. Environment variables

🔍 Troubleshooting

  • Keys not working? Check the Stripe Dashboard for correct keys
  • Webhook errors? Ensure webhook secret matches your Stripe endpoint
  • Configuration not loading? Check file paths and environment variable names