International payment gateways: what they all share

This note is about what all payment gateways share. At a travel software company, the ticketing system had to take payments from customers in several countries. So I implemented PayPal, EMS, Paysafe, Stripe, Mollie, Pay.nl and Ogone, alongside several Iranian gateways. At first each looked like its own world: one wants a form POST, one a token API, one an HMAC signature, one a redirect with odd parameters.
After the third or fourth, I saw they all do the same few things.
Five things all payment gateways do
- Start: a payment is created with an amount, a currency and an order id.
- Send the customer: to the gateway's page, or the gateway's form opens on ours.
- Return: the customer comes back to the site with a result.
- Verify: the site asks the gateway itself what really happened.
- Afterwards: refunds, cancellations, or notifications the gateway sends later.
One contract, one adapter per gateway
So the system worked against one contract, and each gateway was an adapter translating those five steps into its own language. The payment flow (creating the order, holding the seat, issuing the ticket) never knew which gateway was behind it. A new gateway meant a new adapter, not touching the sales flow.
Don't trust the return, ask
This is the most important rule. A customer coming back with a "success" parameter doesn't mean the payment succeeded. Parameters can be tampered with, a browser can close halfway, and some gateways report the final result minutes later. The final status is always asked of the gateway itself, server side.
A few smaller lessons
- Compute the amount on the server. An amount from a form is only a suggestion.
- Verification must be idempotent. If the gateway notifies twice or the customer refreshes, the order isn't confirmed twice.
- The smallest currency unit. Keep amounts as integers in the smallest unit, never floats.
- Every transaction leaves a trail. Each gateway request and response is stored, because on the day a customer says "the money left but no ticket came", that trail answers.
In SimaCMS today
The same principles live in SimaCMS: Iranian gateways, the wallet and buy-now-pay-later are each an adapter behind one shared payment contract, and the store, bookings and courses only say "sell this". Years have passed and the gateways changed, but those five steps and that one rule haven't.
I used the same "one contract, many adapters" pattern for sources with no API in the flight system's crawlers, and for a store where WooCommerce is the source of truth. Stripe's documentation is a good example of a clean payment gateway API.
Comments
Sign in to leave a comment.
Sign inLoading…


