Wednesday, April 22, 2026

How to Integrate eSewa, Khalti & Fonepay with WHMCS: The Ultimate Automation Guide

Share

In the world of web hosting, automation is the difference between a side hustle and a scalable business. If you are running a reseller hosting business in Nepal in 2026, you cannot afford to manually check bank transfers or verify eSewa screenshots on Viber. Your customers expect instant service activation. They want to pay at 2:00 AM and have their hosting account ready by 2:01 AM.

To achieve this, you need a robust integration between WHMCS (Web Host Manager Complete Solution) and Nepalโ€™s leading payment gateways: eSewa, Khalti, and Fonepay.

As part of our Week 2 Deep Dive, we are moving past the “why” and getting into the “how.” This guide will walk you through the technical setup, merchant requirements, and automation logic needed to turn your WHMCS installation into a self-sustaining revenue machine.

The Business Case for Payment Automation in Nepal

Before we touch the code, let’s look at the numbers. A typical reseller in Pokhara spends approximately 4-6 hours a week manually verifying payments. With the Nepal E-commerce Act of 2025 now in full effect, consumer expectations for “Instant Fulfillment” have peaked.

Benefits of Integration:

  • Zero Human Intervention: Invoices are marked “Paid” automatically.
  • Instant Provisioning: WHMCS tells cPanel/WHM to create the account immediately upon payment.
  • Reduced Churn: Customers are less likely to leave if the renewal process is friction-free.
  • Professionalism: A professional checkout experience builds trust, which is the #1 currency in the hosting industry.

Pre-Requisites: Preparing Your WHMCS Environment

Before installing any modules, your infrastructure must be ready. 2026 standards require higher security and specific localization.

I. SSL & HTTPS (Mandatory)

All Nepali gateways (especially eSewa v2 and Khalti) require a secure callback environment. Your WHMCS must be running on https://. Ensure your SSL certificate is valid and not expired.

II. Currency Configuration

Most resellers pay their upstream providers (like PokharaHost or international data centers) in USD but charge local clients in NPR.

  1. Go to Setup > Payments > Currencies.
  2. Add NPR as a currency.
  3. Set the Base Conversion Rate. (Pro Tip: Use the “Update Exchange Rates” button, but add a 2-3% “Forex Buffer” to cover bank conversion fees).

III. System Cron Job

Ensure your WHMCS Cron is running every 5 minutes. Without a functioning cron, the automation “handshake” between the gateway and your server might fail.

Integrating eSewa (v2 API)

eSewa remains the “Big Brother” of digital wallets in Nepal. In late 2025, they fully deprecated the v1 API in favor of eSewa ePay v2, which uses more secure HMAC-SHA256 signatures.

Step 1: Merchant Account Setup

You cannot use a personal eSewa account for WHMCS.

  • Requirements: Company Registration, PAN/VAT Certificate, and a Business Bank Account.
  • Access: Sign up at the eSewa Merchant Portal.
  • Keys Needed: You will receive a Merchant ID, a Secret Key (for HMAC), and a Product Code.

Step 2: Module Installation

  1. Download a compatible eSewa v2 WHMCS module (check the WHMCS Marketplace).
  2. Upload the files to /modules/gateways/. You should see esewa.php and a callback file in /modules/gateways/callback/esewa.php.
  3. In WHMCS Admin, go to System Settings > Payment Gateways > All Gateways and activate eSewa.

Step 3: Configuration

  • Merchant ID: Enter your official ID.
  • Secret Key: Paste the HMAC key.
  • Service Delivery Charge: (Optional) If you want to pass the eSewa fee to the customer.
  • Test Mode: Keep this enabled until you complete a successful transaction in the eSewa Sandbox.

Integrating Khalti: The Developerโ€™s Choice

Khalti is widely praised for its clean API documentation and reliable “Lookup” system. After their merger with IME Pay, their reach has expanded significantly.

The Technical Flow

Unlike eSewa, which often relies on a POST redirect, Khalti uses a pidx (Payment ID) system.

  1. WHMCS requests a pidx from Khalti.
  2. The customer is redirected to the Khalti payment page.
  3. After payment, Khalti redirects back to your WHMCS with a transaction status.

Step 1: Getting API Keys

Step 2: Module Configuration

Most Khalti modules for WHMCS require you to define the Currency as NPR.

  • Conversion: If your invoice is in USD, ensure the module is set to “Convert to For Processing.” Khalti will only accept the final amount in Paisa (100 Paisa = 1 NPR).
  • Callback URL: Usually https://yourdomain.com/modules/gateways/callback/khaltigateway.php.
  • Internal Link: For a comparison of performance, see our Best Web Hosting in Nepal 2026 guide.

Integrating Fonepay (Dynamic QR)

Fonepay is not a wallet; it is a network. This makes it unique because a customer can pay your Fonepay QR using any banking app in Nepal. In 2026, the gold standard is Dynamic QR.

Static vs. Dynamic QR

  • Static QR: A fixed sticker on your wall. The customer has to type the amount. (Bad for automation).
  • Dynamic QR: WHMCS generates a unique QR code for that specific invoice and that specific amount. When the customer scans it, the amount is pre-filled. Once they hit pay, WHMCS is notified instantly.

