Skip to content
Hubs & Guides⏱️ 16 min read·

Nepal Payment Gateway Integration Hub: eSewa, Khalti, ConnectIPS, and Fonepay (2026 Developer Guide)

The complete architectural and practical hub for integrating online payments in Nepal. Compare transaction fees, sandbox testing, SDK support, HMAC signatures, and server-side verification across eSewa v2, Khalti v2, ConnectIPS, and Fonepay QR.

MN
Manoj NeupaneSoftware Developer & Programming Instructor
#eSewa#Khalti#ConnectIPS#Fonepay#Payment Gateway#Nepal FinTech#Laravel#Node.js
🎯 Who This Tutorial Is For

📋 Prerequisites
  • ✓Working knowledge of backend APIs (Node.js/Express, Laravel, or Python)
  • ✓Understanding of cryptographic hashing (HMAC-SHA256 and RSA)
  • ✓A test merchant account on eSewa Developer Portal or Khalti Merchant Portal
  • ✓Basic understanding of HTTP request-response lifecycles and webhooks

🚀 What You Will Learn & Build

  • ▸Direct feature-by-feature comparison of eSewa, Khalti, ConnectIPS, and Fonepay
  • ▸KYC documentation and merchant registration requirements for personal vs. registered business entities
  • ▸Security best practices: preventing client-side spoofing, replay attacks, and duplicate order fulfillment
  • ▸A structured decision tree: which gateway to pick for your startup, e-commerce store, or college project
  • ▸Direct links and learning pathways for step-by-step code implementations
1

The Digital Payment Ecosystem in Nepal: 2026 Overview

Nepal's digital payment ecosystem has matured rapidly under the regulatory oversight of Nepal Rastra Bank (NRB). Today, digital transactions represent billions of NPR monthly. For developers building software in Nepal, supporting digital checkout is no longer optional—it is a core requirement. Four major payment providers dominate the Nepali market, each serving distinct use cases: 1. **eSewa:** The pioneer wallet in Nepal with the highest consumer user base. Uses **ePay v2** with HMAC-SHA256 signature verification. 2. **Khalti:** Modern, developer-centric wallet and payment aggregator. Offers **Khalti ePayment v2 API** with clean RESTful JSON endpoints and server-side status lookup. 3. **ConnectIPS (NCHL):** Bank-to-bank direct debit clearing service operated by Nepal Clearing House. Lower merchant fees for large transactions, but requires stricter RSA cryptographic signing. 4. **Fonepay:** Nepal's largest interoperable QR network. Perfect for in-person dynamic QR generation or web checkout using mobile banking apps.
GatewayPrimary MechanismIntegration ComplexityFee Structure (Approx.)Best Used For
eSewa (ePay v2)Wallet redirect + HMAC-SHA256Beginner / Intermediate2.0% – 3.0%General retail e-commerce, consumer subscriptions
Khalti (ePayment v2)REST JSON API (`pidx`) + redirectBeginner Friendly2.0% – 2.5%Modern web apps, MERN stack, developer-first startups
ConnectIPSDirect bank debit + RSA SHA256Advanced (Cryptographic keys)Flat NPR 2 – 8 per txnHigh-value B2B transactions, tuition, official fees
Fonepay QRDynamic Interoperable EMV QRIntermediate (Next.js/APIs)1.5% – 2.0%Mobile banking users across 50+ commercial banks
2

Which Payment Gateway Should You Integrate First?

If you are starting a new project in Nepal, choose your gateway based on your current project phase and entity status: - **For College Projects, Portfolios, and Learning:** Start with **Khalti ePayment v2**. Khalti offers immediate sandbox key generation without business registration documents, has comprehensive REST documentation, and returns clear JSON error messages. - **For High-Volume Consumer E-Commerce in Nepal:** Integrate **eSewa** first. Because eSewa has over 7 million registered wallets, it is the payment method Nepali consumers search for on checkout pages. - **For Large Ticket Transactions (Tuition, Vehicles, Real Estate):** Integrate **ConnectIPS**. High percentage transaction fees (2.5%) on a NPR 100,000 transaction cost NPR 2,500 on wallets, whereas ConnectIPS charges a flat micro-fee of around NPR 5 to NPR 10. - **For Multi-Bank Mobile App Checkouts:** Integrate **Fonepay Dynamic QR**. This allows customers to scan using Global IME, Nabil, NIC Asia, or any banking app directly.
💡 Pro-Tip— Multi-Gateway Architecture Pattern

Never tightly couple your checkout controller to one provider. Create an abstract PaymentGatewayInterface in your application with initiate(), verify(), and refund() methods. This enables you to toggle eSewa, Khalti, or ConnectIPS without rewriting order fulfillment logic.

3

Non-Negotiable Payment Security Rules

