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.

8 min read • View on GitHub • More from tarnished292

A merchant checkout counter sits in front of a tangled network of wallet icons, payment slips, and routing wires, while a single control panel funnels the chaos into one clean terminal-like path. The scene explains NepPay’s core promise: local gateway complexity enters on one side and a typed Rust interface comes out the other.
NepPay is less a checkout app than a translation layer. It absorbs provider-specific chaos and presents one consistent payment surface to the rest of the system.
Key Takeaways

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

The core idea is separation. An order is the sale. A payment intent is one attempt to settle it, and failed attempts do not rewrite the sale itself.

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.

A close-up workbench scene shows an Order ledger on the left and a PaymentIntent card on the right, separated by a narrow mechanical arm that stamps and rearranges fields into a signed envelope. The image explains how NepPay converts business state into provider-specific payment state without merging the two.
The adapter is not just formatting data. It is the boundary where business meaning becomes provider syntax.

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.

DimensionDirect gateway integrationNepPayLarge orchestration platform
ScopeOne provider at a timeOne typed API over local providersMulti-PSP routing and enterprise breadth
Developer experienceFast to start, fragile to maintainCleaner boundary between order and intentPowerful but heavier to adopt
Type safetyDepends on the host appCore design goalVaries by implementation
Local market fitHigh, but manualHigh, with shared abstractionsUsually lower unless customized
MaturityCan be production-readyAlpha / prototypeMature 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 isWhat it is not
A regional payment abstraction layerA full-scale payment orchestration suite
A typed adapter around gateway quirksA generic wallet app
A modular Rust foundationA polished production payment network
A clean separation of order and payment stateA single monolithic checkout flow
A plausible base for adding more providersA 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.

ApproachBest forTrade-off
Direct gateway integrationTeams shipping quickly on one providerEvery new gateway adds more bespoke code
NepPayMerchants and developers in Nepal who want one typed abstractionSmaller scope and early-stage maturity
Hyperswitch-style orchestrationTeams that need broader routing and enterprise controlHeavier 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.