Step 1: Registration via Bank

You usually cannot get a Fonepay merchant account directly from Fonepay. You must visit your bank (e.g., Nabil, Global IME, NIC Asia) and request Fonepay Merchant QR Integration.

  • Ask specifically for API Access for Dynamic QR.

Step 2: Module Setup

Modules like those from WHMPress or AGM Web Hosting allow you to embed the Fonepay QR directly on the WHMCS invoice page.

  • Merchant Code: Provided by your bank.
  • Password/Secret: Provided for API authentication.

Advanced Automation: The “Reseller Hosting” Logic

As a reseller, you aren’t just taking money; you are managing a lifecycle.

I. Tax & Service Fees

In Nepal, gateways often charge between 1.5% and 3% per transaction.

  • Decision: Do you absorb the cost or pass it to the customer? WHMCS allows you to add a “Payment Gateway Surcharge,” but be carefulโ€”under the new consumer laws, hidden fees can lead to complaints. It is often better to price your hosting slightly higher and offer “Free eSewa Payments.”

II. Multi-Currency Handling

If you sell to international clients via Stripe/PayPal AND local clients via eSewa:

  1. Set USD as your Default Currency.
  2. Ensure eSewa/Khalti modules are set to convert USD to NPR using the current exchange rate at the moment of checkout.

III. Automated Provisioning

Go to Products/Services > Edit Product > Module Settings.

  • Select “Automatically setup the product as soon as the first payment is received.”
  • This ensures that the moment the eSewa callback hits your site, the customer gets their “Welcome Email” with their cPanel login details.

Troubleshooting Common Errors

1. The “Paid but Pending” Problem

This is the most common issue where a customer pays, but the invoice remains “Unpaid.”

  • Cause: The gateway’s callback (IPN) was blocked by your server’s firewall (ModSecurity) or your site’s SSL is invalid.
  • Fix: Whitelist the gateway IPs in your server and check the Gateway Log (Billing > Gateway Log) in WHMCS to see the error message.

2. HMAC Signature Mismatch

  • Cause: Using an old v1 module with a v2 Secret Key, or vice-versa.
  • Fix: Ensure your module version matches the API version of the provider.

3. cURL Timeout

  • Cause: Your server cannot “talk” to the eSewa/Khalti servers.
  • Fix: Contact your hosting provider (like PokharaHost) to ensure outgoing connections to Nepali payment IPs are open.

Compliance & Security: The 2026 Checklist

With the Nepal Data Privacy Act, how you handle payment data matters.

  1. Never Store Wallet Pins: WHMCS gateways should only handle the transaction token, never the customerโ€™s eSewa or Khalti password.
  2. Audit Logs: Regularly check your Gateway Logs for suspicious failed attempts.
  3. Refunds: WHMCS doesn’t always support automated refunds for Nepali gateways. Most refunds must be done manually via the Merchant Portal, then marked as “Refunded” in WHMCS.

Exhaustive FAQ: WHMCS Payments in Nepal

Q1: Can I use one eSewa merchant account for multiple WHMCS sites? A: No. Each Merchant ID is usually tied to a specific domain. You should request separate sub-accounts if you run multiple brands.

Q2: Is there a free WHMCS module for Khalti? A: Yes, Khalti provides an official module on GitHub, though third-party premium modules often offer better “one-click” setup and support.

Q3: How do I handle VAT in WHMCS for Nepal? A: Go to Setup > Tax Rules. Add a 13% tax rule for “Nepal.” Ensure your product prices are set to “Tax Exclusive” so the 13% is added at checkout.

Q4: Does Fonepay support international cards in WHMCS? A: Yes! If you use the Fonepay network, customers can often pay using international travel cards or UPI (from India), making it great for resellers targeting the SAARC region.

Q5: What is the best way to test before going live? A: Always use the Sandbox/Test URLs. For eSewa, you can use the test credentials provided in their docs. Never test with live money until the sandbox “Handshake” is 100% successful.


Conclusion: Building a Frictionless Hosting Brand

Setting up eSewa, Khalti, and Fonepay with WHMCS is a significant technical milestone. It marks the transition from a manual operator to a professional Hosting Provider.

In the competitive Nepali market, speed is your greatest weapon. When a developer in Kathmandu needs a VPS at midnight to fix a bug, the host that allows them to pay via Khalti and get instant access will always win.

Ready to automate? If you are a PokharaHost Reseller, our team can help you configure your gateway modules for free. Let’s get your business running 24/7.

Nalesh Bhandari - Senior Technical Content Strategist
Nalesh Bhandari - Senior Technical Content Strategisthttps://pokharahost.com/blog
Nalesh Bhandari is a Senior Technical Content Strategist at Pokhara Host, bringing over 7 years of hands-on experience in the Web Hosting, VPS Servers, and Domain Infrastructure industry. His expertise lies in simplifying complex hosting technology and making informed decisions accessible to Nepali entrepreneurs and developers. He is dedicated to ensuring Pokhara Hostโ€™s content is technically accurate and focused on local market needs

Read more

Local News