nutandc/nepal-payment-gateway
Composer 安装命令:
composer require nutandc/nepal-payment-gateway
包简介
Nepal payment gateway integration for Laravel: eSewa, Khalti, ConnectIPS, optional Stripe, idempotent and secure.
README 文档
README
Laravel-first payment gateway package for Nepal gateways with optional Stripe support. Built for PHP 8.2+ and Laravel 10+ with clean, typed, and configurable services.
Features
- Nepal gateways: eSewa, Khalti, ConnectIPS
- Optional Stripe integration (Checkout Session)
- Config-driven endpoints and credentials (no hardcoded URLs)
- Idempotency support to prevent duplicate transactions
- PSR-3 logging and structured error handling
- SOLID, typed, and testable services
Gateway flags
| Gateway | Config Key | Default |
|---|---|---|
| eSewa | NEPAL_PAYMENT_ESEWA_ENABLED |
true |
| Khalti | NEPAL_PAYMENT_KHALTI_ENABLED |
true |
| ConnectIPS | NEPAL_PAYMENT_CONNECTIPS_ENABLED |
true |
| Stripe | NEPAL_PAYMENT_STRIPE_ENABLED |
false |
Requirements
- PHP 8.2+
- Laravel 10/11/12
- Extensions:
ext-curl,ext-openssl
Installation
composer require nutandc/nepal-payment-gateway
Publish config:
php artisan vendor:publish --tag=nepal-payment-suite-config
Configuration
Copy .env.example values into your Laravel .env file and update them for your gateway accounts.
Set .env values as needed (examples):
NEPAL_PAYMENT_GATEWAY=esewa NEPAL_PAYMENT_ESEWA_ENABLED=true NEPAL_PAYMENT_ESEWA_BASE_URL=your_esewa_base_url NEPAL_PAYMENT_ESEWA_ENDPOINT_INITIATE=your_esewa_initiate_path NEPAL_PAYMENT_ESEWA_ENDPOINT_VERIFY=your_esewa_verify_path NEPAL_PAYMENT_ESEWA_PRODUCT_CODE=your_product_code NEPAL_PAYMENT_ESEWA_SECRET_KEY=your_secret_key NEPAL_PAYMENT_KHALTI_ENABLED=true NEPAL_PAYMENT_KHALTI_BASE_URL=your_khalti_base_url NEPAL_PAYMENT_KHALTI_ENDPOINT_INITIATE=your_khalti_initiate_path NEPAL_PAYMENT_KHALTI_ENDPOINT_LOOKUP=your_khalti_lookup_path NEPAL_PAYMENT_KHALTI_SECRET_KEY=your_secret_key NEPAL_PAYMENT_CONNECTIPS_ENABLED=true NEPAL_PAYMENT_CONNECTIPS_BASE_URL=your_connectips_base_url NEPAL_PAYMENT_CONNECTIPS_ENDPOINT_INITIATE=your_connectips_initiate_path NEPAL_PAYMENT_CONNECTIPS_ENDPOINT_VERIFY=your_connectips_verify_path NEPAL_PAYMENT_CONNECTIPS_MERCHANT_ID=your_merchant_id NEPAL_PAYMENT_CONNECTIPS_APP_ID=your_app_id NEPAL_PAYMENT_CONNECTIPS_APP_NAME=your_app_name NEPAL_PAYMENT_CONNECTIPS_PRIVATE_KEY=/path/to/private.pem NEPAL_PAYMENT_CONNECTIPS_PRIVATE_KEY_PASSPHRASE=optional_passphrase NEPAL_PAYMENT_CONNECTIPS_PASSWORD=your_password NEPAL_PAYMENT_LOGGING_ENABLED=true NEPAL_PAYMENT_IDEMPOTENCY_ENABLED=true NEPAL_PAYMENT_IDEMPOTENCY_TTL=86400 NEPAL_PAYMENT_STRIPE_ENABLED=false NEPAL_PAYMENT_STRIPE_SECRET=your_stripe_secret
Usage
All gateways are accessed via the GatewayManager service.
eSewa (payment + verify)
use Nutandc\NepalPaymentSuite\Services\GatewayManager; $gateway = app(GatewayManager::class)->esewa(); $payment = $gateway->payment([ 'amount' => '1000', 'tax_amount' => '0', 'total_amount' => '1000', 'transaction_uuid' => 'txn_123', 'product_code' => 'YOUR_PRODUCT_CODE', 'success_url' => route('esewa.success'), 'failure_url' => route('esewa.failure'), ]); // Auto-submit HTML form: echo $payment->redirectForm(); $verify = $gateway->verify([ 'transaction_uuid' => 'txn_123', 'total_amount' => '1000', 'product_code' => 'YOUR_PRODUCT_CODE', ]); if ($verify->isSuccess()) { // handle success }
Khalti (payment + verify)
use Nutandc\NepalPaymentSuite\Services\GatewayManager; $gateway = app(GatewayManager::class)->khalti(); $payment = $gateway->payment([ 'return_url' => route('khalti.return'), 'website_url' => config('app.url'), 'amount' => 1000, 'purchase_order_id' => 'order_123', 'purchase_order_name' => 'Order #123', ]); return redirect()->away($payment->redirectUrl()); $verify = $gateway->verify([ 'pidx' => 'pidx_123', ]);
ConnectIPS (payment + verify)
use Nutandc\NepalPaymentSuite\Services\GatewayManager; $gateway = app(GatewayManager::class)->connectIps(); $payment = $gateway->payment([ 'transaction_id' => 'txn_123', 'transaction_amount' => 1000, 'remarks' => 'Order payment', 'particulars' => 'Order #123', 'reference_id' => 'ref_123', 'success_url' => route('connectips.success'), 'failure_url' => route('connectips.failure'), ]); echo $payment->redirectForm(); $verify = $gateway->verify([ 'reference_id' => 'ref_123', 'transaction_amount' => 1000, ]);
Stripe (optional)
Install the Stripe SDK and enable the gateway:
composer require stripe/stripe-php
NEPAL_PAYMENT_STRIPE_ENABLED=true NEPAL_PAYMENT_STRIPE_SECRET=sk_test_xxx
Usage (amount is in the smallest currency unit, e.g. cents):
use Nutandc\NepalPaymentSuite\Services\GatewayManager; $gateway = app(GatewayManager::class)->stripe(); $payment = $gateway->payment([ 'amount' => 1500, 'currency' => 'usd', 'product_name' => 'Subscription', 'success_url' => route('stripe.success'), 'cancel_url' => route('stripe.cancel'), ]); return redirect()->away($payment->redirectUrl());
Idempotency
Pass a custom idempotency key for any payment call:
$gateway->payment($payload, 'order-123');
Testing
composer install
composer test
composer analyse
composer fix:dry
License
MIT
nutandc/nepal-payment-gateway 适用场景与选型建议
nutandc/nepal-payment-gateway 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「gateway」 「stripe」 「laravel」 「esewa」 「khalti」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nutandc/nepal-payment-gateway 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nutandc/nepal-payment-gateway 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nutandc/nepal-payment-gateway 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
Flexible payment integration for Laravel, lunarphp, supporting multiple payment providers.
Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Client library to send SMS using Comilio SMS Gateway API (https://www.comilio.it)
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-03