Getting a payment button working in test mode is one of the more satisfying moments of building an app with AI. Getting it ready for real money takes a bit more care, because this is the part where mistakes cost you, or your customers, actual pounds.
Test mode and live mode
Payment providers like Stripe give you two sets of keys: test and live. Test keys move pretend money; live keys move real money. Each set has two parts:
- A publishable key, which is fine in the browser.
- A secret key, which must only ever be on your server. Anyone who has it can create charges and refunds on your account.
AI-generated code sometimes puts the secret key straight into the front end because it's the quickest way to make a demo work. Before you switch to live keys, search your code for it. If it's ever been in the browser, roll it (create a new one) in your provider's dashboard.
Don't trust the success page
The most common gap: the app marks an order as paid when the customer lands on a "thank you" page. But anyone can visit that page directly, and some people close the tab before it loads. Neither tells you anything about whether money changed hands.
The reliable way is a webhook: a message the payment provider sends to your server when a payment really succeeds. Your server checks the message is genuine (providers sign them, and your code should verify that signature), then marks the order as paid. Only then should you send the product, confirm the booking or unlock the account.



