8000 GitHub - clintonngotta/Mpesa-PHP: php implementaion of mpesa api based on daraja documentaion (https://developer.safaricom.co.ke/docs)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

clintonngotta/Mpesa-PHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mpesa-PHP

This project is a vanilla/native PHP implementation of the M-Pesa API based on the Daraja documentation. It provides sample scripts for integrating with M-Pesa's C2B, B2C, B2B, STK Push, and Transaction Status APIs.

Project Structure

  • MpesaPayments.php: Main class for handling authentication and API requests.
  • C2B/: Customer to Business (C2B) endpoint handlers and simulation.
  • B2C/: Business to Customer (B2C) request and callback handlers.
  • B2B/: Business to Business (B2B) request and callback handlers.
  • STKPUSH/: STK Push request and callback handlers.
  • TransactionStatus/: Transaction status query and result handler.
  • cert.cer: Example certificate file for security credentials.

Usage

1. Authentication

All API requests require an access token. The MpesaPayments class handles token generation:

$mpesa = new MpesaPayments();
$accessToken = $mpesa->GenerateAccessToken();

2. C2B (Customer to Business)

  • This endpoint enables developers to receive real time notifications when a client makes a payments to a merchant's Till number or Paybill number. It assumes the payment are made via the SIM card toolkit and as a developer you need to know when that payment hits the merchants till/paybill number for reconciliation and accounting purposes.

3. B2C (Business to Customer)

4. B2B (Business to Business)

5. STK Push

6. Transaction Status

Notes

  • Update callback URLs in MpesaPayments.php to point to your server.
  • Database credentials in C2B/confirmation.php must be set for transaction logging.
  • Security credentials and certificates should be securely managed.

References

About

php implementaion of mpesa api based on daraja documentaion (https://developer.safaricom.co.ke/docs)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0