We created a good PHP package to interact with M-Pesa API. This package can be pulled in via composer or directly downloaded from github. The API allows a merchant to initiate C2B online checkout (PayBill via web) transactions. The merchant submits authentication details, transaction details, callback URI and callback method. After request submission, the merchant receives instant feedback with validity status of their requests. The C2B API handles customer validation and authentication via USSD push. The customer then confirms the transaction. If the validation of the customer fails or the customer declines the transaction, the API makes a callback to the merchant. Otherwise, the transaction is processed and its status is made through a callback.
Installing the package.
When you're using vanilla php, you can leverage the installer script included in the package by adding the following to the scripts section of composer.json: