{"id":8879,"date":"2026-03-10T10:30:41","date_gmt":"2026-03-10T10:30:41","guid":{"rendered":"https:\/\/pokharahost.com\/blog\/?p=8879"},"modified":"2026-04-20T10:37:08","modified_gmt":"2026-04-20T10:37:08","slug":"integrate-esewa-khalti-fonepay-whmcs-nepal","status":"publish","type":"post","link":"https:\/\/pokharahost.com\/blog\/integrate-esewa-khalti-fonepay-whmcs-nepal\/","title":{"rendered":"How to Integrate eSewa, Khalti &amp; Fonepay with WHMCS: The Ultimate Automation Guide"},"content":{"rendered":"\n<p>In the world of web hosting, <strong>automation is the difference between a side hustle and a scalable business.<\/strong> 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.<\/p>\n\n\n\n<p>To achieve this, you need a robust integration between <strong>WHMCS (Web Host Manager Complete Solution)<\/strong> and Nepal\u2019s leading payment gateways: <strong>eSewa, Khalti, and Fonepay.<\/strong><\/p>\n\n\n\n<p>As part of our <strong>Week 2 Deep Dive<\/strong>, we are moving past the &#8220;why&#8221; and getting into the &#8220;how.&#8221; 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Business Case for Payment Automation in Nepal<\/h2>\n\n\n\n<p>Before we touch the code, let&#8217;s look at the numbers. A typical reseller in Pokhara spends approximately 4-6 hours a week manually verifying payments. With the <strong>Nepal E-commerce Act of 2025<\/strong> now in full effect, consumer expectations for &#8220;Instant Fulfillment&#8221; have peaked.<\/p>\n\n\n\n<p><strong>Benefits of Integration:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Zero Human Intervention:<\/strong> Invoices are marked &#8220;Paid&#8221; automatically.<\/li>\n\n\n\n<li><strong>Instant Provisioning:<\/strong> WHMCS tells cPanel\/WHM to create the account immediately upon payment.<\/li>\n\n\n\n<li><strong>Reduced Churn:<\/strong> Customers are less likely to leave if the renewal process is friction-free.<\/li>\n\n\n\n<li><strong>Professionalism:<\/strong> A professional checkout experience builds trust, which is the #1 currency in the hosting industry.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Pre-Requisites: Preparing Your WHMCS Environment<\/h2>\n\n\n\n<p>Before installing any modules, your infrastructure must be ready. 2026 standards require higher security and specific localization.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>I. SSL &amp; HTTPS (Mandatory)<\/strong><\/h3>\n\n\n\n<p>All Nepali gateways (especially eSewa v2 and Khalti) require a secure callback environment. Your WHMCS must be running on <code>https:\/\/<\/code>. Ensure your SSL certificate is valid and not expired.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>II. Currency Configuration<\/strong><\/h3>\n\n\n\n<p>Most resellers pay their upstream providers (like PokharaHost or international data centers) in <strong>USD<\/strong> but charge local clients in <strong>NPR<\/strong>.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Go to <strong>Setup > Payments > Currencies<\/strong>.<\/li>\n\n\n\n<li>Add <strong>NPR<\/strong> as a currency.<\/li>\n\n\n\n<li>Set the <strong>Base Conversion Rate<\/strong>. (Pro Tip: Use the &#8220;Update Exchange Rates&#8221; button, but add a 2-3% &#8220;Forex Buffer&#8221; to cover bank conversion fees).<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>III. System Cron Job<\/strong><\/h3>\n\n\n\n<p>Ensure your WHMCS Cron is running every 5 minutes. Without a functioning cron, the automation &#8220;handshake&#8221; between the gateway and your server might fail.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Integrating eSewa (v2 API)<\/h2>\n\n\n\n<p id=\"p-rc_8d90e649006db7fb-26\">eSewa remains the &#8220;Big Brother&#8221; of digital wallets in Nepal. In late 2025, they fully deprecated the v1 API in favor of <strong>eSewa ePay v2<\/strong>, which uses more secure <strong>HMAC-SHA256<\/strong> signatures.<sup><\/sup><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Merchant Account Setup<\/strong><\/h3>\n\n\n\n<p>You cannot use a personal eSewa account for WHMCS.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Requirements:<\/strong> Company Registration, PAN\/VAT Certificate, and a Business Bank Account.<\/li>\n\n\n\n<li><strong>Access:<\/strong> Sign up at the <a href=\"https:\/\/merchant.esewa.com.np\" target=\"_blank\" rel=\"noreferrer noopener\">eSewa Merchant Portal<\/a>.<\/li>\n\n\n\n<li><strong>Keys Needed:<\/strong> You will receive a <code>Merchant ID<\/code>, a <code>Secret Key<\/code> (for HMAC), and a <code>Product Code<\/code>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Module Installation<\/strong><\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Download a compatible eSewa v2 WHMCS module (check the <a href=\"https:\/\/marketplace.whmcs.com\/product\/7945-esewa-payment-gateway\" target=\"_blank\" rel=\"noreferrer noopener\">WHMCS Marketplace<\/a>).<\/li>\n\n\n\n<li>Upload the files to <code>\/modules\/gateways\/<\/code>. You should see <code>esewa.php<\/code> and a callback file in <code>\/modules\/gateways\/callback\/esewa.php<\/code>.<\/li>\n\n\n\n<li>In WHMCS Admin, go to <strong>System Settings > Payment Gateways > All Gateways<\/strong> and activate <strong>eSewa<\/strong>.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Configuration<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Merchant ID:<\/strong> Enter your official ID.<\/li>\n\n\n\n<li><strong>Secret Key:<\/strong> Paste the HMAC key.<\/li>\n\n\n\n<li><strong>Service Delivery Charge:<\/strong> (Optional) If you want to pass the eSewa fee to the customer.<\/li>\n\n\n\n<li><strong>Test Mode:<\/strong> Keep this enabled until you complete a successful transaction in the eSewa Sandbox.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Integrating Khalti: The Developer\u2019s Choice<\/h2>\n\n\n\n<p id=\"p-rc_8d90e649006db7fb-28\">Khalti is widely praised for its clean API documentation and reliable &#8220;Lookup&#8221; system.<sup><\/sup> After their merger with IME Pay, their reach has expanded significantly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The Technical Flow<\/strong><\/h3>\n\n\n\n<p>Unlike eSewa, which often relies on a POST redirect, Khalti uses a <code>pidx<\/code> (Payment ID) system.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>WHMCS requests a <code>pidx<\/code> from Khalti.<\/li>\n\n\n\n<li>The customer is redirected to the Khalti payment page.<\/li>\n\n\n\n<li>After payment, Khalti redirects back to your WHMCS with a transaction status.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Getting API Keys<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Visit the <a href=\"https:\/\/admin.khalti.com\" target=\"_blank\" rel=\"noreferrer noopener\">Khalti Merchant Dashboard<\/a>.<\/li>\n\n\n\n<li>Go to <strong>Settings > API Keys<\/strong>.<\/li>\n\n\n\n<li>You will need the <strong>Live Secret Key<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Module Configuration<\/strong><\/h3>\n\n\n\n<p id=\"p-rc_8d90e649006db7fb-30\">Most Khalti modules for WHMCS require you to define the <strong>Currency<\/strong> as NPR.<sup><\/sup><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Conversion:<\/strong> If your invoice is in USD, ensure the module is set to &#8220;Convert to For Processing.&#8221; Khalti will only accept the final amount in Paisa (100 Paisa = 1 NPR).<\/li>\n\n\n\n<li><strong>Callback URL:<\/strong> Usually <code>https:\/\/yourdomain.com\/modules\/gateways\/callback\/khaltigateway.php<\/code>.<\/li>\n\n\n\n<li><strong>Internal Link:<\/strong> For a comparison of performance, see our <a href=\"https:\/\/pokharahost.com\/blog\/best-web-hosting-nepal-comparison-ranking\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best Web Hosting in Nepal 2026<\/a> guide.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Integrating Fonepay (Dynamic QR)<\/h2>\n\n\n\n<p id=\"p-rc_8d90e649006db7fb-31\">Fonepay is not a wallet; it is a <strong>network<\/strong>.<sup><\/sup> This makes it unique because a customer can pay your Fonepay QR using <em>any<\/em> banking app in Nepal. In 2026, the gold standard is <strong>Dynamic QR<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Static vs. Dynamic QR<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Static QR:<\/strong> A fixed sticker on your wall. The customer has to type the amount. (Bad for automation).<\/li>\n\n\n\n<li><strong>Dynamic QR:<\/strong> WHMCS generates a unique QR code for <em>that specific invoice<\/em> and <em>that specific amount<\/em>. When the customer scans it, the amount is pre-filled. Once they hit pay, WHMCS is notified instantly.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Registration via Bank<\/strong><\/h3>\n\n\n\n<p id=\"p-rc_8d90e649006db7fb-33\">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 <strong>Fonepay Merchant QR Integration<\/strong>.<sup><\/sup><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ask specifically for <strong>API Access for Dynamic QR<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Module Setup<\/strong><\/h3>\n\n\n\n<p id=\"p-rc_8d90e649006db7fb-34\">Modules like those from <strong>WHMPress<\/strong> or <strong>AGM Web Hosting<\/strong> allow you to embed the Fonepay QR directly on the WHMCS invoice page.<sup><\/sup><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Merchant Code:<\/strong> Provided by your bank.<\/li>\n\n\n\n<li><strong>Password\/Secret:<\/strong> Provided for API authentication.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Advanced Automation: The &#8220;Reseller Hosting&#8221; Logic<\/h2>\n\n\n\n<p>As a reseller, you aren&#8217;t just taking money; you are managing a lifecycle.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>I. Tax &amp; Service Fees<\/strong><\/h3>\n\n\n\n<p>In Nepal, gateways often charge between 1.5% and 3% per transaction.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Decision:<\/strong> Do you absorb the cost or pass it to the customer? WHMCS allows you to add a &#8220;Payment Gateway Surcharge,&#8221; but be careful\u2014under the new consumer laws, hidden fees can lead to complaints. It is often better to price your hosting slightly higher and offer &#8220;Free eSewa Payments.&#8221;<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>II. Multi-Currency Handling<\/strong><\/h3>\n\n\n\n<p>If you sell to international clients via Stripe\/PayPal AND local clients via eSewa:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Set <strong>USD<\/strong> as your Default Currency.<\/li>\n\n\n\n<li>Ensure eSewa\/Khalti modules are set to convert USD to NPR using the current exchange rate at the moment of checkout.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>III. Automated Provisioning<\/strong><\/h3>\n\n\n\n<p>Go to <strong>Products\/Services &gt; Edit Product &gt; Module Settings<\/strong>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select <strong>&#8220;Automatically setup the product as soon as the first payment is received.&#8221;<\/strong><\/li>\n\n\n\n<li>This ensures that the moment the eSewa callback hits your site, the customer gets their &#8220;Welcome Email&#8221; with their cPanel login details.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting Common Errors<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. The &#8220;Paid but Pending&#8221; Problem<\/strong><\/h3>\n\n\n\n<p>This is the most common issue where a customer pays, but the invoice remains &#8220;Unpaid.&#8221;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Cause:<\/strong> The gateway&#8217;s callback (IPN) was blocked by your server&#8217;s firewall (ModSecurity) or your site&#8217;s SSL is invalid.<\/li>\n\n\n\n<li><strong>Fix:<\/strong> Whitelist the gateway IPs in your server and check the <strong>Gateway Log<\/strong> (<strong>Billing > Gateway Log<\/strong>) in WHMCS to see the error message.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. HMAC Signature Mismatch<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Cause:<\/strong> Using an old v1 module with a v2 Secret Key, or vice-versa.<\/li>\n\n\n\n<li><strong>Fix:<\/strong> Ensure your module version matches the API version of the provider.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. cURL Timeout<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Cause:<\/strong> Your server cannot &#8220;talk&#8221; to the eSewa\/Khalti servers.<\/li>\n\n\n\n<li><strong>Fix:<\/strong> Contact your hosting provider (like PokharaHost) to ensure outgoing connections to Nepali payment IPs are open.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Compliance &amp; Security: The 2026 Checklist<\/h2>\n\n\n\n<p>With the <strong>Nepal Data Privacy Act<\/strong>, how you handle payment data matters.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Never Store Wallet Pins:<\/strong> WHMCS gateways should only handle the transaction token, never the customer\u2019s eSewa or Khalti password.<\/li>\n\n\n\n<li><strong>Audit Logs:<\/strong> Regularly check your Gateway Logs for suspicious failed attempts.<\/li>\n\n\n\n<li><strong>Refunds:<\/strong> WHMCS doesn&#8217;t always support automated refunds for Nepali gateways. Most refunds must be done manually via the Merchant Portal, then marked as &#8220;Refunded&#8221; in WHMCS.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Exhaustive FAQ: WHMCS Payments in Nepal<\/h2>\n\n\n\n<p><strong>Q1: Can I use one eSewa merchant account for multiple WHMCS sites?<\/strong> A: No. Each Merchant ID is usually tied to a specific domain. You should request separate sub-accounts if you run multiple brands.<\/p>\n\n\n\n<p><strong>Q2: Is there a free WHMCS module for Khalti?<\/strong> A: Yes, Khalti provides an official module on GitHub, though third-party premium modules often offer better &#8220;one-click&#8221; setup and support.<\/p>\n\n\n\n<p><strong>Q3: How do I handle VAT in WHMCS for Nepal?<\/strong> A: Go to <strong>Setup &gt; Tax Rules<\/strong>. Add a 13% tax rule for &#8220;Nepal.&#8221; Ensure your product prices are set to &#8220;Tax Exclusive&#8221; so the 13% is added at checkout.<\/p>\n\n\n\n<p id=\"p-rc_8d90e649006db7fb-35\"><strong>Q4: Does Fonepay support international cards in WHMCS?<\/strong> 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.<sup><\/sup><\/p>\n\n\n\n<p><strong>Q5: What is the best way to test before going live?<\/strong> A: Always use the <strong>Sandbox\/Test URLs<\/strong>. For eSewa, you can use the test credentials provided in their docs. Never test with live money until the sandbox &#8220;Handshake&#8221; is 100% successful.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion: Building a Frictionless Hosting Brand<\/h2>\n\n\n\n<p>Setting up eSewa, Khalti, and Fonepay with WHMCS is a significant technical milestone. It marks the transition from a manual operator to a professional <strong>Hosting Provider<\/strong>.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Ready to automate? If you are a <a href=\"https:\/\/pokharahost.com\/reseller-hosting-in-nepal.php\" target=\"_blank\" rel=\"noreferrer noopener\">PokharaHost Reseller<\/a>, our team can help you configure your gateway modules for free. Let&#8217;s get your business running 24\/7.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8880,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[579,576,578,493,575],"class_list":{"0":"post-8879","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-guides-tutorials","8":"tag-esewa-whmcs-integration","9":"tag-fonepay-dynamic-qr","10":"tag-khalti-whmcs-module","11":"tag-reseller-hosting-nepal","12":"tag-whmcs-payment-nepal"},"_links":{"self":[{"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/posts\/8879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/comments?post=8879"}],"version-history":[{"count":1,"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/posts\/8879\/revisions"}],"predecessor-version":[{"id":8881,"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/posts\/8879\/revisions\/8881"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/media\/8880"}],"wp:attachment":[{"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/media?parent=8879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/categories?post=8879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pokharahost.com\/blog\/wp-json\/wp\/v2\/tags?post=8879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}