Payment gateway integration is usually described as a checkout problem: the customer pays, the money arrives, the order is marked paid. In business software, that is only the first step. An ERP or invoicing system also has to record the payment against the right invoice, handle refunds and failed charges, and reconcile the gateway report with the bank account at month end. This article lists what to plan for before you write any code.
Why payment gateway integration is harder inside business software
A retail store can often rely on the gateway dashboard to see what was paid. An ERP cannot. It needs to know which invoice a payment belongs to, whether the amount is partial, which branch or company received it, and how it affects accounts receivable. When these details are missing, finance staff end up matching payments by hand from spreadsheets, and the ERP stops being the source of truth.
For a broader view of what a point-of-sale or ERP should cover, see our notes on ERP system design and the POS subscription option for smaller retail and hospitality operations.
The integration checklist
- Payment states. Define every state a payment can be in: initiated, pending, paid, failed, cancelled, partially refunded and refunded. Each state must map to a clear status on the invoice or order.
- Webhooks, not polling. Gateways notify your system when a payment status changes. Build a webhook endpoint that verifies the gateway signature, stores the raw event, and processes it once even if the same event arrives twice.
- Idempotency. A retry must never create a second payment record. Use the gateway's transaction reference as a unique key in your database.
- Invoice matching. Each payment must link to an invoice ID, not just a customer name. Decide what happens to overpayments and underpayments.
- Refunds and reversals. Refunds should create a linked credit entry in the ledger. Do not overwrite the original payment, because the audit trail matters.
- Currency and rounding. Store amounts in the smallest unit and keep the currency code with every record. If you invoice in Egyptian pounds but the gateway settles in another currency, record the exchange rate used.
- Fees and net settlement. Gateways deduct fees before settling funds. Record the gross amount, the fee and the net amount separately so the bank deposit can be matched.
- Reconciliation report. Build a daily or weekly view that compares gateway transactions with ledger entries and bank deposits, and flags anything that does not match.
- Failure handling. Define what the customer sees, when the system retries, who gets alerted, and how staff can mark a payment resolved.
- Logs and access control. Keep logs of every webhook and API call, and restrict who can issue refunds.
Reconciliation is where most projects go wrong
Teams often finish the checkout flow in a few weeks and then spend months on reconciliation. The gap usually appears in three places: fees that were not recorded, payments that arrived after the period closed, and refunds that were processed directly in the gateway dashboard without reaching the ERP.
A practical rule: nobody should issue a refund or change a payment status outside the system of record. If the gateway dashboard is still used for refunds, the integration should import those events through webhooks so the ledger stays accurate.
A simple reconciliation check
| Check | What it confirms | Frequency |
|---|---|---|
| Gateway transactions vs. ledger payments | Every paid transaction has one ledger entry | Daily |
| Net settlements vs. bank deposits | Fees and timing differences are explained | Weekly |
| Refunds and reversals | Each refund links to its original payment | Daily |
| Open or pending payments | Nothing stays pending longer than the agreed window | Daily |
| Unmatched webhook events | No event was received but not processed | Daily |
Choosing the right payment methods for your system
Card payments, mobile wallets and cash on delivery each behave differently in software. Wallet payments may require a confirmation step on the customer's phone, which creates a longer pending state. Cash on delivery never sends a webhook at checkout, so the system needs a manual or courier-driven step to mark the invoice paid. Our article on payment gateway options for Egyptian retail covers the customer-facing side of these choices. Here, the point is that each method needs its own states in your data model.
Testing before go-live
Test payments are not enough. Plan test cases for each path: successful card payment, declined card, wallet timeout, duplicate webhook, partial refund, refund after the period has closed, and a webhook that arrives before the order record is saved. Run the reconciliation report against test data and confirm that totals match to the piastre.
We also recommend a parallel run for one or two weeks, where the old process and the new integration both record payments, and differences are investigated before the old process is switched off. The same approach is used when we plan an ERP go-live.
What to ask a development partner
- How do you verify webhook signatures, and how do you prevent duplicate processing?
- Where are refunds recorded, and do they create ledger entries?
- Can the reconciliation report be run without a developer?
- What happens during a gateway outage, and how are missed events recovered?
- Will we own the integration code and the test suite?
If you have a system that already takes payments and you are not sure whether the ledger matches the gateway, we can review the flow and list the gaps. Past projects with payment and invoicing features are described on our projects page, and you can contact us to discuss your setup.
Frequently asked questions
How long does payment gateway integration take?
A basic card checkout connected to an existing invoice can be built in a few weeks. Adding reconciliation, refunds, multiple currencies and a parallel run usually extends the schedule to a few months, depending on how many systems are involved.
Do I need a separate integration for each payment method?
Often yes, or at least a separate adapter for each provider. Each method has different states and settlement timing, so the data model should support them without forcing them into one generic status.
Can an ERP record payments made through a POS?
Yes, if the POS and ERP share customer, invoice and payment records. The main requirement is a single payment ledger that both systems write to, so sales and cash reports agree.
Who should own the reconciliation process?
Finance should own the process, and the system should give them a report that shows exceptions clearly. Technical staff maintain the integration, but a reconciliation that only developers can run will eventually fall behind.



