We build payment software, so we have a stake in the answer. The sections below give you the trade-offs in the order a payment meets them, and you can weigh them yourself.
Payment gateway development, one payment at a time
A gateway usually follows this skeleton, and that skeleton is the payment gateway architecture you will either write or rent. What changes is how much of it your own developers touch.
1. The front door
Merchants call an API or open a hosted payment page. The door validates the request, assigns an ID to the payment attempt and decides which flow applies. Keep retries linked to the original payment, so your finance team can trace it during reconciliation.
2. The switching core
A rules layer chooses the acquirer or PSP. It reads card type, currency, amount and country, and it can also read the payment method. This layer never stops growing, because every new market adds rules that somebody has to write, test and explain to support.
3. The connectors
Each acquirer has its own API, status codes and quirks. A connector translates between that dialect and your core. Building one means reading documentation, getting a technical contact at the acquirer and testing every edge case, so the work repeats for every provider you add.
4. The card vault and the fraud layer
A gateway design can include a card vault and fraud screening. If you store card numbers, scope the vault under PCI DSS, and decide which transactions your risk rules should screen before they go out. Both sit on the route, so a weakness in either one is a weakness in the whole route.
5. The record
Each attempt, retry and outcome is written down under one ID, so that when a merchant disputes a payment three weeks later, your team can replay what the switch tried, in which order and with which provider, without guessing.
What you set when you build your own payment gateway
Even a custom build ends in configuration, so decide these early. If you plan to create your own payment gateway, these choices define the system more than any framework does.
| Decision | What it controls | Example |
|---|---|---|
| Acquirer set | How many connectors you write or buy | Two local acquirers and one global PSP at launch |
| Routing rule model | How rules are stored and changed | Edited in a dashboard, not in code |
| Retry policy | Which declines may be retried and where | Soft declines cascade, hard declines stop |
| Failure mode | What a timeout does to the checkout | Check the first attempt, then try the next acquirer |
| Deployment | Where the system runs | Your own cloud account or your own servers |
| Ownership | Who maintains the code after launch | Your team, or a vendor under contract |
The routing model is the decision people regret most. Rules that live in code need a developer and a release for every change, which turns a business question into a sprint.
When a payment goes wrong, and who fixes it
A home-built gateway meets failure on day one. A provider returns an unexpected status code, a timeout leaves a payment half-finished, or an acquirer goes down on a Saturday. Each case needs a written rule and a test, not a hope.
On a ready switching core those rules exist as settings: soft declines retry across providers within one payment flow, and failover covers timeouts, provider outages and inconsistent status codes. You still decide the policy. You just don't have to build the machinery before you can state it.
If you do go custom, the order of work is in a guide to building a gateway that starts from the same route.
Build, license or buy
The honest cost drivers of a custom gateway are developers, infrastructure and maintenance, and maintenance never ends. Three paths follow from that, and payment gateway software development sits on only the first.
- Build from scratch, if the gateway itself is your product and you can staff it for years.
- Buy the code and maintain it yourself, which our page on gateway source code explains. Check the contract for the rights you receive.
- Run a white label gateway, brand it and add what makes you different.
For the third path, plugins exist for WooCommerce, Magento and PrestaShop, and customizations can follow after launch. New acquirer connectors are the other thing to plan for, because the acquirer's documentation and the speed of its technical team set the pace.