{"id":13696933,"url":"https://github.com/abdulmueid/mpesa-php-api","last_synced_at":"2026-01-16T00:40:52.390Z","repository":{"id":31018339,"uuid":"126646310","full_name":"abdulmueid/mpesa-php-api","owner":"abdulmueid","description":"PHP library for M-Pesa API (Mozambique)","archived":false,"fork":false,"pushed_at":"2023-07-10T21:52:36.000Z","size":858,"stargazers_count":45,"open_issues_count":7,"forks_count":27,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-24T07:46:21.423Z","etag":null,"topics":["api","library","mpesa","php","php-library","php7"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abdulmueid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-03-24T22:44:55.000Z","updated_at":"2025-04-07T12:09:40.000Z","dependencies_parsed_at":"2023-10-20T16:15:17.193Z","dependency_job_id":null,"html_url":"https://github.com/abdulmueid/mpesa-php-api","commit_stats":{"total_commits":20,"total_committers":3,"mean_commits":6.666666666666667,"dds":"0.30000000000000004","last_synced_commit":"de6b7bfb3a37465684385899edd3bb0c8cfa5e74"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdulmueid%2Fmpesa-php-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdulmueid%2Fmpesa-php-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdulmueid%2Fmpesa-php-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abdulmueid%2Fmpesa-php-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abdulmueid","download_url":"https://codeload.github.com/abdulmueid/mpesa-php-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252226892,"owners_count":21714891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","library","mpesa","php","php-library","php7"],"created_at":"2024-08-02T18:00:50.213Z","updated_at":"2026-01-16T00:40:52.376Z","avatar_url":"https://github.com/abdulmueid.png","language":"PHP","funding_links":[],"categories":["Bibliotecas"],"sub_categories":[],"readme":"# Welcome to M-Pesa PHP API\n\nThis project aims to provide an easy-to-use and up-to-date PHP wrapper for the M-Pesa Mozambique API.\n\nTarget version of M-Pesa API: **v1x**\n\n## Installation\n\nInstall using composer:\n```\ncomposer require abdulmueid/mpesa\n```\n\n## Usage\n\n1. Load the configuration from file.\n    ```php\n    $config = \\abdulmueid\\mpesa\\Config::loadFromFile('/path/to/config.php');\n    ```\n    See sample configuration file in examples folder.\n\n2. Create a Transaction using the configuration.\n    ```php\n    $transaction = new \\abdulmueid\\mpesa\\Transaction($config);\n    ```\n    \n3. Execute API operations and pass appropriate parameters. \n\n    1. Initiate a C2B payment collection.\n       ```php\n       $c2b = $transaction-\u003ec2b(\n           float $amount,\n           string $msisdn,\n           string $reference,\n           string $third_party_reference\n       );\n        ```\n        \n    2. Initiate a B2C payment.\n       ```php\n       $b2c = $transaction-\u003eb2c(\n           float $amount,\n           string $msisdn,\n           string $reference,\n           string $third_party_reference\n       );\n       ```\n        \n    3. Initiate a B2B payment.\n       ```php\n       $b2b = $transaction-\u003eb2b(\n            float $amount,\n            string $receiver_party_code,\n            string $reference,\n            string $third_party_reference\n       );\n       ```\n    \n    2. Initiate a reversal.\n       ```php\n       $reversal = $transaction-\u003ereversal(\n           float $amount,  \n           string $transaction_id,\n           string $third_party_reference\n       );\n       ```\n    \n    3. Query a transaction.\n       ```php\n       $query = $transaction-\u003equery(\n           string $query_reference,\n           string $third_party_reference\n       );\n       ```\n4. Check Response\n\n    All transactions return the `TransactionResponse` object. The object has the following public methods:\n\n    1. `getCode()` - Returns the response code i.e. `INS-0`\n\n    2. `getDescription()` - Returns the description.\n\n    3. `getTransactionID()` - Returns the transaction ID.\n\n    4. `getConversationID()` - Returns the conversation ID.\n\n    5. `getTransactionStatus()` - Returns the transaction status. Only populated when calling the `query()` transaction.\n\n    6. `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.\n\nIn a typical scenario, code to check for successful transactions should be as follows:\n\n```php\n$c2b = $transaction-\u003ec2b(...);\n\nif($c2b-\u003egetCode() === 'INS-0') {\n    // Transaction Successful, Do something here\n}\n```\n\n## Testing\nThis repo provides Unit Tests to validate the objects and their interaction with M-Pesa.\n\nTo run tests, \n1. Open the `phpunit.xml` file and add the require credentials/parameters as supplied by M-Pesa.\n2. Run `phpunit` \n3. Check the handset for USSD prompts to approve test transactions.\n\nAll tests use 1MT as the test amount.\n\n\n## License\n\nThis library is release under the MIT License. See LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdulmueid%2Fmpesa-php-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabdulmueid%2Fmpesa-php-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdulmueid%2Fmpesa-php-api/lists"}