Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

IME Pay Integration for Nepal Businesses

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.

IME Pay Integration OverviewCustomerCheckout pageYour ServerLaravel / PHP appIME PayPayment gatewayVerified order marked paid in databaseOnly after server-side callback signature checkIdempotent update prevents double fulfilment
IME Pay integration for Nepal businesses: customer checkout, merchant server, and gateway verification flow

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

  1. Customer submits checkout and selects IME Pay as the payment method.
  2. Your application creates a pending order with a unique merchant reference (invoice ID).
  3. Your server calls the IME Pay payment initiation endpoint with amount, reference, and return URLs.
  4. IME Pay responds with a payment URL or token; you redirect the customer there.
  5. After payment, IME Pay hits your success/failure return URL and sends a server-to-server callback.
  6. 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.

IME Pay Payment Sequence1. Checkout2. Init API3. Redirect4. CallbackServer-side handler responsibilitiesValidate HMAC / signature from IME PayMatch amount to order total in paisaReject duplicate callback with idempotency keyQueue email / SMS only after DB commitLog raw payload for audit trail
Four-step IME Pay payment sequence with server-side callback verification duties

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.

IME Pay Merchant OnboardingPAN + BankBusiness KYCApplyMerchant portalSandboxTest paymentsGo LiveProduction keysBefore requesting production credentialsHTTPS on all callback and return URLsSuccessful sandbox test with exact order amountRefund and cancellation policy published on siteServer logs show verified callback handling
IME Pay merchant onboarding path from PAN registration through sandbox testing to production go-live

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.

GatewayPrimary user baseIntegration styleBest fitWatch-outs
IME PayIME wallet holders, IME agent network usersRedirect + server callback, HMAC tokenRetail eCommerce, telecom-adjacent audiences, businesses already in IME ecosystemSmaller dev community than eSewa; confirm current API PDF with merchant support
eSewaLargest wallet penetration nationallyRedirect + verification endpointGeneral-purpose online stores, utilities, mass-market checkoutHigh expectation—customers assume it is available
KhaltiUrban mobile-first usersRedirect + server verification APIApps, ride/booking flows, younger demographicsTest mobile deep links on both Android and iOS
ConnectIPSDirect bank account holdersBank redirect, NCHL infrastructureHigh-value B2B invoices, customers preferring bank debitMore 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.

Which Gateways to Offer?Nepal checkoutMass marketeSewa + KhaltiIME usersAdd IME PayHigh ticketAdd ConnectIPSLegal / bookingAll three wallets
Decision guide for IME Pay integration alongside eSewa, Khalti, and ConnectIPS on Nepal business checkouts

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

IME Pay integration connects your website to IME Pay's merchant API: create a signed payment request, redirect the customer, then verify the server-side callback before marking the order paid.

Three practical reasons drive adoption on real client projects. Conversion improves because customers with an IME Pay balance can pay in seconds instead of manual bank transfer. Reconciliation becomes reliable because each transaction carries a reference your system matches to an order row. Trust increases because a recognised wallet badge reduces hesitation compared to sharing a personal account number. On legal-tech and booking portals I have shipped, local gateways like IME Pay are part of the product, not optional extras when your audience includes wallet users.

Most IME Pay integrations follow a redirect-and-callback model similar to eSewa and Khalti. Your server creates a pending order with a unique merchant reference, calls the payment initiation endpoint with amount, reference, and return URLs, then redirects the customer to IME Pay. After authorisation, IME Pay hits your success or failure return URL and sends a server-to-server callback. Your handler verifies the signature, checks amount and reference, then updates the order atomically inside a database transaction.

Registered business PAN and company registration, a business-name bank account, authorized signatory ID, a live website showing products and refund policy, and a technical contact for API credential delivery.

After merchant approval, IME Pay provides sandbox and production credentials. Store them in .env, never in Git, and map through config/imepay.php using variables such as IMEPAY_ENV, IMEPAY_BASE_URL, IMEPAY_MERCHANT_CODE, IMEPAY_API_KEY, IMEPAY_SECRET_KEY, and IMEPAY_MODULE if required. Use separate sandbox and production values. Confirm exact field names against the merchant integration PDF IME Pay sends you, because labels differ between API versions. Do not guess production URLs—use the values supplied in your merchant welcome pack.

