A Stripe checkout can show “Payment successful” while the customer’s account stays locked. The payment and the app’s decision to grant access are separate steps. Test both with one made-up monthly plan and two dummy accounts in a private copy of your app. One account buys the plan. The other gives you a way to check that access did not open for the wrong person.
Start with a Stripe sandbox. Then check a purchase, a decline and what happens if the buyer never returns to your app. If the plan renews, rehearse the next payment and the end of access too. You can write the expected results on paper before setting up any accounts or connections.
What should a payment test prove?
Check three things for the same purchase. Stripe should show the actual payment result in the sandbox. Your app should save the result against the intended account and plan. When you open the app again, that account should see the access it paid for.
A webhook is a message Stripe sends to your app when something changes. It can reach your server even if the browser closes before returning from Checkout. Stripe can also deliver the same message again or deliver updates in a different order from when they happened. Your test should show that the app can recover the right result without giving access twice or reversing a newer decision.
How do you isolate the practice checkout?
Use a general Stripe sandbox for a new integration. Stripe’s older test mode shares some Dashboard settings with live mode. A general sandbox separates its settings and records from live Stripe. Your app’s own database and connections still need separate setup.
Before opening Checkout, verify all three boundaries:
| Check | What you should see |
|---|---|
| Stripe | The Dashboard, the app’s server key, any publishable key it uses, and the test plan’s price all belong to the same named sandbox. A test-key prefix alone does not identify which sandbox you selected. Keep the server key private. |
| Your app | The local or private test copy uses a disposable database and test-only sign-in. Both dummy accounts are there, neither has paid access, and there are no real customer records. Disable outgoing email and other side effects or route them to a test-only capture tool. |
| Stripe messages | Your test app receives messages from that sandbox. It checks the signature with the secret for the exact sender: your sandbox webhook destination or the local Stripe CLI listener. Keep that secret out of source control and shared logs. |
For a local app, set up the CLI listener described below before opening Checkout. For a hosted test copy using this example, create an event destination in Workbench inside the named sandbox. Choose Your account, then Snapshot and the API version your test handler expects. Select the events the handler uses. Choose Webhook endpoint and enter the test copy’s exact HTTPS webhook address. Stripe needs to be able to reach that route, and the route must verify signatures.
The CLI example below listens for one event. Before testing later results, restart the local listener with the additional event types in its comma-separated --events list or use a sandbox destination configured to send them. For delayed payments, include checkout.session.async_payment_succeeded and checkout.session.async_payment_failed. For recurring plans, include the invoice and subscription events your handler uses, such as invoice.paid, invoice.payment_failed, customer.subscription.updated and customer.subscription.deleted.
If you cannot verify a boundary, stop at the paper checks. A test payment does not move real money, but your app can still write to a live database or send a real message if it is connected to one.
Which Stripe payment results should you check?
Use the isolated test copy and Stripe sandbox you verified above. Start each new purchase case with a clean dummy account or reset its records in the test copy. Sign in and open Checkout through your app so it uses the intended account and sandbox price. Use only Stripe’s test cards in the sandbox. The two cards below accept a future expiry date and a three-digit CVC.
| Try this | What to check |
|---|---|
Pay with 4242 4242 4242 4242 | Stripe shows a successful test payment for the intended Checkout session, with the expected plan, amount and currency. Reopen the app and confirm the buyer has the plan. The other dummy account stays locked. |
Pay with 4000 0000 0000 0002 | The app or Checkout shows a decline and a way to try again. A failed-attempt record can stay for diagnosis. It should remain unpaid and open no paid access. |
| Pay successfully without using the return page | Close the browser after Stripe confirms the test payment. If the browser returns immediately, use a test-only return page that does no access work. Keep the webhook running. Reopen the workspace directly and confirm access came through once. |
| Receive the same valid payment notification twice | Deliver the same event ID twice in a local automated test. If the test goes through the webhook endpoint, use a valid test signature. The app should keep one paid result and one access grant for that purchase. Test a second copy arriving at the same time if your app processes messages in parallel. |
If you offer a payment method that settles later, test the waiting state too. A completed Checkout session can still have an unpaid result. The app should wait for confirmation from Stripe before opening paid access, and show a useful way forward if the payment later fails. Stripe Checkout fulfillment
What should happen after the first month?
For renewal and period-end cancellation, start each case with a fresh paid dummy subscription from your test app. When the sandbox subscription is eligible, open it in the Dashboard, choose Run simulation, and advance the test clock to the date you want to check. Wait for the simulation to finish. Read the invoice, subscription and app records before deciding whether the test passed. Stripe Billing simulations
| Try this | What to check |
|---|---|
| Advance a paid subscription to renewal | The new invoice is paid, the subscription is active and the original account keeps access for the next period. There is one renewal result for that invoice. |
| Simulate a failed collection separately | Start with a separate dummy customer. Set test card 4000 0000 0000 0341 as its default payment method, then create a subscription with a short trial and automatic card collection for this case. After that trial ends, wait for its invoice to finalize and collection to be attempted. Confirm invoice.payment_failed for that invoice, read the invoice and subscription status, and check the expected recovery behavior. |
| Schedule cancellation at the end of the paid period | The dummy buyer keeps access through the paid period and loses it when the subscription actually ends. Check both sides of that time boundary. |
| Test refunds if your app uses them to decide access | Start with saved local examples of a full and a partial refund. Check the money record and the app’s access rule separately. A refund on a past payment does not itself tell your app whether future billing should continue. |
If the failed-collection subscription has no matching account in your test app, it can show whether the failure message reached the handler. To test whether access changes, use a correctly linked dummy subscription or a saved local example with a known account and starting access.
Use the Stripe examples for renewals, cancellations and refunds to choose what your app should do before you write a check for it. If an older notification arrives after a more recent change, the app should use the current provider record and protect the newer access decision from an older update.
What should run automatically, and what needs Stripe?
Run routine tests in your automated checks before merging changes. Use saved examples and simulated Stripe replies to cover your app’s logic without opening hosted Checkout on every run. Stripe’s hosted payment screens have protections against automated use. Keep a separate, occasional sandbox check for the real Checkout flow and message delivery.
| Check | What it tells you |
|---|---|
| Local examples and simulated replies | Your app’s rules handle declines, duplicate or late notices and the wrong workspace. Test signature rejection separately. Stripe’s signature check needs the original request body. A direct call to your payment logic does not exercise that check. |
| A Stripe CLI sample event | A Stripe test event can reach your running local endpoint and pass its signature check. The sample can create unrelated Stripe objects and may send other events. It does not prove that your app created Checkout for the right customer. |
| Checkout opened from your isolated app | The sandbox price, payment and message agree with the account and purchase your app created. It is the check that joins Stripe’s record to your app’s access. |
If you are testing a snapshot event locally, sign in to the Stripe CLI and select the intended sandbox and confirm the other practice boundaries again. Start your app, then forward to its actual local webhook route. For example, if it uses port 3000 and the route below:
stripe listen --forward-to localhost:3000/api/webhooks/stripe --events checkout.session.completed
Wait for the listener to report that it is ready. If you automate this step, use a timeout and fail if it never reaches readiness. Put the listener’s signing secret into the private local app configuration and reload the test server if it reads configuration at startup. Keep the terminal output with the secret out of shared logs. Confirm the app is running with that setup before sending an event from the same sandbox.
stripe trigger checkout.session.completed
Check that the signed message reached the local handler. The built-in sample uses objects it creates for the example. If it does not match an app-created checkout, it should open no access. To check a paid result on your own dummy workspace, use the app-created Checkout flow. Stop the listener after the test.
The CLI also accepts a JSON file of sample API requests with stripe fixtures <filepath>. Review what the file creates or changes in the sandbox first. Use an offline test with saved examples if you just need to exercise your own code. Stripe CLI fixtures
What should you record before turning on live payments?
Keep a short test record with the app version, sandbox name, cases you ran and what you saw in Stripe and in the two app accounts. Keep secrets and card details out of it. If a case fails, fix the app or setup and repeat that case from a fresh test record. Recheck the main checkout when you change the app’s billing or access rules.
Before enabling live checkout, review the intended live configuration separately. A sandbox pass shows what your practice copy did. The live app needs the correct plan, endpoint and credentials for its own environment, and a clear way to investigate when a payment arrives but access does not.