kpay/laravel-kpay
最新稳定版本:v1.0.0
Composer 安装命令:
composer require kpay/laravel-kpay
包简介
Laravel 12 package for integrating with the K-Pay payment gateway.
README 文档
README
Laravel 12 package for integrating with the K-Pay payment gateway.
Based on the official K-Pay API documentation: https://developers.kpay.africa/documentation.php
Installation
Require the package via Composer:
composer require kpay/laravel-kpay
Publish the config:
php artisan vendor:publish --tag=kpay-config
Configuration
Set these environment variables:
KPAY_BASE_URL=https://pay.esicia.com/ KPAY_API_KEY=your_api_key KPAY_USERNAME=your_username KPAY_PASSWORD=your_password KPAY_RETAILER_ID=YOUR_RETAILER_ID KPAY_RETURL=https://your-app.com/kpay/callback KPAY_REDIRECTURL=https://your-app.com/payment/return KPAY_CURRENCY=RWF
Usage
Initiate a payment
use KPay; $result = KPay::pay([ 'msisdn' => '250783300000', 'email' => 'customer@example.com', 'details' => 'Order #12345', 'refid' => 'ORDER123456789', 'amount' => 5000, 'cname' => 'John Doe', 'cnumber' => 'CUST001', 'pmethod' => 'momo', // momo, cc, spenn ]); // If success == 1, redirect user to $result['url']
Check payment status
use KPay; $status = KPay::checkStatus('ORDER123456789'); // statusid: 01 (success), 02 (failed), 03 (pending)
Webhook (Callback)
By default the package registers:
POST /kpay/callback
K-Pay requires your endpoint to respond:
{ "tid": "...", "refid": "...", "reply": "OK" }
The controller also dispatches events based on statusid:
KPay\LaravelKPay\Events\PaymentSucceededKPay\LaravelKPay\Events\PaymentFailedKPay\LaravelKPay\Events\PaymentPending
To customize the path or middleware:
KPAY_CALLBACK_PATH=kpay/callback KPAY_CALLBACK_MIDDLEWARE=api KPAY_CALLBACK_ENABLED=true
Testing
composer test
Contributing
Please follow our commit message convention (Conventional Commits). See CONTRIBUTING.md.
License
MIT
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-18