Menu

Razorpay and Stripe in one FastAPI app, without trusting the browser
📰

Razorpay and Stripe in one FastAPI app, without trusting the browser

DEV Community: fastapi·Aravind Govindhasamy·17 days ago
#THREGu0s
#devtofastapi#devto#dev#payment#payments
Reading 0:00
15s threshold

If you sell to customers in India, you want UPI, and for that you want Razorpay. If you also sell abroad, Stripe Checkout is the easiest way to take cards. The starter does both from one FastAPI app, with one rule that matters more than either provider: the browser never decides that a payment succeeded.

Prices live on the server

Products and their prices are a dictionary in backend/app/api/payments.py :

PRODUCTS : dict [ str , dict ] = { " pro " : { " name " : " Pro upgrade " , " plan " : " pro " , # profiles.plan after payment " prices " : { " stripe " : ( 1900 , " usd " ), " razorpay " : ( 149900 , " inr " )}, }, }

Enter fullscreen mode

Exit fullscreen mode

Amounts are in minor units (cents and paise). The client sends a product id, never an amount, so nobody can buy the Pro plan for one rupee by editing a request.

Pending until a webhook says otherwise

Checkout creates a pending row in payments and returns the provider's checkout URL or order.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.