Regardless of which gateway you choose, beginner developers routinely commit catastrophic security mistakes that allow malicious actors to spoof transactions. Memorize these golden rules: 1. **Client-side redirects are NOT proof of payment:** When a user returns to your `success_url`, your server MUST NOT mark the order as paid immediately. Users can copy the success URL with forged query parameters. 2. **Server-to-Server Verification is mandatory:** Your backend server must make an independent HTTPS request to the gateway's verification endpoint (e.g. eSewa status API or Khalti `/epayment/lookup/`) using your secret key. 3. **Verify the Amount and Currency:** Compare the amount returned by the gateway with the exact amount recorded in your database before fulfillment. Attackers will attempt to change a NPR 10,000 cart to NPR 10. 4. **Enforce Idempotency:** Payment gateways may send duplicate callbacks due to network retries. Ensure your payment handler checks if the transaction has already been fulfilled to prevent duplicate credits.
services/paymentVerification.ts
// Example of safe, idempotent order fulfillment logic
export async function fulfillOrderSafely(transactionUuid: string, paidAmount: number) {
  const order = await db.orders.findOne({ transactionUuid });
  if (!order) {
    throw new Error("Order not found");
  }

  // Check state machine: Prevent duplicate fulfillment
  if (order.status === "PAID") {
    console.warn(`Duplicate callback ignored for order: ${transactionUuid}`);
    return { success: true, message: "Already fulfilled" };
  }

  // Strict verification: Verify amount match
  if (order.totalAmount !== paidAmount) {
    await db.orders.updateOne({ transactionUuid }, { status: "SUSPICIOUS_AMOUNT_MISMATCH" });
    throw new Error("Fraud alert: Paid amount does not match recorded order amount");
  }

  // Update status atomically
  await db.orders.updateOne(
    { transactionUuid },
    { 
      status: "PAID",
      paidAt: new Date(),
      paymentVerifiedVia: "SERVER_API"
    }
  );

  return { success: true, message: "Order fulfilled securely" };
}
4

Comprehensive Cluster Tutorials & Code Guides

Explore our detailed, step-by-step guides for implementing each provider in production: - [eSewa Payment Integration in Laravel 12](/blog/esewa-payment-integration-laravel-12-complete-guide): Complete controller, routes, CSRF bypass, and HMAC-SHA256 verification. - [Khalti ePayment v2 in Node.js/Express](/blog/khalti-epayment-v2-api-nodejs-express-guide): REST client, `pidx` session handling, and lookup verification. - [Solving the 'Invalid Signature' Error in eSewa](/blog/esewa-invalid-signature-error-causes-and-fixes): 5 root causes, encoding bugs, and exact fixes. - [ConnectIPS Integration in PHP from Scratch](/blog/connectips-integration-php-rsa-key-signing-guide): RSA-SHA256 private/public key generation and settlement. - [Dynamic Fonepay QR in Next.js](/blog/dynamic-fonepay-qr-integration-nextjs-guide): Real-time merchant QR code rendering on the web. - [Stop Spoofed Payment Verification](/blog/stop-spoofed-payment-verification-esewa-khalti-nepal): Advanced anti-spoofing and replay attack prevention.

✨ Expected Output & Verification

A robust conceptual and architectural roadmap that allows any developer in Nepal to select, design, and securely integrate payment systems without common amateur vulnerabilities.

🧪 How to Test the Implementation

  1. 1Review the gateway comparison matrix against your company's or project's entity status
  2. 2Register a developer account on developer.esewa.com.np and admin.khalti.com
  3. 3Bookmark the cluster tutorials matching your chosen tech stack (Laravel, Node.js, Next.js)
  4. 4Set up test environment variables in your local .env file before writing code

⚠️ Common Errors & How to Fix Them

❌Hardcoding Secret Keys in Client-Side JavaScript

Root Cause: Placing merchant credentials in React, Vue, or frontend HTML where any visitor can inspect source code.

Fix: Move all secret keys to server-side .env files. Only public merchant codes belong in frontend forms.

❌Allowing Decimal Precision Mismatches

Root Cause: Sending 100.5 to gateway while database has 100.50, causing signature validation or verification failure.

Fix: Normalize all amounts using number_format($amt, 2, '.', '') or Number(amt).toFixed(2).

🛡️ Security Considerations & Best Practices

  • !Never trust client redirects without server-to-server transaction status queries.
  • !Store payment callback logs with raw payloads in a separate audit table for financial reconciliation.
  • !Use HTTPS on all environments except local development to prevent man-in-the-middle payload tampering.

❓ Frequently Asked Questions (FAQ)

For production live credentials, eSewa and ConnectIPS legally require a registered business (PAN/VAT certificate, company registration, and bank account). However, Khalti allows personal developer sandboxes for testing, and recently introduced personal merchant onboarding for registered individual taxpayers.

📌 Summary of Key Takeaways

Nepal's digital payment ecosystem offers world-class wallet and banking infrastructure. Success comes down to selecting the right provider for your audience, adhering strictly to server-side cryptographic verification, and enforcing idempotency.

Official References & Further Reading