How to Accept Payments in Your App with Stripe
Taking money online is mostly a solved problem, if you let Stripe hold the card and you trust only its webhook. Here is the flow, the data you store and the mistakes to avoid.

Key takeaways
- Use a hosted checkout page so card details never touch your app. Stripe handles card security and most payment methods.
- Your server sets the price, and only a verified webhook from Stripe marks an order as paid. Never trust the browser on either.
- Subscriptions add states (trialing, active, past due, canceled) that your app must mirror from Stripe's events.
The simplest reliable way to accept payments in your app is Stripe Checkout: your server creates a checkout session with the items and prices, the customer pays on a page hosted by Stripe, and Stripe notifies your server through a webhook when the payment succeeds. Your app never sees card numbers, Stripe handles cards, wallets and fraud checks, and your database records what was bought. The same pattern works for one-time purchases and subscriptions.
The payment flow, step by step
Here is what happens when someone buys a $25 workshop ticket:
- 01The customer clicks "Buy ticket". The app calls your server function with the ticket type, not a price.
- 02The server looks up the real price ($25) in the database, creates a pending `orders` row, and asks Stripe for a checkout session, attaching the order ID as metadata.
- 03Stripe returns a checkout address. The app sends the customer there.
- 04The customer pays on Stripe's page, with card, Apple Pay, Google Pay or other methods you switched on.
- 05Stripe redirects the customer to your "thank you" page. Important: this redirect is not proof of payment.
- 06Stripe sends a signed `checkout.session.completed` webhook to your server. The server verifies the signature, finds the order by its ID and marks it paid, then sends the ticket email.
Why step 6 and not step 5? Customers close tabs, lose signal and press back. Some payment methods take time to confirm. The webhook arrives regardless, and it is signed with a secret only Stripe and your server know, so it cannot be faked.
What your database stores
You do not store card details, ever. You store what you need to deliver and support the purchase:
- `products` or `prices`: what you sell and for how much, owned by your server, not editable by customers.
- `orders`: who bought what, the amount, the currency, a status (pending, paid, refunded) and Stripe's session or payment ID so you can match them later.
- For subscriptions, a `subscriptions` row per customer with the plan, the Stripe customer and subscription IDs, the status and the current period end.
One-time payments vs subscriptions
One-time payments are the easy case: pending, then paid, occasionally refunded. Subscriptions are a small state machine that lives in Stripe, and your app mirrors it:
- trialing: free trial running. Full access.
- active: paid and current. Full access.
- past_due: a renewal payment failed and Stripe is retrying. Usually keep access for a grace period and show a "update your card" banner.
- canceled: ended. Remove premium access.
Listen for `customer.subscription.updated` and `customer.subscription.deleted` (and `invoice.payment_failed` if you want to email people), and update your `subscriptions` row each time. Your app then checks one column to decide what to show. For plan changes, cancellations and card updates, Stripe's hosted Customer Portal saves you building those screens.
Fees, refunds, disputes and tax
- Fees: Stripe charges per successful payment. Standard US card pricing has long been around 2.9 percent plus 30 cents, with differences by country, card type and currency. Check Stripe's pricing page for yours, and price your product with it in mind.
- Refunds: issued from the Stripe dashboard or through the API. Listen for the refund event and update the order.
- Disputes (chargebacks): a customer asks their bank to reverse a charge. Clear product names on statements, receipts and an easy refund policy prevent most of them.
- Tax: depending on where you and your customers are, you may need to collect sales tax or VAT. Stripe offers tax tools; whether you must collect is a question for an accountant.
Test before you take real money
Stripe has a separate test mode with its own keys. Use the test card `4242 4242 4242 4242` with any future expiry date and any CVC to simulate success, and Stripe's other documented test cards for declines and extra authentication. Run through: a successful purchase, a declined card, closing the tab right after paying (the webhook should still mark the order paid), a refund, and for subscriptions, a failed renewal. Switch to live keys only when all of those behave.
A note on native store apps
Web apps can use Stripe for anything. Native apps sold through the App Store or Google Play have their own rules for digital goods sold inside the app, which often require the stores' own billing systems; physical goods and real-world services generally can use Stripe. The rules change, so check the current store guidelines before you design pricing for a native app.
Receipts, statements and support
Most payment support tickets are not about bugs. They are "what is this charge?" and "I was charged twice". A little setup prevents both:
- Statement descriptor: the short name that appears on card statements. Set it in Stripe to something people recognize, such as your app's name rather than your legal company name.
- Receipts: Stripe can email receipts automatically. Your own confirmation email can then focus on what happens next (the ticket, the access link, the delivery date).
- Duplicate protection: disable the Buy button after the first click and reuse an open checkout session for the same cart, so a nervous double tap does not create two orders.
- A written refund policy: linked from the checkout page and the receipt. Clear policies settle disputes before they reach a bank.
- An order page: let customers see their past orders and statuses in the app. It answers half the questions before they are asked.
Keep the Stripe payment ID on every order row. When a customer writes in, you can find the exact payment in the Stripe dashboard in seconds instead of searching by email and amount.
Payments in a Startbase app
Payments in Startbase Cloud run on your own Stripe account. Money lands there directly, Startbase never holds it, and Startbase adds no fee of its own (Stripe's fees still apply). The recommended path is Stripe Connect: click Connect with Stripe, finish Stripe's onboarding (business details, bank account), and once the status reads Ready your app starts checkouts with `createCheckout` from its helper library, with no keys in your code. If you prefer to wire it yourself, the manual path saves your `STRIPE_SECRET_KEY` in Secrets, has the agent scaffold checkout and billing, and registers a webhook with its `STRIPE_WEBHOOK_SECRET`. Either way, Stripe keys only reach edge functions, never client-side code. Full steps in the payments docs.
Add paid memberships to my yoga studio app with Stripe. Two plans: Monthly at $29 and Yearly at $290, both with a 7-day free trial. Members get access to the video library; everyone else sees the class schedule only. Mark people as members only from Stripe webhooks, show a "payment failed, update your card" banner when a renewal fails, and add a Manage billing button that opens Stripe's customer portal.
For marketplaces where you pay out to sellers, payments get more involved; our marketplace guide covers that shape. And because the webhook is just an API call in reverse, what an API is is useful background.
Frequently asked questions
Do I need to be PCI compliant to accept payments?
Every business taking cards has some PCI obligations, but using a hosted checkout like Stripe Checkout keeps card data off your servers entirely, which makes your share of the work small. Stripe documents what remains for you.
How much does Stripe charge?
A percentage plus a fixed amount per successful payment, varying by country and payment method. Standard US card pricing has long been about 2.9 percent plus 30 cents. Check Stripe's current pricing for your country.
Why not just mark the order paid on the success page?
Because anyone can open that page, and customers sometimes close the tab before reaching it. A signed webhook from Stripe is the only reliable proof of payment.
Does Startbase take a cut of my payments?
No. Payments go to your own Stripe account and Startbase adds no fee of its own. Stripe's processing fees apply as usual.

