Download the PHP package abdulmueid/mpesa without Composer
On this page you can find all versions of the php package abdulmueid/mpesa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mpesa
Welcome to M-Pesa PHP API
This project aims to provide an easy-to-use and up-to-date PHP wrapper for the M-Pesa Mozambique API.
Target version of M-Pesa API: v1x
Installation
Install using composer:
Usage
-
Load the configuration from file.
See sample configuration file in examples folder.
-
Create a Transaction using the configuration.
-
Execute API operations and pass appropriate parameters.
-
Initiate a C2B payment collection.
-
Initiate a B2C payment.
-
Initiate a B2B payment.
-
Initiate a reversal.
- Query a transaction.
-
-
Check Response
All transactions return the
TransactionResponse
object. The object has the following public methods:-
getCode()
- Returns the response code i.e.INS-0
-
getDescription()
- Returns the description. -
getTransactionID()
- Returns the transaction ID. -
getConversationID()
- Returns the conversation ID. -
getTransactionStatus()
- Returns the transaction status. Only populated when calling thequery()
transaction. getResponse()
- Returns the full response JSON object as received from M-Pesa servers. Good for debugging any issues or undocumented behaviors of the M-Pesa API.
-
In a typical scenario, code to check for successful transactions should be as follows:
Testing
This repo provides Unit Tests to validate the objects and their interaction with M-Pesa.
To run tests,
- Open the
phpunit.xml
file and add the require credentials/parameters as supplied by M-Pesa. - Run
phpunit
- Check the handset for USSD prompts to approve test transactions.
All tests use 1MT as the test amount.
License
This library is release under the MIT License. See LICENSE file for details.
All versions of mpesa with dependencies
ext-curl Version *
ext-json Version *
ext-openssl Version *