{"id":51222217,"url":"https://github.com/dodopayments/fastapi-boilerplate","last_synced_at":"2026-06-28T08:02:48.615Z","repository":{"id":329239309,"uuid":"1112818276","full_name":"dodopayments/fastapi-boilerplate","owner":"dodopayments","description":"Minimal FastAPI boilerplate for integrating Dodo Payments into your Python application.","archived":false,"fork":false,"pushed_at":"2025-12-18T07:08:46.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-21T15:28:07.214Z","etag":null,"topics":["dodopayments","fastapi","python"],"latest_commit_sha":null,"homepage":"https://docs.dodopayments.com/developer-resources/fastapi-boilerplate","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dodopayments.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-09T06:23:14.000Z","updated_at":"2025-12-18T07:08:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dodopayments/fastapi-boilerplate","commit_stats":null,"previous_names":["dodopayments/fastapi-boilerplate"],"tags_count":null,"template":true,"template_full_name":null,"purl":"pkg:github/dodopayments/fastapi-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodopayments%2Ffastapi-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodopayments%2Ffastapi-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodopayments%2Ffastapi-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodopayments%2Ffastapi-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dodopayments","download_url":"https://codeload.github.com/dodopayments/fastapi-boilerplate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodopayments%2Ffastapi-boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34881384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dodopayments","fastapi","python"],"created_at":"2026-06-28T08:02:48.089Z","updated_at":"2026-06-28T08:02:48.605Z","avatar_url":"https://github.com/dodopayments.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dodo Payments FastAPI Boilerplate\n\n\u003ca href=\"https://discord.gg/bYqAp4ayYh\"\u003e\n    \u003cimg src=\"https://img.shields.io/discord/1305511580854779984?label=Join%20Discord\u0026logo=discord\" alt=\"Join Discord\" /\u003e\n\u003c/a\u003e\n\nA minimal FastAPI boilerplate for integrating [Dodo Payments](https://dodopayments.com/) into your Python application.\n\n## Features\n\n- **Quick Setup** - Get started in under 5 minutes\n- **Payment Integration** - Pre-configured checkout flow using `dodopayments` Python SDK\n- **Modern UI** - Clean, dark-themed pricing page with Tailwind CSS\n- **Webhook Handler** - Ready-to-use webhook endpoint for payment events\n- **Customer Portal** - One-click subscription management\n- **Type Safety** - Fully typed with Pydantic models\n- **Pre-filled Checkout** - Demonstrates passing customer data to improve UX\n\n## Prerequisites\n\nBefore you begin, make sure you have:\n\n- **Python 3.8+** (required for FastAPI and the Dodo Payments SDK)\n- **Dodo Payments account** (to access API and Webhook Keys from dashboard)\n\n## Quick Start\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/dodopayments/fastapi-boilerplate.git\ncd fastapi-boilerplate\n```\n\n### 2. Create Virtual Environment\n\n```bash\npython3 -m venv venv\nsource venv/bin/activate\n```\n\n### 3. Install Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n### 4. Get API Credentials\n\nSign up at [Dodo Payments](https://dodopayments.com/) and get your credentials from the dashboard:\n\n- **API Key:** [Dashboard → Developer → API Keys](https://app.dodopayments.com/developer/api-keys)\n- **Webhook Key:** [Dashboard → Developer → Webhooks](https://app.dodopayments.com/developer/webhooks)\n\n\u003e Make sure you're in **Test Mode** while developing!\n\n### 5. Configure Environment Variables\n\nCreate a `.env` file in the root directory:\n\n```bash\ncp .env.example .env\n```\n\nUpdate the values with your Dodo Payments credentials:\n\n```env\nDODO_PAYMENTS_API_KEY=your_api_key_here\nDODO_PAYMENTS_WEBHOOK_KEY=your_webhook_signing_key_here\nDODO_PAYMENTS_RETURN_URL=http://localhost:8000\nDODO_PAYMENTS_ENVIRONMENT=test_mode\n```\n\n### 6. Add Your Products\n\nUpdate `app/lib/products.py` with your actual product IDs from Dodo Payments:\n\n```python\nproducts: List[Product] = [\n    Product(\n        product_id=\"pdt_001\",  # Replace with your product ID\n        name=\"Basic Plan\",\n        description=\"Get access to basic features and support\",\n        price=9999,  # in cents\n        features=[\n            \"Access to basic features\",\n            \"Email support\",\n            \"1 Team member\",\n            \"Basic analytics\",\n        ],\n    ),\n    # ... add more products\n]\n```\n\n### 7. Run the Development Server\n\n```bash\nuvicorn app.main:app --reload --port 8000\n```\n\nOpen [http://localhost:8000](http://localhost:8000) to see your pricing page!\n\n## Project Structure\n\n```\napp/\n├── api/\n│   ├── checkout.py      # Checkout session handler\n│   ├── portal.py        # Customer portal redirect\n│   └── webhook.py       # Webhook event handler\n├── core/\n│   └── config.py        # Configuration settings\n├── lib/\n│   ├── customers.py     # Customer utilities (normalization, payload helpers)\n│   └── products.py      # Product definitions\n├── templates/\n│   ├── base.html        # Base template\n│   └── index.html       # Pricing page\n├── static/\n│   └── css/             # Custom styles (if needed)\n└── main.py              # App entry point\n```\n\n## Customization\n\n### Update Product Information\n\nEdit `app/lib/products.py` to modify:\n- Product IDs (from your Dodo dashboard)\n- Pricing\n- Features\n- Descriptions\n\n### Pre-fill Customer Data\n\nIn `app/templates/index.html`, replace the hardcoded values with your actual user data:\n\n```javascript\nconst customerData = {\n    name: \"John Doe\",  // Replace with actual logged-in user's name\n    email: \"john@example.com\"  // Replace with actual logged-in user's email\n};\n```\n\nIn a production app, you would get this data from your authentication system (e.g., session, JWT token, etc.).\n\n### Update Customer Portal Link\n\nIn `app/templates/index.html`, replace the hardcoded customer ID:\n\n```javascript\nconst customerId = \"cus_001\";  // Replace with actual customer ID\n```\n\n## Webhook Events\n\nThe boilerplate demonstrates handling two webhook events in `app/api/webhook.py`:\n\n- `subscription.active` - Triggered when a subscription becomes active\n- `payment.succeeded` - Triggered when a payment is successful\n\nAdd your business logic inside these handlers:\n\n```python\nif event_type == \"subscription.active\":\n    # Grant access to your product\n    # Update user database\n    # Send welcome email\n    pass\n```\n\nAdd more webhook events as needed.\n\nFor local development, you can use tools like [ngrok](https://ngrok.com/) to create a secure tunnel to your local server and use it as your webhook URL. Remember to update your `.env` file with the correct webhook verification key.\n\n## Deployment\n\n### Build for Production\n\nFor production, you can use Gunicorn with Uvicorn workers:\n\n```bash\npip install gunicorn\ngunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker\n```\n\n### Deployment targets\n\nYou can deploy this FastAPI application to any platform that supports Python/FastAPI:\nNote: FastAPI on Vercel is possible via Python Serverless Functions but is outside the scope of this boilerplate. Prefer Railway/Render for FastAPI.\n\nDon't forget to add your environment variables (API key, Webhook key, Return URL, Environment) in the deployment platform's dashboard.\n\n[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fdodopayments%2Ffastapi-boilerplate.git)\n\n\n### Update Webhook URL\n\nAfter deploying, update your webhook URL in the [Dodo Payments Dashboard](https://app.dodopayments.com/developer/webhooks):\n\n```\nhttps://yourdomain.com/api/webhook\n```\n\n## Learn More\n\n- [Dodo Payments Documentation](https://docs.dodopayments.com/)\n- [Python SDK Documentation](https://docs.dodopayments.com/developer-resources/sdks/python)\n- [Webhooks Documentation](https://docs.dodopayments.com/developer-resources/webhooks)\n\n## Support\n\nNeed help? Reach out:\n- [Dodo Payments Discord](https://discord.com/invite/bYqAp4ayYh)\n- [GitHub Issues](https://github.com/dodopayments/fastapi-boilerplate/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodopayments%2Ffastapi-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdodopayments%2Ffastapi-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodopayments%2Ffastapi-boilerplate/lists"}