A Nepal restaurant SaaS needed to accept Khalti and eSewa for domestic outlets and Stripe for international orders. The chains also needed owners to reconcile all three without double-counting a payment. I built the payment layer for that system instead of treating gateway integration as a generic checkout tutorial.
The platform served restaurant chains and multi-outlet food businesses in Nepal. Orders came from counters and online channels, while owners wanted a single revenue view across outlets. An off-the-shelf POS did not fit the payment landscape or the operating flow, so I designed a gateway abstraction before adding the second provider.
Khalti, eSewa, and Stripe each returned different webhook payloads and retry semantics. A callback could arrive more than once, and a naive update could create a duplicate financial record. That was the hard part: the app needed one payment state while each provider described success differently.
I wrote a provider adapter for each gateway and a normalization layer behind it. The order service called one payment interface; the adapter handled initiation, callback verification, status mapping, and retry behavior. Webhook endpoints used idempotency keys so repeated delivery could not mark the same order paid twice.
$gateway = match($restaurant->region) {
'nepal' => $restaurant->payment_method === 'khalti'
? new KhaltiGateway()
: new eSewaGateway(),
default => new StripeGateway(),
};
$gateway->charge($order->total, $order->paymentMeta());Nepal-based restaurants routed to Khalti or eSewa; international orders routed to Stripe. Queue workers processed payment updates and notifications outside the HTTP request, while webhook reconciliation kept the order ledger aligned with provider state.
The platform now runs for multiple restaurant chains and handles daily orders. Owners get one dashboard across outlets and reconciled multi-gateway payments. The real lesson was timing: the abstraction had to exist before the second gateway, not after payment behavior started leaking into orders, reports, and support workflows.
