Khalti by IME in Paymentsnp checkout
Our server starts each Khalti payment with your secret key, the customer pays on Khalti's own page, and we look the payment up with Khalti for the exact amount before the order counts as paid.
- Payments settle to your own Khalti merchant account
- Customers use the options Khalti offers on its page
- IME Pay customers pay through Khalti
Choose how to pay
Log in to your eSewa wallet to payKhalti wallet, mobile banking or internet banking
Scan a QR code with any mobile banking app
Powered by Paymentsnp
How Khalti works in Paymentsnp. Started on our server, finished on Khalti's.
Server-side initiate
When the customer picks Khalti, our server calls Khalti's initiate API with your secret key, the amount in paisa and the attempt id. Your key never reaches the browser.
Khalti's payment page
The customer goes to pay.khalti.com, or test-pay.khalti.com in Test mode, and pays with whatever options Khalti offers there. We refuse a payment URL on any other host.
Lookup for the exact amount
When the customer returns, we ask Khalti's lookup API about that payment. Only Completed, not refunded, for exactly the order's amount marks the order paid.
Background re-check
If Khalti reports the payment as pending, or the customer never comes back, a worker keeps checking with growing gaps, up to 20 checks over about 14 hours.
What we send and what we ask. Two calls, both from our server.
The initiate and lookup calls for a Rs 2,500 order. Test mode uses Khalti's test API host and test-pay.khalti.com.
- Amount
- Sent in paisa, taken from the order
- Reference
- Khalti's
pidx, stored with the attempt - Payment page
pay.khalti.com- Your secret key
- Encrypted at rest, used only by our server
POST https://khalti.com/api/v2/epayment/initiate/
Authorization: Key <your live secret key>
{
"return_url": "<checkout return URL>",
"website_url": "<your site>",
"amount": 250000,
"purchase_order_id": "<payment attempt id>",
"purchase_order_name": "Paymentsnp checkout"
}
// Khalti answers with a pidx and a payment_url.
// The customer is sent there only if the URL is
// https://pay.khalti.com with the same pidx.POST https://khalti.com/api/v2/epayment/lookup/
Authorization: Key <your live secret key>
{ "pidx": "<pidx from initiate>" }
// Paid only when status is "Completed", it is not
// refunded, and total_amount equals 250000 paisa.How we read Khalti's answer. Unclear means pending, never paid.
| Khalti status | Paymentsnp result | What happens next |
|---|---|---|
Completed | Succeeded | Order paid, webhook sent, receipt sent to the customer |
User canceled, Expired, Failed | Failed | The customer can try again or pick another method |
Pending, Initiated | Pending | Checked again in the background; a second payment is blocked meanwhile |
| Amount or pidx mismatch | Not paid | Rejected and never marked paid |
The Rs 10 minimum. Khalti's limit, applied for you.
Khalti does not accept payments under Rs 10. Rather than let a customer pick Khalti and fail on Khalti's page, Paymentsnp applies the limit before the customer sees it.
Your other methods are unaffected. eSewa and Fonepay have no minimum set by Paymentsnp, so a small order can still be paid with one of them.
| Hosted checkout | Khalti is hidden from the list of methods |
|---|---|
| Payment links | Khalti is left out of the link |
| Direct start | Refused with amount_too_small |
Khalti and IME Pay. One method, not two.
IME merged IME Pay into Khalti, and the service is now Khalti by IME. IME Pay customers pay through Khalti, so Paymentsnp checkout shows one Khalti option rather than a separate IME Pay button.
A separate IME Pay option would only make sense if IME confirms an independent merchant API for it. Until then there is nothing extra to set up.
What you need. From Khalti, before Live.
You apply to Khalti as a merchant and paste your own keys into Paymentsnp. Paymentsnp does not open Khalti accounts for you.
| Merchant account | An approved Khalti merchant account |
|---|---|
| Live | The live secret key from your Khalti merchant dashboard |
| Test | A test secret key for Khalti's test environment |
| Minimum amount | Rs 10, Khalti's own limit |
Saving your keys
When you save a key, Paymentsnp checks it with Khalti for the environment you are in. If Khalti rejects it, nothing is saved. Saving does not switch Khalti on; you enable it yourself, separately for Test and Live.
Settlement, fees and refunds stay between you and Khalti. A refund you make in Khalti's panel can be recorded in Paymentsnp so your records match.
Khalti ePayment developer information (opens in a new tab)Questions about Khalti.
Which payment options does the customer see?
Whatever Khalti offers on its own payment page. Paymentsnp sends the customer to Khalti and does not choose or limit Khalti's options.
Why is Khalti missing from my checkout?
Either the order is under Rs 10, Khalti is not enabled for the environment you are in, or its credentials have not been saved. Check Gateways in the dashboard for Test and Live separately.
When does Khalti money reach my account?
Settlement timing and fees are set by your agreement with Khalti. The money goes from Khalti to your own Khalti merchant account; Paymentsnp never holds it.
Can IME Pay customers pay me?
Yes, through Khalti. IME Pay merged into Khalti by IME, so there is no separate IME Pay option.
What if the customer closes the page after paying?
The background worker keeps looking the payment up with Khalti. If Khalti reports it completed for the right amount, the order is recorded as paid, even after the 30 minute expiry.