IME Pay typically signs callback payloads with HMAC using a shared secret. Recompute the signature on your server using the documented field order: remove the Signature field, sort remaining fields, concatenate values, and hash with your secret key. Compare using hash_equals() in PHP to prevent timing attacks. Always match callback amount against your stored order total in paisa, not float rupees, and match RefId to your server-generated payment record. Respond with HTTP 200 only after the database transaction commits, and store raw callback JSON for disputes.

IME Pay targets IME wallet holders and IME agent-network users via redirect plus server callback with HMAC token signing—strong for retail eCommerce and telecom-adjacent audiences. eSewa has the largest national wallet penetration and customers often expect it at checkout. Khalti suits urban mobile-first users on apps and booking flows. ConnectIPS serves direct bank account holders through NCHL infrastructure, better for high-value B2B invoices. On a Laravel store like Quick And Easy Nepalese Grocery, offering multiple wallets reduced checkout drop-off compared to a single-gateway setup.

Failures I see repeatedly on client projects brought in after launch-day outages include trusting the browser return URL instead of the verified callback, using float rupee amounts instead of integer paisa, missing idempotency so gateway retries double-send confirmations or inventory updates, hard-coding sandbox URLs when .env is not switched for production, and skipping weekly settlement reconciliation. A working redirect with an unverified callback is worse than no integration—it creates false positives and angry customers who received goods without confirmed payment.

Add IME Pay when checkout analytics show IME-related payment attempts or your customer base overlaps IME's agent-corridor footprint, especially outside Kathmandu valley.

IME Pay's servers POST payment results to your callback URL and cannot send Laravel's CSRF token. Register the callback route without CSRF middleware, exempting only that specific URI in bootstrap/app.php or your middleware configuration while keeping all admin routes protected. This matches the same pattern used for Khalti and eSewa callbacks. Rate-limit the callback endpoint to reduce junk POST noise, alert on signature failures that may indicate misconfiguration or probing, and respond with HTTP 200 only after your database transaction commits successfully.

Gateways retry POST requests, so callback handling must be idempotent. Wrap updates in a database transaction, use lockForUpdate() on the payment row, and return early if status is already paid. This prevents double confirmation emails, duplicate inventory allocation, and repeated order status changes. Store raw callback JSON for dispute resolution and VAT audit trails. Run heavier post-payment work in a queue only after synchronous signature verification and amount matching pass, not before.

Store amount_paisa as an integer column and convert Rs 1,250.00 to 125000 at the boundary. Never compare floats from JSON callbacks because floating-point rupee math causes mismatches. Generate merchant references server-side when the order is created, such as ORD-{orderId}-{random}, and match RefId to your internal payment record rather than a user-supplied order ID from the query string. For international storefronts displaying other currencies, charge customers in NPR at checkout unless IME Pay explicitly supports another settlement currency in your merchant tier.

WooCommerce and Shopify merchants can use official or third-party plugins where available, avoiding hand-written initiation and callback handlers. Custom Laravel carts benefit from a dedicated ImepayGateway service class that keeps gateway logic out of controllers, making credential rotation and testing straightforward. A unified payment interface normalising initiate, verify, and refund methods across gateways works well when you offer IME Pay alongside eSewa, Khalti, and ConnectIPS on the same checkout page.

Keep gateway logic out of controllers using a dedicated service class with initiate() and verifyCallback() methods. Use Laravel's Http facade with a 15-second timeout, generate HMAC-SHA256 tokens from merchant code, reference, and amount in paisa, and handle callbacks in a separate controller with DB transactions and lockForUpdate(). Store credentials in config/imepay.php mapped from .env. On API development projects for Nepal clients, I use Laravel 13 on PHP 8.3 or higher with the same redirect-and-callback patterns shared across other Nepal gateway integrations.

IME Pay operates as a digital wallet and payment service under IME Group within Nepal's framework for digital payment service providers supervised by Nepal Rastra Bank oversight. Merchant onboarding follows standard KYC: registered business with valid PAN, company registration or sole proprietorship papers, business bank account in the business name, authorized signatory ID, and a website demonstrating products plus refund policy. Payment gateways typically reject applications where PAN and bank account names do not match, so formalise your business entity before applying.

Share this article

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.

Quick Contact Options
Choose how you want to connect me: