Payment integrationfor a multi-merchant payments platform

A payment layer where every transaction has an explicit state: failures aren’t lost, retries don’t turn into double charges, and mismatches go to review.

105

merchants accepting payments through the platform

9K+

transactions processed by the payment layer

3

systems reconciled against each other: the aggregator, merchant POS, and the wallet ledger
Payment Integration
Backend Development
FinTech
Payment flow: the mobile app calls the payment service, the payment service sends the charge to the payment aggregator, and the aggregator returns a webhook

About the client

A multi-merchant payments platform where users pay partner merchants from an in-app wallet. Every payment involves real money, the merchant’s POS system, and a wallet balance, and all three records have to match.

Business goals

Accept payments from several providers without rebuilding the product for each one.
Avoid lost, duplicate, and half-completed transactions. Each one means either a direct loss or a refund to the user plus a support ticket.
Keep payments, POS bills, and wallet balances consistent, including refunds and split bills.

Scope

A payment layer on top of an existing system. The platform connects to an aggregator that sits between it and multiple payment providers and banks. The aggregator moves the money. Gilzor owns everything around it: payment states, retries, the link between each payment and its wallet ledger entry, and reconciliation.

Challenges

01

Payments aren’t atomic

The aggregator confirms a payment, and the connection drops before our system records it. Or the payment succeeds, but the POS bill update fails. Half-completed transactions are the most common failure mode in payments. We modeled every payment as an explicit state machine, so the system always knows where a transaction stopped and what the next safe step is.

02

Duplicates and retries

Networks drop, users tap Pay twice, and webhooks are delivered at least once, so duplicates are expected. Without protection, any of these becomes a double charge or a duplicate wallet credit. We made payment processing idempotent and added controlled retries. Operations that still fail after retries go to a dead-letter queue instead of being dropped.

03

Reconciliation across three systems

The aggregator, the merchant’s POS, and the platform’s wallet ledger each hold their own version of a payment. Partial payments and split bills make matching harder. We built reconciliation that compares the three records and flags partial or mismatched transactions for manual review.
Solution development

How it works

The payment layer is provider-agnostic: the app talks to our backend, and the backend talks to the aggregator. A provider the aggregator already supports can be added without changing the product. A payment moves through five steps:
  1. Pay request. The user taps Pay in the app.
  2. Create payment. The backend creates the payment with the status pending and stores an idempotency key.
  3. Charge. The request goes to the provider through the aggregator.
  4. Webhook. The aggregator sends the provider’s payment confirmation.
  5. Ledger entry. The backend sets the status to paid, writes the wallet ledger entry, and notifies the app.
If the provider doesn’t respond, the backend waits for the timeout and retries with the same idempotency key so the retry doesn’t create a second charge. After a set number of failed attempts, the operation goes to a dead-letter queue for review. Once a day, the ledger is reconciled against the aggregator’s records: matched payments need no action, and mismatches go to manual review.
Payment flow: normal flow from pay request to ledger entry, failure flow with timeout, retry and dead-letter queue, and daily reconciliation of our ledger, aggregator records and POS bills

Key Features

Aggregator integration

One integration covers several payment providers and banks. Adding a provider the aggregator already supports doesn’t require app changes.

Payment state tracking

Every payment moves through explicit states, including pending, partial, failed, and refunded, all visible in the admin portal.

Idempotent processing

Repeated requests and duplicate webhooks are processed by key and don’t create a second charge or a second wallet entry.

Retries and a dead-letter queue

Failed operations are retried automatically. Anything that can’t be completed stays in a queue for review instead of disappearing.

Split and partial payments

A bill can be paid in shares or in parts, through the POS or manually, and ends up in one consistent state.

Wallet balances tied to payment status

Credits and debits are posted only against confirmed payments, and refunds are posted as reversing entries.

Reconciliation

Payments are matched against aggregator records and POS bills, with partial and mismatched cases flagged for review.
Tech stack

Payment Integration Tech Stack

Backend

NestJS

Database

PostgreSQL

Admin portal

React

Payments

Aggregator integration
Idempotent processing
Retry and dead-letter queues

Achieved

results

In production

The payment layer runs in production across 105 merchants and has processed 9K+ transactions.

New providers without a release

New providers supported by the aggregator can be added without an app release.

Reconciliation by exception

Manual financial reconciliation is down to handling exceptions: the client’s team reviews only mismatches, not the full payment flow.

Fewer support tickets

Double charges and stuck payments are no longer a routine source of support tickets: repeat taps and duplicate webhooks don’t create duplicates, and unfinished payments show up in the admin portal with their status.

Consistent balances

Refunds and split bills are reflected consistently in wallet balances and POS bills.