reflex-stripe
Stripe payment components for Reflex applications
A Reflex custom component library wrapping @stripe/react-stripe-js for seamless Stripe payment integration in Python.
Features
- Express Checkout — Apple Pay, Google Pay, and Link via
ExpressCheckoutElement - Embedded Checkout — Full Stripe-hosted checkout form in an iframe
- Backend State Management —
StripeStatehandles PaymentIntents and Checkout Sessions - API Routes — Auto-registered FastAPI endpoints for client-server communication
- Type-Safe Config — Pydantic-style
Appearance,ExpressCheckoutOptions, and more
Installation
pip install reflex-stripe
uv add reflex-stripe
Quick Start
Express Checkout
Drop in a complete Express Checkout (Apple Pay / Google Pay) with a single provider:
import os
import reflex as rx
import reflex_stripe as stripe
def checkout_page() -> rx.Component:
return stripe.stripe_provider(
stripe.ExpressCheckoutBridge.create(
return_url="/checkout/complete",
),
publishable_key=os.environ["STRIPE_PUBLISHABLE_KEY"],
secret_key=os.environ["STRIPE_SECRET_KEY"],
mode="payment",
amount=1099,
currency="usd",
)
Embedded Checkout
Render a full Stripe Checkout form as an embedded iframe:
import os
import reflex as rx
import reflex_stripe as stripe
def checkout_page() -> rx.Component:
return stripe.embedded_checkout_session(
publishable_key=os.environ["STRIPE_PUBLISHABLE_KEY"],
secret_key=os.environ["STRIPE_SECRET_KEY"],
line_items=[{
"price_data": {
"currency": "usd",
"product_data": {"name": "Pro Plan"},
"unit_amount": 2000,
},
"quantity": 1,
}],
return_url="/checkout/complete",
)
Register API Routes
Register the Stripe backend endpoints on your Reflex app:
app = rx.App()
stripe.register_stripe_api(app)
Architecture
reflex_stripe/
├── base.py # StripeBase — shared component base class
├── models.py # Appearance, ExpressCheckoutOptions, ButtonType, etc.
├── stripe_provider.py # StripeProvider wrapping <Elements> + loadStripe
├── stripe_state.py # StripeState — PaymentIntent & Checkout Session management
├── express_checkout.py # ExpressCheckoutElement + JS bridge
└── embedded_checkout.py # EmbeddedCheckoutProvider + EmbeddedCheckout + bridge
| Layer | Component | Purpose |
|---|---|---|
| Provider | StripeProvider |
Wraps <Elements> with loadStripe() |
| Elements | ExpressCheckoutElement, EmbeddedCheckout |
Stripe UI components |
| Bridges | ExpressCheckoutBridge, EmbeddedCheckoutBridge |
JS glue for event handling |
| State | StripeState |
Backend payment logic (PaymentIntents, Sessions) |
| API | register_stripe_api() |
Auto-registers /api/stripe/* endpoints |
Environment Variables
| Variable | Required | Description |
|---|---|---|
STRIPE_PUBLISHABLE_KEY |
Yes | Stripe publishable key (pk_test_... or pk_live_...) |
STRIPE_SECRET_KEY |
Yes | Stripe secret key (sk_test_... or sk_live_...) |
Development
task install # Install dev deps + pre-commit hooks
task lint # Run ruff linter
task typecheck # Run pyright type checker
task test # Run full test suite
task run # Run demo app
task run-docs # Run docs locally
Requirements
- Python 3.11+
- Reflex >= 0.8.0
- Stripe Python SDK >= 12.0.0
Contributing
Contributions welcome. Please run task lint and task test before submitting a PR.
License
Metadata
Release files for reflex-stripe 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| reflex_stripe-0.1.1.tar.gz | 22.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| reflex_stripe-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.7 kB
Release files / reflex_stripe-0.1.1.tar.gz
| Download URL | reflex_stripe-0.1.1.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de73866e085a28562de70bd82275ebbca018b166f72e9c7e8de62c1c707fdf30
|
|
BLAKE2b-256 checksum How to use checksums |
ac16922be8cfae50786077e0c5f380e745c103fe5a5b560b3e59495ad8ea7955
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.5
|
Release files / reflex_stripe-0.1.1-py3-none-any.whl
| Download URL | reflex_stripe-0.1.1-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9c7cce24e8b1785d11d3992a441e9319db7f4e015e752708315bc3123a5ed95
|
|
BLAKE2b-256 checksum How to use checksums |
9ef8218a8ae04f4aca9b7d0f7ba3e0f24b25f8b46de1ea1970af42a107f48a74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.5
|