1. Go to this page and download the library: Download kpay/laravel-kpay library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kpay / laravel-kpay example snippets
use KPay;
use KPay\LaravelKPay\Enums\PaymentMethod;
$result = KPay::pay([
'msisdn' => '250783300000',
'email' => '[email protected]',
'details' => 'Order #12345',
'refid' => 'ORDER123456789',
'amount' => 5000,
'cname' => 'John Doe',
'cnumber' => 'CUST001',
'pmethod' => PaymentMethod::Momo, // or 'momo', 'cc', 'spenn'
]);
// If success == 1, redirect user to $result['url']
use KPay\LaravelKPay\Events\PaymentSucceeded;
// In your listener:
public function handle(PaymentSucceeded $event): void
{
$event->tid; // K-Pay transaction ID
$event->refid; // your merchant reference
$event->statusid; // '01'
$event->statusdesc; // human-readable status
$event->payaccount; // mobile/card account used
$event->payload; // full raw payload array
}