Php code
**Introduction**
This package seeks to help php developers implement the various Mpesa APIs without much hustle. It is based on the REST API whose documentation is available on
developer.safaricom.co.ke.
**Installation using composer**
`composer require safaricom/mpesa`
**Configuration**
At your project root, create a .env file and in it set the consumer key and consumer secret as follows
`MPESA_CONSUMER_KEY= [consumer key]`
`MPESA_CONSUMER_SECRET=[consumer secret]`
`MPESA_ENV=[live or sandbox]`
For Laravel users, open the Config/App.php file and add `\Safaricom\Mpesa\MpesaServiceProvider::class` under providers and ` 'Mpesa'=> \Safaricom\Mpesa\MpesaServiceProvider::class` under aliases.
_Remember to edit the consumer_key and consumer_secret values appropriately when switching between sandbox and live_
**Usage**
**Confirmation and validation urls**
**B2C Payment Request**
This creates transaction between an M-Pesa short code to a phone number registered on M-Pesa.
`$mpesa= new \Safaricom\Mpesa\Mpesa();`
`$b2cTransaction=$mpesa->b2c($InitiatorName, $SecurityCredential, $CommandID, $Amount, $PartyA, $PartyB, $Remarks, $QueueTimeOutURL, $ResultURL, $Occasion);`
**Account Balance Request**
This is used to enquire the balance on an M-Pesa BuyGoods (Till Number)
`$mpesa= new \Safaricom\Mpesa\Mpesa();`
`$balanceInquiry=$mpesa->accountBalance($CommandID, $Initiator, $SecurityCredential, $PartyA, $IdentifierType, $Remarks, $QueueTimeOutURL, $ResultURL);`
**Transaction Status Request**
This is used to check the status of transaction.
`$mpesa= new \Safaricom\Mpesa\Mpesa();`
`$trasactionStatus=$mpesa->transactionStatus($Initiator, $SecurityCredential, $CommandID, $TransactionID, $PartyA, $IdentifierType, $ResultURL, $QueueTimeOutURL, $Remarks, $Occasion);`
**B2B Payment Request**
This is used to transfer funds between two companies.
`$mpesa= new \Safaricom\Mpesa\Mpesa();`
`$b2bTransaction=$mpesa->b2b($ShortCode, $CommandID, $Amount, $Msisdn, …