NepPay: A Rust Payment Layer That Turns Nepal’s Gateway Sprawl Into One Typed API
A close look at a regional payments orchestrator that separates orders from payment attempts, automates gateway signatures, and hints at a clean path to multi-provider support.
- NepPay’s main idea is state discipline: it separates a merchant order from a payment attempt so gateway complexity never leaks into the business layer.
- The eSewa adapter shows the real product value, which is not a payment button but a repeatable way to build signed provider payloads without hand-wiring every integration.
- Rust earns its keep here by making invalid payment states harder to express, especially when provider support is still expanding.
- This is an alpha-stage orchestrator, but its module boundaries already look like the skeleton of a serious regional payment platform.
The hidden complexity behind a simple checkout button
A checkout button looks trivial until the first gateway rejects your payload. Then the real work appears: field ordering, signature rules, redirect URLs, intent states, callback verification, and a different set of quirks for every provider. NepPay exists to hide that mess behind one Rust API.
That matters because Nepal’s payment stack is fragmented. A merchant should not have to remember which gateway wants which fields in which order, or which state belongs to the sale and which state belongs to the payment attempt. NepPay’s value is that it tries to make that boundary explicit.
Order is not the same thing as payment
This is the best mental model in the codebase. In src/order.rs, the order carries business meaning. In src/initiate.rs, the payment intent carries execution meaning. That split keeps the merchant’s domain clean even when the gateway flow gets noisy.
It also creates room for retries. If a provider fails, the order does not need to be rewritten as a new sale. A new payment intent can exist for the same order, which is exactly the kind of separation a payments system should protect.
let message = format!(
"total_amount={},transaction_uuid={},product_code={}",
order.amount, intent.id, merchant.product_code
);
let signature = compute_hmac(&merchant.secret, &message);
How NepPay translates one clean model into eSewa’s rules
The sharpest file in the repo is src/esewa.rs. It takes the internal model, reshapes it into the fields eSewa expects, and computes the signature the gateway needs to trust the request. That is the whole game: keep the system canonical on the inside, then adapt at the edge.
The adapter pattern is doing real work here. The merchant code does not need to know about provider-specific field names like signed_field_names or the exact concatenation required for HMAC validation. NepPay centralizes that logic so it can be reviewed, tested, and replaced in one place.
The code also shows a useful payment pattern: one clean message string, one deterministic digest, one verification path. In financial plumbing, repeatability beats cleverness.
Rust is doing real work here
This is not a “Rust because Rust” project. The language matters because the system is full of states that can go wrong: provider choice, intent status, order status, payload shape, and signature integrity. Rust’s enums and module boundaries make those states harder to confuse.
| Dimension | Direct gateway integration | NepPay | Large orchestration platform |
|---|---|---|---|
| Scope | One provider at a time | One typed API over local providers | Multi-PSP routing and enterprise breadth |
| Developer experience | Fast to start, fragile to maintain | Cleaner boundary between order and intent | Powerful but heavier to adopt |
| Type safety | Depends on the host app | Core design goal | Varies by implementation |
| Local market fit | High, but manual | High, with shared abstractions | Usually lower unless customized |
| Maturity | Can be production-ready | Alpha / prototype | Mature or near-mature |
The benefit is not raw performance. It is the chance to stop invalid states before they hit a provider. When a payment stack is built in a dynamically typed way, a lot of the safety net arrives too late, after the request is already on the wire.
The current code still shows prototype habits, including minimal error handling and demo-style flow control. But the architectural direction is clear: keep the surface small, keep the types strict, and push provider logic to the edges.
What NepPay is, and what it is not
| What it is | What it is not |
|---|---|
| A regional payment abstraction layer | A full-scale payment orchestration suite |
| A typed adapter around gateway quirks | A generic wallet app |
| A modular Rust foundation | A polished production payment network |
| A clean separation of order and payment state | A single monolithic checkout flow |
| A plausible base for adding more providers | A finished enterprise platform |
That distinction matters. NepPay does not need to compete with every payment company or every orchestration platform to be interesting. Its real contribution is narrower and better defined: a clean local integration layer that treats payment plumbing like a software design problem.
Where it sits in the payment orchestration landscape
Direct gateway integrations are the cheapest way in, but they spread provider logic across the codebase. Broad orchestration platforms like Hyperswitch solve a larger problem, but they are designed for a different scale and a wider market. NepPay sits in the middle of those extremes, closer to the merchant and much closer to the local rules.
| Approach | Best for | Trade-off |
|---|---|---|
| Direct gateway integration | Teams shipping quickly on one provider | Every new gateway adds more bespoke code |
| NepPay | Merchants and developers in Nepal who want one typed abstraction | Smaller scope and early-stage maturity |
| Hyperswitch-style orchestration | Teams that need broader routing and enterprise control | Heavier platform footprint and more operational complexity |
That is a sensible place to start. Regional software often fails not because the idea is bad, but because the first version tries to solve too much. NepPay looks like the opposite: one tight problem, one tight abstraction, and room to grow without collapsing the model.
The roadmap is visible in the code
The unfinished edges are easy to see. Error handling is thin. Demo credentials are hardcoded. Persistence is implied more than realized. None of that is surprising in an alpha project, and none of it weakens the architectural signal.
What matters is that the repo already knows what it wants to be. It wants to keep business state separate from payment execution, keep provider-specific logic behind adapters, and use Rust to prevent the worst kinds of integration mistakes. That is a strong foundation for a payment stack, especially in a fragmented regional market.





