coding-sniper / mpesa-c2b
A PHP package for easily implementing Mpesa(Daraja) C2B checkout API.
dev-master
2022-03-23 07:21 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2025-06-23 14:22:06 UTC
README
This is a PHP package for easily implementing Mpesa(Daraja) C2B checkout API.
Features
- Initiate an STK push
- Check transaction status.
Installation
Inorder to install:
composer require coding-sniper/mpesa-c2b
Configuration
Fill in your credentials on the credentials.json file
{ "customer_key": "", "callback" : "", "customer_secret" : "", "partyb" : "", "shortcode" : "", "pass_key" : "", "country_code" : "", "environment" : "live" }
Usage
To perform an STK push:
use CodingSniper\MpesaC2B\MpesaC2B; $data = array("phone" => "","amount" => "","account_reference" => "", "trans_description" => ""); $mpesaC2B = new MpesaC2B(); $mpesaC2B->stkPush($data);
To check the transaction status:
use CodingSniper\MpesaC2B\MpesaC2B; $checkID = ""; // the check_id $mpesaC2B = new MpesaC2B(); $mpesaC2B->checkTrans($checkID);
License
MIT
Free Software, Hell Yeah!