Summary
A Payment Gateway for iGaming that serves agents and white-label brands needs a hierarchy-aware ledger, not a pile of balances. Model the network as Company → Agents → Merchants, record every movement as a debit and a credit that sum to zero, keep that financial ledger immutable and separate from security audit logs, and restrict who can move value with role-based access control. With those four pieces in place, reconciliation becomes a routine check instead of a month-end investigation.
01Why a hierarchy changes the money problem
A single operator with one website has a simple money story: players deposit, players withdraw, and the operator settles the difference. The moment you add agents who recruit players, or white-label brands that run under your licence and infrastructure, the same cash has to be attributed to several parties at once. A deposit made on a Friday night belongs to a player, was collected for a brand, was introduced by an agent, and ultimately rolls up to the company that owns the platform.
Most teams discover this problem late. They launch with one balance per merchant, add an agent column when the first sales partner arrives, and bolt on a commission spreadsheet when the second one does. Six months later the finance lead is asked a simple question, such as how much float each agent is currently holding, and the answer requires three exports and a day of manual matching.
The goal of this article is to describe a structure that avoids that outcome. It is written for platform owners, finance leads and engineers who run, or plan to run, a multi-level network on a Payment Gateway iGaming setup. Merchants remain responsible for their own licensing and for compliance with the rules of the markets they operate in; the design below is about bookkeeping and control, not about legality.
02The Company → Agents → Merchants structure
Start by naming the three tiers precisely. The Company is the top-level organisation: it owns the platform relationship, the settlement destinations and the final authority over rules. Agents sit underneath and manage a portfolio of brands or sub-networks, typically earning a commission on the volume those brands produce. Merchants are the operating brands at the bottom, each with its own players, its own pay-in and payout flow and its own balance.
The key design decision is that the hierarchy is data, not convention. Each node should have a parent, a currency position and a defined set of operators who may act on it. When a transfer happens it is always between two known nodes, so the question of who owes what to whom can be answered by reading the tree, not by reading chat history.
SF PayGate models this tree through its organization layer, and the `/api/v1/organization-transfers` endpoint moves value along it in the Company → Agents → Merchants direction using double-entry bookkeeping. The ledger architecture supports 11 currencies, with THB, HKD and USDT on TRC20 live in the core today. Treat the hierarchy as the backbone and everything else in this article as controls attached to it.
| Tier | Typical role | Money it is concerned with | Typical question it asks |
|---|---|---|---|
| Company | Platform owner and final authority | Total float, settlement destinations, funding of agents | Does the sum of all tiers match what we hold? |
| Agent | Manages a portfolio of brands | Float allocated to its merchants, commission position | Which of my brands is running low? |
| Merchant | Operating brand with its own players | Pay-ins, payouts, its own balance | Can I cover tonight's withdrawals? |
03Why single-entry balances break at scale
A single-entry balance is just a number that goes up and down. A deposit adds to it, a withdrawal subtracts from it, and the current figure is whatever the last update left behind. It is easy to build and it works for a while, which is exactly why it is dangerous.
Consider a retried request. A network timeout makes a transfer call look like it failed, so an operator or an automated job repeats it. With a plain balance, nothing in the data says the first attempt actually landed, and you end up with a figure that is quietly too high on one side and too low on the other. Because there is only one number to look at, there is no second record against which to notice the difference.
Hierarchies make it worse. If an agent funds a merchant by editing two balances separately, a crash between the two edits leaves value created or destroyed. Over thousands of transfers, small inconsistencies accumulate and nobody can say which one is wrong. The remedy is to stop storing balances as the primary truth and to store movements instead, so that a balance is something you derive and can re-derive.
- Value can be created or lost if two balances are edited separately and the process stops in between.
- A repeated request is indistinguishable from a legitimate second transfer unless something records the first.
- Corrections overwrite history, so you cannot show an auditor what the figure was yesterday.
- There is no built-in way to prove that the whole network still adds up.
04Double-entry explained for non-accountants
Double-entry bookkeeping sounds technical, but the rule is small: every movement of money is recorded twice, once as a debit on one account and once as a credit on another, and the two amounts are equal. Put differently, the entries for any single movement sum to zero. Money never appears from nowhere; it always leaves one place and arrives in another.
Think of it as a receipt that must be signed by both sides. If the company moves 100,000 THB to an agent, the company account is reduced by 100,000 and the agent account is increased by 100,000, and both facts are written as one atomic record. If only half of that record could be written, the whole thing is rejected, so the books cannot drift out of balance halfway through.
For a hierarchy this has a very practical payoff. The total of all debits across the network must equal the total of all credits, and you can check that with a simple sum. If the check fails, you know there is a defect and you also know it is inside a bounded set of recent entries, not somewhere in two years of data.
05A worked transfer, step by step (illustration)
The table below is a hypothetical illustration, not real customer data. Suppose the Company funds an Agent with 500,000 THB, the Agent then allocates 200,000 THB to Merchant A, and Merchant A later returns 50,000 THB of unused float. Each line records one debit and one credit of the same size.
Reading the table from top to bottom, notice that no single row changes the total across the three tiers. Value only moves between accounts. The figure that actually changes holdings in the real world, such as a player deposit arriving or a payout leaving, is recorded as a separate movement involving an external account, so it is also balanced.
After the third row, the Company is down 500,000, the Agent holds 350,000 and Merchant A holds 150,000, and the three together equal the original 500,000. That reconciliation, trivial here, is the same check you run at the end of every day across hundreds of nodes.
| Step | Movement | Debit (leaves) | Credit (arrives) | Amount | Net effect on network total |
|---|---|---|---|---|---|
| 1 | Company funds Agent | Company | Agent | 500,000 | 0 |
| 2 | Agent allocates to Merchant A | Agent | Merchant A | 200,000 | 0 |
| 3 | Merchant A returns unused float | Merchant A | Agent | 50,000 | 0 |
| Result | Balances after step 3 | Company −500,000 | Agent 350,000 / Merchant A 150,000 | Sum = 0 across the tiers |
06Moving value with /api/v1/organization-transfers
In SF PayGate, `/api/v1/organization-transfers` is the rail for moving value inside the hierarchy: Company → Agents → Merchants, recorded as double-entry. It is one of three outbound rails, alongside organization-settlements (which move value out to a destination) and payouts (which pay players). Keeping the internal rail separate from the outbound ones is what lets you answer, at any time, which money is still inside the network and which has left it.
Requests to the API are signed in the usual way: X-API-Key, X-Timestamp and X-Signature, where the signature is HMAC-SHA256 over the raw body. The API key and the signing secret are separate credentials, and the leading `/api` is stripped before verification, so you sign `/v1/organization-transfers` even when you call `/api/v1/organization-transfers`. Use your own idempotency discipline on the caller side as well: record your internal reference before sending, so that a retry after a timeout can be matched to the original attempt.
Before moving large amounts outward, check the limits and preview endpoints under `/api/v1/organization-settlements`. They exist so that you see what a settlement would look like before you confirm it. For the exact request fields and examples, use the developer API documentation rather than guessing from this article.
07Immutable ledger versus security audit logs
Two records are often confused. The financial ledger answers what money moved, between which accounts and in what amount. The security audit log answers who did what in the system: who logged in, who changed a permission, who revoked a session. They serve different readers, and mixing them makes both worse.
SF PayGate keeps an immutable financial ledger separate from security audit logs. Immutable means entries are appended and never edited; if a mistake needs correcting, you add a new reversing entry that points back to the original, and the history of both stays visible. That is the behaviour an auditor expects, and it is also what makes a derived balance trustworthy, because past entries cannot be rewritten to make a total fit.
Keeping the logs apart also helps with access. A support agent who needs to investigate a suspicious login should not need to see financial detail, and a finance reviewer reconciling transfers should not need to browse authentication events. Separate stores let you grant each team exactly the view it needs.
| Aspect | Financial ledger | Security audit log |
|---|---|---|
| Question answered | What money moved, where, how much | Who did what, when, from where |
| Typical reader | Finance, reconciliation, auditors | Security, operations, compliance |
| Edits allowed | Append only; corrections are new entries | Append only; reviewed for anomalies |
| Used for | Balances, settlement, dispute evidence | Access reviews, incident investigation |
08RBAC at menu and CRUD level, and the access-control matrix
Role-based access control decides who can see a screen and who can create, read, update or delete within it. SF PayGate applies menu- and CRUD-level RBAC security controls, together with a per-account IP allowlist on both the API and the portal, login rate limiting, 2FA and session revocation. The practical effect is that a finance viewer can be given read access to reports without any way to trigger a transfer, and a support operator can see tickets without seeing credentials.
For multi-tier networks, a few operations should be reserved for the Company level: creating agents, funding agents, changing settlement destinations and anything that alters the shape of the hierarchy. The reason is simple. Those actions change who may hold or receive value, so they deserve the smallest possible set of authorised people. Agents should manage their own brands and see only their own subtree.
The matrix below is a design template, a starting point you can adapt, not a description of fixed built-in roles. Write your own version before onboarding, and review it whenever a person changes team.
| Role | Can see | Can do |
|---|---|---|
| Company owner | Entire hierarchy, all balances, ledger, audit logs | Create agents, fund agents, set settlement destinations, manage all roles |
| Company finance | All balances and ledger entries, reconciliation reports | Run transfers within policy, request settlement, export reports |
| Agent manager | Own agent account and its merchants only | Allocate float to own merchants, manage own staff |
| Merchant operator | Own pay-ins, payouts, balance | Create orders and payouts, manage own webhook settings |
| Support | Tickets, order status, no credentials | Open and update cases, no financial changes |
| Read-only auditor | Ledger and reports for the scope granted | Export only; no create, update or delete |
09Per-brand credentials and webhooks
Each brand in a white-label network should hold its own API key, signing secret and webhook endpoint. When credentials are shared across brands, a leak at one brand exposes all of them, and you cannot tell from a log which brand a request came from. With separate credentials you can rotate one brand's secret without touching the others, and you can disable a single brand quickly if you need to investigate it.
Webhooks follow the same logic. SF PayGate sends signed webhooks and retries them automatically until the merchant returns HTTP 200, so every brand needs an endpoint that verifies the signature, handles duplicates safely and responds quickly. If two brands point to one endpoint, your handler has to infer the brand from the payload, which is an avoidable source of mistakes. Give each brand its own URL and run HMAC-SHA256 webhook signature verification against that brand's own secret.
Remember that the webhook is only one of three confirmations. The query API is available 24/7, and the slip fallback covers cases where a customer has paid but the callback was missed. A well-run network checks all three before treating an order as final.
10Commission and float management in principle
Commission is a business agreement between you and your agents, and the gateway does not decide it for you. What the ledger gives you is a reliable base: verified volume per brand, per currency and per period, from which any commission formula can be computed and checked afterwards. Calculate commission from completed transactions only, because expired, cancelled or failed orders are not charged and should not earn a share either.
Float is the working balance a brand needs to cover payouts. If it is too small, withdrawals queue up on a Friday night when players are most active; if it is too large, money sits idle where it adds risk and no value. A sensible routine is to agree on a minimum and target float per brand, review it at a fixed time each day alongside your on-demand settlement schedule, and top up through organization transfers from the agent or company level rather than through ad hoc arrangements.
Keep the arithmetic visible. For illustration, suppose a brand's target float is 300,000 THB and it currently shows 120,000 THB; the top-up is 180,000 THB, recorded as one debit on the agent and one credit on the brand. A written rule like that is easier to audit than a decision made in a chat window.
11An end-of-day reconciliation routine
Reconciliation is easiest when it is small and frequent. Do it daily, at a consistent time, comparing your internal records to the ledger and to the bank or wallet positions you hold. A small difference found on the same day usually has a simple cause, such as a pending order or a transfer in flight; the same difference found at month end is an investigation.
Settlement timing matters when you pick that time. The API settlement queue accepts instructions 24/7, though arrival depends on the recipient bank's clearing. Dashboard USDT (TRC20) settlement runs daily between 14:00 and 22:00 (UTC+7), so a request placed at 02:00 is processed in the next window. Build your cut-off around these windows so that items in flight are explained rather than flagged.
If something does not match, open a ticket via `POST /api/me/issues` and keep the request_id; every live merchant organisation also has a dedicated private Telegram support room, available 24/7. Disputes and bank holds are handled as tracked cases under the written merchant agreement, and there are no card-network chargebacks because cards are not supported.
- 1Freeze a cut-off time and list every transfer, pay-in, payout and settlement up to that point.
- 2Confirm that all debits equal all credits across the network for the period.
- 3Compare each brand's derived balance with its own reported figure.
- 4Match settlements and payouts against bank or wallet statements, allowing for clearing time.
- 5Explain every difference in writing, either as an item in flight or as a ticket with a request_id.
- 6Record the sign-off, who reviewed it, and the next day's target float for each brand.
12Pitfalls, and when this structure fits
The most common mistake is to keep the ledger clean and then run exceptions in a side spreadsheet. If an agent is topped up outside the platform, the books and the real world disagree from that moment on. Another frequent pitfall is giving too many people the ability to move value; if five people can fund agents, accountability is blurred and a compromised account has greater reach.
A hierarchy is the right fit when you have more than one brand, more than one party with a stake in the volume, or any plan to add them. It is probably more than you need for a single brand that owns all its players and has no sub-networks. In that case, simple merchant accounts with strong RBAC, 2FA and IP allowlisting may be enough, and you can migrate to a deeper structure later.
Compliance remains with you. Merchants are responsible for their own licensing and for the rules of the markets they operate in, and SF PayGate reviews merchants before going live. Scams, phishing, fake investment and Ponzi operations are prohibited on the network under a 100% prohibition policy. If you want to discuss a multi-tier setup, you can request an onboarding consultation without needing a live domain, followed by a sandbox evaluation and a production review with a written agreement.
Frequently asked questions
- What does double-entry mean in plain terms?
- Every movement of money is recorded as a debit on one account and a credit on another, in equal amounts, so the entries sum to zero. Because both sides are written together, the books cannot silently lose or create value. It also gives you a simple check: total debits should equal total credits.
- What does /api/v1/organization-transfers do?
- It moves value inside the hierarchy, from Company to Agents to Merchants, recorded as double-entry. It is separate from organization-settlements, which move value out, and from payouts, which pay players. Check the developer documentation for the exact request format.
- Why keep the ledger separate from security audit logs?
- They answer different questions: the ledger records what money moved, while audit logs record who did what in the system. Keeping them apart lets you give finance and security teams only the view they need. The financial ledger is immutable, so corrections are added as new entries rather than edits.
- Which actions should be company-only?
- Creating agents, funding agents, changing settlement destinations and anything that reshapes the hierarchy are good candidates. These change who can hold or receive value, so restrict them to a small, reviewed group. Your own access matrix should set the exact boundaries.
- Should every brand have its own API credentials and webhook?
- Yes, as a design practice. Separate keys, signing secrets and webhook URLs limit the impact of a leak, make rotation simpler and make each request traceable to a brand. Verify the HMAC-SHA256 signature against that brand's secret.
- How often should we reconcile?
- Daily is a practical rhythm, using a fixed cut-off and allowing for settlement windows such as the daily 14:00 to 22:00 (UTC+7) dashboard USDT run. Small same-day differences are much easier to explain than month-end ones. Open a ticket with a request_id for anything unexplained.