How to pick a payment API for vibe coding an app
When an AI assistant writes the code, choose the payment API that fails safe: hosted card entry, server-set prices, verified confirmation and one Test purchase you can trace.
For a payment API to vibe code with, choose one that keeps card entry on a hosted page, lets your server decide the price, and hands you a confirmed payment record you can verify before delivering anything. Railbed is built for that flow, and it takes ordinary businesses and the ones mainstream processors turn away, with no application to pass. This guide explains what the coding assistant should build, in which order, and what you personally check before a real customer pays.
Why the API choice decides whether your app can take money safely
Vibe coding means you describe what you want and an AI assistant writes most of the code. That works well for screens, forms and simple logic. Money is the part where small mistakes cost real cash: a price the browser can edit, a confirmation the app trusts too early, a secret key pasted where anyone can read it. The API you pick determines which of those mistakes are even possible.
The safest shape for a first app is the one documented in Railbed's checkout session workflow: your server creates a session with an amount, currency and reference; the buyer pays on the hosted page; your server receives a notification, verifies it and re-reads the payment before fulfilling. No card number ever touches your code. Compare that with a raw card-processing API where the assistant would have to build card entry, validation and error handling itself, on a website that may not even have a proper backend yet.
That is the first filter: pick an API whose dangerous parts are done for you. Card entry, buyer identity checks and the payment page are the provider's job. Your code handles three things: deciding the price, saving the order and confirming payment before delivery. Railbed's developer documentation is written for exactly that division, and the assistant can read it as Markdown.
The second filter is whether the account can actually go live. A side project in a mainstream processor's restricted category can be approved in Test and rejected at activation, which means weeks of code written against a gateway that will never take your customer's money. Railbed has no application to pass, so any business signs up the same way, including the ones processors turn away. That doesn't change what you may lawfully sell; it removes the gate that stalls most vibe-coded apps at the worst moment, after the build, before the first sale.
Ask for hosted checkout, not a card form
Tell the assistant what you want in one sentence: "Use Railbed's checkout session API so the buyer pays on Railbed's hosted page; my server creates the session and verifies the payment." That single instruction avoids the most common vibe-coding failure, which is an assistant confidently building a card form inside your app because a tutorial it half-remembers did that.
A hosted flow also keeps the integration small enough to review. When the assistant finishes, you should be able to read every file it touched in a few minutes: the products file with prices, the checkout route, the notification handler and the fulfillment function. If the diff is a thousand lines of custom card logic, validation rules and retry machinery, that is the wrong API choice, not a better one. Railbed's own recipes keep the code to a handful of small files; the Next.js recipe is a good template even if your app uses another framework, because the shapes transfer: server-side products, one checkout route, one webhook, one fulfillment function.
Ask the assistant to show you where each of these lives before it writes anything:
- The price: a server-side list the browser can only reference by product id.
- The order: a saved record with the amount, currency, buyer and an internal reference.
- The session: the API call that turns the saved order into a payment page.
- The confirmation: the notification handler that verifies, re-reads and matches the payment.
- The delivery: one function that grants access or records shipment exactly once.
If your app is nothing but a landing page with no server at all, stop earlier: a fixed offer is better served by Railbed's reusable checkout page, which needs no code. See hosted checkout versus payment links for that decision.
Keep the price where the browser can't reach it
The classic vibe-coded payment bug is a client-side price. The assistant puts the amount in the button's code, the buyer edits it in the browser's developer tools, and the app charges two dollars for the hundred-dollar plan. The fix is structural, not careful review: the browser sends only a product id; the server looks up the price in its own list; the session is created from that.
Railbed's API enforces this shape naturally, because the session's amount is set server-side. But the assistant can still get it wrong in the other direction: accepting an amount from the client "to support custom tips" and passing it through. If you genuinely sell variable amounts, treat the client value as a suggestion, validate it against your own rules server-side, and record what rule produced the final number. Otherwise, refuse it: "prices are fixed on the server; the client sends an id."
Currency works the same way. If the app shows converted prices for convenience, the session must still be created in the currency your business actually sells in. Record that currency on the order. A report that mixes a displayed conversion with the collected currency is how finance ends up explaining numbers that don't match anything.
One more server-side rule: the order record is created before the session, with the amount, currency and an internal reference you control. Pass that reference into the session. When the confirmation arrives, your handler matches it back to the saved order. If the assistant skips the order table "to keep it simple", the app has no memory, and every later question, from support to refunds to reconciliation, becomes guesswork.
Verify payment before anything ships
The second classic bug is trusting the return. The buyer lands back on your success page and the app marks the order paid and unlocks the product. The page visit is not evidence. The buyer may have closed the tab before paying, the payment may still be processing, or the URL may be a link someone shared.
Railbed's fulfillment guide gives the correct order of operations: verify the notification's signature, re-read the payment from the API, check its amount, currency, reference and mode against your saved order, and only then fulfill, once. Write that rule into the assistant's brief in plain words: "The success page only shows status from the database. Only the verified webhook path marks an order paid."
Then make the assistant prove it, not just claim it. In Test mode, run the documented scenarios: a successful payment, a declined one, an underpaid one that stays held, and the same legitimate event delivered twice. The webhook verification guide lists what each path should produce. A vibe-coded app that passes "pay and unlock" but delivers twice on a replayed event is one background job away from giving your product away.
Ask for the evidence in writing. Railbed maintains checkouts.md, an open format where the project records its products, wiring, fulfillment rule and dated test results. Have the assistant fill it in as part of the job, not as an afterthought. When you come back to the app in three months, that file is the difference between a five-minute recall and an archaeology dig.
Handle keys, environments and go-live like an owner, not a tester
API keys are the part of vibe coding most likely to leak. The assistant needs a Test key to build against; it does not need it in the chat transcript, the git history or the client-side bundle. The documented flow creates keys through the Railbed CLI and writes them into a gitignored environment file on your machine. You approve the connection in the browser. The assistant never sees the secret value, and you never paste one into a prompt.
Keep Test and Live visibly separate until go-live day. A Test button that looks identical to production is how a real customer ends up paying a simulated amount, or worse, how a demo appears in your sales report. The recipes handle this by keeping the Live key out of the project until the go-live step pushes it to the server's environment. Follow that order even when it feels slow: it exists because the alternative has burned real stores.
Go-live itself is a checklist, not a vibe. Set the production callback addresses, register the Live endpoint, deploy, then run the end-to-end checks: a real attempt on the production site that you refund or cancel yourself if your product allows it, the first verified notification, and the first settlement you can see in your wallet. Railbed never holds funds; card sales settle to a wallet the merchant controls, almost always as USDC on Polygon, and settled sales can't be pulled back from your wallet. That is the settlement story; disputes and refunds still follow their own rules.
If the app takes off, the same structure scales: more products in the server list, the same one-time fulfillment rule, the same verification. If it doesn't, you've spent an afternoon, not a month. See Railbed for software and online services for how subscription and one-off sales fit the same account.
What to check in the assistant's work, in order
Read the diff yourself before running anything, even if you can't write code. You are looking for shape, not syntax:
- Prices appear in exactly one server-side file, and the client sends ids only.
- An order is saved before the session is created, carrying amount, currency and reference.
- The success page reads from the database and never marks anything paid.
- The notification handler verifies the signature, re-reads the payment and matches it to the order before fulfilling.
- Fulfillment runs once per order, inside the recorded update, not in a fire-and-forget job.
- No secret appears in any file the browser loads, any committed file, or the chat itself.
Then sit beside the assistant while it runs the Test scenarios and watch the results in the dashboard, not just in the logs. When one sale is traceable end to end, from the button you clicked to the verified payment and the delivered product, the API choice has done its job.
Common failure patterns, and the instruction that prevents each
Vibe-coded payment code fails in patterns, not at random. Each has a one-line instruction that prevents it, which you can paste into the assistant's brief before it writes anything.
| Failure pattern | What it looks like later | Instruction that prevents it |
|---|---|---|
| Client-side price | Buyer edits the button payload and pays $2 for the $100 plan | "The client sends a product id only; the server owns the price." |
| Return-page trust | Order marked paid because the buyer landed on /success | "The success page reads status from the database; it never sets it." |
| Skipped verification | Unverified notification fulfills an order | "Verify the signature, re-read the payment from the API, match it to the order before fulfilling." |
| Double delivery | Replay of a legitimate event grants the product twice | "Fulfillment runs once per order, guarded inside the same update that marks it paid." |
| Leaked secret | Key found in the repo, the chat log or a client bundle | "Keys live in a gitignored server environment file, created through the documented CLI flow." |
| Mode mix-up | A Test payment appears in a Live report, or the reverse | "Every order and payment record carries its mode; reports filter by it." |
| No order memory | Support cannot tell what a payment was for | "Save an order with amount, currency, buyer and reference before creating the session." |
None of these are exotic. They are the seven mistakes an eager assistant makes when nobody states the boundary, because each one produces code that appears to work in the happy path. The happy path is precisely what a demo shows you and what a real buyer immediately leaves. State the boundaries up front and the review step shrinks to checking that they were respected.
A useful trick is to make the assistant argue against itself before writing code: "List the ways this integration could pay out wrongly or deliver twice, then write the code that prevents each." The failure list it produces is a better review checklist than anything generic, because it references the actual files it is about to write. Keep that list next to the checkouts.md evidence when you commit.
Plan for the buyer who doesn't finish, and the sale that's ambiguous
A working checkout is half the flow. The other half is everyone who stops partway, and the first thing you'll be asked about once real traffic arrives.
Design the incomplete path deliberately. A buyer who abandons at the hosted page should be able to return to your app and try again without the old attempt haunting the cart. That means your app keeps the prior attempt visible, checks its state before inviting a second payment, and never sends two sessions for the same order reference. Railbed's payments documentation describes the states an attempt can sit in; map each one to a single sentence your support person can say.
Write those sentences now, in Test, while nothing is on fire:
- "We're still confirming your payment" for an attempt that is processing.
- "That payment didn't complete; you can try again from your order page" for a failed or expired one.
- "Your payment is being reviewed; we'll email you when it's done" for a held one.
- "We received your payment and your order is prepared" for a paid one awaiting delivery.
The difference matters because the buyer's question in each case is different: whether to wait, whether to retry, whether anything is wrong on their side, or whether delivery is coming. A single vague error message that says "try again" for all four is how a paid customer gets told to pay twice, and how an unpaid one gets a product. This is the same boundary the payment summaries for finance guide draws for reporting: confirmed, held and settled are different facts, and collapsing them is the root of most confusion.
Ambiguous sales need a home too. If a payment arrives that matches no saved order, or an amount doesn't match any order, the correct action is a human, not an automated guess. Build an exception view, even a simple one: unmatched payments, held payments, and paid orders whose delivery hasn't been confirmed. When your app is one week old, that list is empty and the work feels unnecessary. When it's one year old and processing hundreds of orders, it is the difference between a ten-minute investigation and a refund you didn't owe.
For subscriptions, the same pattern applies with more states. Railbed's subscriptions bill by invoice each period rather than by automatic card charges, which changes what your app should model: the subscription, the invoice per period and the verified payment are three records. If the assistant models subscription state as a single boolean, push back and ask it to mirror the documented model, or see managing Railbed subscriptions with an AI assistant for the full walkthrough.
FAQ
What kind of payment API should an AI-coded app use?
A hosted checkout API. Your server creates the session and verifies the payment; the provider handles card entry, the payment page and buyer checks. That keeps the integration small enough to review and removes card data from your code entirely.
Can I vibe code a custom card form instead?
You can, but you shouldn't for a first app. Card entry, validation and error handling are exactly where AI-written code fails expensively, and handling raw card data adds obligations your side project doesn't want. Use the hosted page.
How do I stop the buyer editing the price in the browser?
The browser never sends an amount. It sends a product id; the server looks up the price and creates the session from it. Verify that the assistant's diff has no amount in any client-side file.
Is visiting the success page proof of payment?
No. Only a verified notification, re-read from the API and matched to your saved order, proves payment. The page should show status from your database, never set it.
Where do API keys go in a vibe-coded project?
In a gitignored server-side environment file, created through the documented CLI flow where you approve the connection. Never in the chat, the repository or a client-side bundle.
When do I switch from Test to Live?
After the documented Test scenarios pass: successful, declined, underpaid, replayed. Go live with one offer, watch the first real notification and settlement, then add more.
Does Railbed work for high-risk side projects?
Yes. There is no application to pass, so restricted categories sign up the same way as ordinary ones. That removes the approval gate; it does not change what you may lawfully sell.
The one-purchase standard
Whatever the API, hold your vibe-coded app to one standard before showing it to a customer: a single Test purchase, traceable from the button through the verified payment to the delivered product, with the evidence written down in the project. If that trace exists, the integration is real. If it doesn't, the app is a demo wearing a checkout.