Add Stripe to your app without card numbers touching your server
The short version
Stripe looks like just a payment form, but the form was never the hard part. Holding card numbers is. With Stripe Checkout (Stripe's hosted payment page) or the Payment Element, the card goes straight from your customer to Stripe and never passes through your server. That keeps most of the banks' card-security rules (PCI) off your plate, and Stripe also screens for fraud, retries failed subscription payments and pays out to your bank.
Build it yourself vs Stripe Checkout
| Job |
Build the form yourself |
Stripe Checkout |
| Card numbers |
land on your server |
go straight to Stripe |
| Banks' security rules (PCI) |
full yearly checks are your job |
a short self-assessment |
| Stolen cards testing your form |
your job |
Stripe Radar flags them |
| Cards that expire mid-subscription |
your job |
Smart Retries and card updates |
| Paying you out |
you wire it up |
automatic payouts to your bank |
| The catch |
|
a fee on every sale, first payout in 7-14 days |
Copy these prompts
Add Stripe Checkout to this app.
- Use Stripe's hosted Checkout page (or the Payment Element). Card numbers must never reach our server or our database.
- Create a Checkout Session on the server with the secret key from an environment variable; never ship the secret key to the browser.
- Add a webhook endpoint for checkout.session.completed and verify the Stripe signature before trusting it. Mark the order or subscription paid ONLY from the webhook, not from the success page.
- For subscriptions, use Stripe Billing and turn on Smart Retries for failed renewals.
- Use test mode and the test card 4242 4242 4242 4242 until I say go live.
- Show me the files you changed and how to run the webhook locally with the Stripe CLI.
Before we go live with Stripe, check this app and list anything that fails:
1. Is the Stripe secret key only on the server, in an environment variable?
2. Is "paid" set only from a verified webhook, never from the success page?
3. Does any code, log or database column store a full card number? (It must not.)
4. Do refunds and disputes have an owner and a written policy?
If you are building your first paid app
| Check |
Why |
| Secret key only on the server |
a leaked secret key can move money |
| Paid status from the verified webhook |
the success page can be faked or closed early |
| Test mode end to end first |
real cards cost real fees and refunds |
| Your first payout timing |
Stripe's first payout typically takes 7-14 days, depending on country, industry and risk |
| The fee in your country |
Stripe keeps a cut of every sale; check stripe.com/pricing |
Run this on your codebase
Search this codebase for anything that touches raw card data: inputs named card/cc/cvc, logs or database columns that could hold a card number, and any payment call that sends card details to our own server. Replace each with Stripe Checkout or the Payment Element and show me the diff.
Sources
- Stripe security guide (docs.stripe.com/security/guide): low-risk integrations send payment details directly to Stripe without passing through your servers.
- Stripe payouts (docs.stripe.com/payouts): the first payout typically completes in 7-14 days.
- Stripe Billing Smart Retries (docs.stripe.com/billing/revenue-recovery/smart-retries); Stripe Radar (docs.stripe.com/radar).