Dipendra Guragain

Web Development

eSewa and Khalti Payment Integration for Your Website: A Practical Guide for Nepal

Written by

6 min read

How online payments with eSewa, Khalti and Fonepay actually get onto a Nepali website: what you need from each provider, how the payment flow works, the mistakes that lose orders, and what it costs.

Infographic summarising the article "eSewa and Khalti Payment Integration for Your Website: A Practical Guide for Nepal"

Article

Short answer: to accept eSewa or Khalti on your website, you first sign a merchant agreement with each provider and get live keys. Then your website sends the customer to the provider to pay, and your server checks with the provider that the payment really happened before marking the order as paid. That last check is the step most broken integrations skip.

I build ecommerce websites in Kathmandu, and payment integration is the part store owners worry about most. This guide explains the process in plain language, so you know what to ask your developer and what a working setup looks like. If you are a developer, it also covers the technical points that cause most failed or fake payments.

What You Need Before Any Code Is Written

Each provider needs its own merchant account. Expect to provide your business registration, PAN or VAT certificate, a bank account in the business name, and the website address where payments will be taken. Approval can take from a few days to a few weeks, so start this while the website is still being built, not the week before launch.

Both eSewa and Khalti give developers a test environment with test credentials, so the integration can be built and tested before your merchant account is approved. When approval comes through, you receive live keys and the website is switched over.

How the Payment Flow Works

The flow is similar for every Nepali gateway, and it has four steps:

1. The customer clicks Pay with eSewa or Pay with Khalti at checkout. Your server creates the order and asks the provider to start a payment for that exact amount.

2. The customer is sent to the provider's page or app, logs in and confirms the payment.

3. The provider sends the customer back to your website with the result.

4. Your server asks the provider directly whether that payment succeeded and for how much. Only then is the order marked as paid.

Step 4 is not optional. The details in the return address can be edited by anyone. A store that trusts the return address alone can be tricked into treating an unpaid order as paid. Always confirm with the provider's status or lookup service from your server.

eSewa: The Technical Points

eSewa's current payment flow (ePay version 2) needs the payment request to be signed with your secret key, using an HMAC-SHA256 signature over the amount, a unique transaction ID and your product code. The secret key must stay on the server. If it appears in your website's JavaScript, anyone can read it.

Use a new, unique transaction ID for every payment attempt, not just every order. A customer who cancels and tries again needs a fresh ID, otherwise the second attempt can be rejected. After the customer returns, decode the response, check the signature, and then call eSewa's transaction status service to confirm.

Khalti: The Technical Points

Khalti's web checkout works differently. Your server sends the order to Khalti with your secret key, Khalti replies with a payment ID (called `pidx`) and a payment link, and you send the customer to that link. When they come back, your server uses the lookup service with the same `pidx` to confirm the status.

Khalti expects the amount in paisa, not rupees, so NPR 1,500 is sent as 150000. Getting this wrong is the most common Khalti bug I see, and it shows up as payments for one hundredth of the price or one hundred times it.

Fonepay and Bank QR Payments

Fonepay works through your bank rather than through a separate wallet company. Many stores show a static Fonepay QR code at checkout and check payments by hand. That works for low order volumes, but it does not connect payments to orders automatically. A dynamic QR integration, which needs an agreement with Fonepay through your bank, gives each order its own QR code and confirms the payment automatically.

Which Platforms Support This

WooCommerce has plugins for eSewa and Khalti, and a custom plugin can be written when the existing ones are out of date. It is usually the easiest platform for Nepali payments. See WooCommerce development in Nepal.

Shopify depends on the payment apps available to stores in your region, so check what your plan supports before choosing it. Some Nepali Shopify stores use manual payment methods with QR codes instead. See Shopify store setup in Nepal.

Custom websites built with Next.js, Laravel or Node.js can integrate any gateway directly, with full control over the checkout. This costs more to build but suits stores with unusual flows. I compare the three options in Shopify vs WooCommerce vs a custom store in Nepal.

Mistakes That Lose Orders

  • Not confirming payments on the server. This is covered above, and it is the most serious mistake.
  • No handling for customers who close the tab. The payment succeeds but the customer never returns to your site. Run a scheduled check for pending orders, so a paid order is not left as unpaid.
  • Testing only on desktop. Most Nepali customers pay on their phone, often switching to the eSewa or Khalti app and back. Test the full flow on a real phone.
  • Hiding the payment options. Show the eSewa, Khalti and Fonepay logos on product pages, not only at checkout. Customers who do not see their preferred method often leave before they reach the checkout.
  • Keeping cash on delivery as the only fallback. Cash on delivery is still important in Nepal, but offering digital payment with a small incentive can reduce returns and refused deliveries.

What It Costs

There are two costs. The provider charges a fee on each transaction, agreed in your merchant contract, so ask each provider for its current rate. The development cost depends on the platform: a plugin on WooCommerce is a small job, while a custom checkout with several gateways and automatic status checks is a bigger one. My pricing page lists current website packages.

If you want eSewa, Khalti or Fonepay set up on your store, a new store built by an ecommerce website developer in Nepal with payments included from day one, or an existing integration checked for the problems above, get in touch and I'll tell you what your setup needs.

To accept eSewa or Khalti on a website, sign a merchant agreement with each provider to get live keys. The website sends the customer to the provider to pay, and the server then confirms the payment with the provider before marking the order as paid. That server-side confirmation is the step most broken integrations skip.

Web DevelopmentEcommercePaymentseSewaKhaltiNepal

Questions about this article

How do I add eSewa payment to my website?

Sign a merchant agreement with eSewa to get live credentials, then have your developer integrate eSewa's payment flow. The website sends the customer to eSewa to pay, and your server confirms the payment with eSewa's status service before marking the order as paid.

Can I use both eSewa and Khalti on one website?

Yes. Each needs its own merchant account and its own integration, but both can be offered side by side at checkout. Many Nepali stores also offer Fonepay QR and cash on delivery.

Does Shopify support eSewa and Khalti?

It depends on the payment apps available to your store. Check before choosing Shopify. WooCommerce and custom websites can integrate eSewa and Khalti directly.

Why do I need to verify payments on the server?

The details a customer brings back from the payment page can be edited. Asking eSewa or Khalti directly from your server is the only reliable way to know that a payment succeeded and for the right amount.

Want to talk about a similar project?

Start a Conversation