
September 09, 2026
14 min read
By Kokil Thapa | Last reviewed: September 2026
Your checkout works, but customers abandon when you only show bank transfer details. IME Pay Integration for Nepal Businesses closes that gap by letting shoppers pay from the IME Pay wallet or linked bank account and return to your site with a verifiable status. IME Pay sits alongside eSewa, Khalti, and ConnectIPS as a mainstream option for Nepal-based eCommerce, booking portals, and service platforms. This guide walks through merchant onboarding, server-side payment initiation, callback handling, and production hardening—the same patterns I use on API development projects for Nepal clients running Laravel 13 on PHP 8.3 or higher.
What is IME Pay and why should Nepal businesses integrate it?
IME Pay is a digital wallet and payment service operated under IME Group, widely used across Nepal for mobile top-ups, utility bills, and merchant payments. For a business website, integration means your application talks to IME Pay’s merchant backend instead of asking customers to send money manually.
That shift matters for three practical reasons. First, conversion: customers who already hold an IME Pay balance can pay in seconds. Second, reconciliation: each transaction carries a reference your system can match to an order row. Third, trust: a recognised wallet badge on checkout reduces hesitation compared to sharing a personal bank account number.
On legal-tech and booking portals I have shipped—client payment collection on platforms like Mijar Law Associates—local gateways are not optional extras. They are part of the product. IME Pay belongs in that stack when your audience includes IME Pay wallet users, which is common outside the Kathmandu valley as mobile money adoption grows.
If you are evaluating whether to add IME Pay now or later, read how to start an eCommerce business in Nepal in 2026 for the broader payment mix most stores need at launch.
How does IME Pay integration work for Laravel and PHP applications?
Most IME Pay merchant integrations follow a redirect-and-callback model, similar to eSewa and Khalti. Your server creates a payment session, the customer authorises payment on IME Pay’s hosted page or app, and IME Pay notifies your backend with the result.
Core integration steps
- Customer submits checkout and selects IME Pay as the payment method.
- Your application creates a pending order with a unique merchant reference (invoice ID).
- Your server calls the IME Pay payment initiation endpoint with amount, reference, and return URLs.
- IME Pay responds with a payment URL or token; you redirect the customer there.
- After payment, IME Pay hits your success/failure return URL and sends a server-to-server callback.
- Your callback handler verifies the signature, checks amount and reference, then updates the order atomically.
Never mark an order paid based only on the browser return URL. Users close tabs. They hit the back button. Callback verification is the source of truth—the same rule covered in our Laravel Khalti and eSewa integration guide.
Laravel service class pattern
Keep gateway logic out of controllers. A dedicated service class makes testing and rotation of credentials straightforward. Below is a representative structure for Laravel 13—you will map field names to the current IME Pay merchant API documentation supplied after onboarding.
<?php
namespace App\Services\Payments;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
class ImepayGateway
{
public function initiate(int $orderId, int $amountPaisa, string $customerPhone): array
{
$reference = 'ORD-' . $orderId . '-' . Str::upper(Str::random(6));
$payload = [
'MerchantCode' => config('imepay.merchant_code'),
'Amount' => $amountPaisa,
'RefId' => $reference,
'SuccessUrl' => route('payments.imepay.success'),
'FailureUrl' => route('payments.imepay.failure'),
'CancelUrl' => route('payments.imepay.cancel'),
'Token' => $this->generateToken($reference, $amountPaisa),
];
$response = Http::timeout(15)
->withHeaders(['Authorization' => 'Bearer ' . config('imepay.api_key')])
->post(config('imepay.base_url') . '/api/merchant/payment/init', $payload);
$response->throw();
return $response->json();
}
private function generateToken(string $reference, int $amountPaisa): string
{
$secret = config('imepay.secret_key');
$data = config('imepay.merchant_code') . $reference . $amountPaisa;
return hash_hmac('sha256', $data, $secret);
}
}
Store credentials in .env, never in Git. Map them through config/imepay.php. Use separate sandbox and production values. Our Laravel payment integrations overview covers shared patterns across Nepal gateways.
Callback controller with idempotency
<?php
namespace App\Http\Controllers;
use App\Models\Order;
use App\Models\Payment;
use App\Services\Payments\ImepayGateway;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ImepayCallbackController extends Controller
{
public function __invoke(Request $request, ImepayGateway $gateway)
{
if (! $gateway->verifyCallback($request->all())) {
abort(403, 'Invalid IME Pay signature');
}
$reference = $request->input('RefId');
$txnId = $request->input('TransactionId');
$amount = (int) $request->input('Amount');
$status = $request->input('Status');
DB::transaction(function () use ($reference, $txnId, $amount, $status, $request) {
$payment = Payment::where('gateway_reference', $reference)->lockForUpdate()->firstOrFail();
if ($payment->status === 'paid') {
return;
}
if ($status !== 'SUCCESS' || $amount !== $payment->amount_paisa) {
$payment->update(['status' => 'failed', 'raw_response' => $request->all()]);
return;
}
$payment->update([
'status' => 'paid',
'gateway_txn_id' => $txnId,
'paid_at' => now(),
'raw_response' => $request->all(),
]);
$payment->order->markAsPaid();
});
return response('OK', 200);
}
}
Register the callback route without CSRF middleware. IME Pay’s servers cannot send your Laravel CSRF token. Exempt only that route in bootstrap/app.php or your middleware configuration.
For pure PHP without Laravel, the same flow applies: one initiation script, one callback endpoint, and PDO transactions around status updates. See the eSewa integration guide for PHP apps for a framework-agnostic baseline you can adapt.
How do you set up IME Pay merchant credentials for a Nepal business?
Before writing code, you need an active IME Pay merchant account. Requirements vary by business type, but the process generally follows Nepal’s standard KYC pattern for payment aggregators supervised under Nepal Rastra Bank oversight.
Documents and business prerequisites
- Registered business with valid PAN and company registration (or sole proprietorship papers).
- Business bank account in the business name—personal accounts are usually rejected.
- Authorized signatory ID and contact details for the merchant portal.
- Website or app URL demonstrating what you sell and your refund policy.
- Technical contact email for API credential delivery and IP whitelisting if required.
If you are still formalising the business entity, read how to get a business PAN for Nepal freelancers and choosing a business bank account for Nepal tech startups first. Payment gateways reject applications that lack matching PAN and bank account names.
Environment configuration
After approval, IME Pay provides sandbox and production credentials. Structure your .env like this:
IMEPAY_ENV=sandbox
IMEPAY_BASE_URL=https://sandbox.imepay.com.np
IMEPAY_MERCHANT_CODE=YOUR_MERCHANT_CODE
IMEPAY_API_KEY=your_api_key_here
IMEPAY_SECRET_KEY=your_secret_key_here
IMEPAY_MODULE=your_module_name_if_required
Confirm exact variable names against the merchant integration PDF IME Pay sends you. Field labels differ between API versions. Do not guess production URLs—use the values in your merchant welcome pack.
On shared hosting or a VPS you manage yourself, keep secrets out of web-readable directories. Our Linux system administration service covers permission hardening if your deployment pipeline is still manual.
Reference Nepal Rastra Bank for the regulatory context around digital payment service providers. IME Pay operates within that framework alongside other licensed wallets.
How do you verify IME Pay payments and handle callbacks securely?
Callback security is where most first integrations fail. A working redirect flow with an unverified callback is worse than no integration—it creates false positives and angry customers.
Signature verification
IME Pay typically signs callback payloads with a shared secret or HMAC scheme. Recompute the signature on your server using the documented field order. Compare with hash_equals() in PHP to prevent timing attacks.
public function verifyCallback(array $payload): bool
{
$received = $payload['Signature'] ?? '';
unset($payload['Signature']);
ksort($payload);
$string = implode('', array_values($payload));
$expected = hash_hmac('sha256', $string, config('imepay.secret_key'));
return hash_equals($expected, $received);
}
Adjust field sorting and concatenation to match IME Pay’s current spec. If their docs say to exclude empty fields, follow that exactly.
Amount and reference checks
Always compare callback amount against your stored order total in the smallest currency unit (paisa for NPR). Floating-point rupee math causes mismatches. Use integers end to end.
Match RefId to your internal payment record, not directly to a user-supplied order ID from the query string. Generate references server-side when the order is created.
For multi-currency display on international storefronts, convert display amounts carefully. Our Nepal forex rates tool helps sanity-check NPR equivalents, but charge customers in NPR at checkout unless IME Pay explicitly supports another settlement currency in your merchant tier.
Production hardening checklist
- Exempt only the callback URI from CSRF; keep all admin routes protected.
- Respond with HTTP 200 only after the database transaction commits.
- Store raw callback JSON for dispute resolution and VAT audit trails.
- Rate-limit the callback endpoint to reduce junk POST noise.
- Alert on signature failures—they may indicate misconfiguration or probing.
- Run callback handling inside a queue only after synchronous verification passes.
VAT reporting for digital sales still applies. Cross-read Nepal VAT and tax compliance for SaaS businesses if you sell subscriptions or software licences through IME Pay.
How does IME Pay compare with eSewa, Khalti, and ConnectIPS?
No single gateway covers every customer. Most Nepal businesses offer two or three options at checkout. Here is a practical comparison based on integration shape and customer behaviour, not marketing claims.
| Gateway | Primary user base | Integration style | Best fit | Watch-outs |
|---|---|---|---|---|
| IME Pay | IME wallet holders, IME agent network users | Redirect + server callback, HMAC token | Retail eCommerce, telecom-adjacent audiences, businesses already in IME ecosystem | Smaller dev community than eSewa; confirm current API PDF with merchant support |
| eSewa | Largest wallet penetration nationally | Redirect + verification endpoint | General-purpose online stores, utilities, mass-market checkout | High expectation—customers assume it is available |
| Khalti | Urban mobile-first users | Redirect + server verification API | Apps, ride/booking flows, younger demographics | Test mobile deep links on both Android and iOS |
| ConnectIPS | Direct bank account holders | Bank redirect, NCHL infrastructure | High-value B2B invoices, customers preferring bank debit | More steps at checkout; see our ConnectIPS integration guide |
On Quick And Easy Nepalese Grocery, a Laravel store with local delivery zones, offering multiple wallets reduced checkout drop-off compared to a single-gateway setup. IME Pay is worth adding when analytics show IME-related payment attempts or when your customer base overlaps IME’s agent corridor footprint.
WooCommerce and Shopify merchants can use official or third-party plugins where available. Custom Laravel carts—like those we build through eCommerce development in Nepal—benefit from a unified payment interface that normalises initiate, verify, and refund methods across gateways.
What are common IME Pay integration mistakes in production?
These failures show up repeatedly on client projects brought in after a launch-day payment outage.
Trusting the browser return URL alone
The success page is UX, not proof of payment. Always wait for the verified callback before sending confirmation email, releasing digital goods, or booking an appointment slot.
Using float rupee amounts
Store amount_paisa as an integer column. Convert Rs 1,250.00 to 125000 at the boundary. Never compare floats from JSON callbacks.
Missing idempotency on callbacks
Gateways retry POST requests. Without a lock or status check, you may dispatch two confirmation emails or double-allocate inventory. The callback controller example above guards with lockForUpdate() and an early return when status is already paid.
Hard-coding sandbox URLs in production
Use environment-driven base URLs. A common deploy mistake is copying .env.example without switching IMEPAY_ENV. Add a startup config check that aborts boot if sandbox URLs are detected when APP_ENV=production.
Skipping reconciliation reports
Download IME Pay settlement reports weekly. Match them against your payments table. Discrepancies usually mean a missed callback or a manual refund processed outside your app. For ongoing monitoring after launch, support and maintenance should include a payment reconciliation task in the runbook.
On a legal-tech portal I built, payment audit trails matter as much as uptime. Store gateway transaction IDs alongside invoice numbers. That pairing saves hours when a client disputes a consultation fee months later.
If you are building from scratch rather than patching an existing store, review eCommerce development in Nepal and best eCommerce platform for small business in Nepal before committing to a gateway mix.
Key Takeaways
- IME Pay integration for Nepal businesses follows redirect-plus-callback flow—verify every payment server-side before fulfilment.
- Complete PAN, business bank account, and merchant KYC before requesting production API credentials from IME Pay.
- Store amounts as integer paisa, generate merchant references server-side, and make callback handlers idempotent with database locks.
- Offer IME Pay alongside eSewa and Khalti rather than as a sole option—different customers prefer different wallets.
- Keep sandbox and production credentials in environment variables and reconcile IME Pay settlement reports against your database weekly.
- Exempt only the IME Pay callback route from CSRF; log signature failures and raw payloads for audit and dispute resolution.
People Also Ask
How long does IME Pay merchant approval take in Nepal?
Approval timelines depend on document completeness and IME Pay’s review queue. Complete PAN, bank account, and website compliance pages before applying. Incomplete KYC is the most common delay. Budget one to three weeks for first-time merchants in 2026.
Can freelancers integrate IME Pay without a registered company?
Most payment gateways require a business PAN and matching business bank account. Sole proprietorship registration often satisfies this. Personal PAN with a personal bank account is typically rejected. Formalise the business entity first.
Does IME Pay support refunds through the API?
Refund capability depends on your merchant agreement and API tier. Some merchants process refunds through the IME Pay merchant portal manually while API refund endpoints roll out. Confirm refund workflow in your integration PDF and design your order admin accordingly.
Is IME Pay integration compatible with WordPress WooCommerce?
WooCommerce 11.1 on WordPress 7.1 can integrate IME Pay through a custom gateway plugin or an available third-party extension. Custom plugins should follow the same callback verification rules as Laravel—use WooCommerce order notes and status transitions only after verified payment.
Ship IME Pay on a production-ready checkout
IME Pay integration for Nepal businesses is straightforward when you treat callbacks as the source of truth, store money as integer paisa, and keep gateway logic in a testable service class. Pair IME Pay with eSewa and Khalti for coverage, add ConnectIPS for bank-first customers, and reconcile settlements weekly.
If you want IME Pay wired into a Laravel booking portal, WooCommerce store, or custom SaaS billing flow, contact us for implementation scoped to your merchant credentials and checkout UX. You can also explore custom software development in Nepal or browse the Notary Nepal portfolio entry for an example of local payment collection on a service portal.
Frequently Asked Questions
0 Comments
Leave a comment
Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

