Download the PHP package mesasdk/php-mpesa without Composer

On this page you can find all versions of the php package mesasdk/php-mpesa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-mpesa

PHP M-Pesa SDK

A comprehensive PHP SDK for integrating with the M-Pesa API in Ethiopia. This SDK provides a simple and elegant way to interact with M-Pesa's payment services, featuring a modern fluent interface design and robust error handling.

Features

Requirements

Installation

Install the package via composer:

Quick Start

Configuration

Environment Variables

We recommend using environment variables for sensitive configuration:

Available Configuration Options

Option Description Required Notes
baseUrl API base URL Yes Use sandbox URL for testing
environment 'sandbox' or 'production' Yes Start with sandbox
consumerKey Your M-Pesa API consumer key Yes Keep secure
consumerSecret Your M-Pesa API consumer secret Yes Keep secure
shortCode Your M-Pesa shortcode Yes -
passKey Your M-Pesa passkey For STK Push -
verifySSL Whether to verify SSL certificates Optional Always true in production

Features Documentation

STK Push

B2C Payment

C2B Simulation

Account Balance Query

C2B Validation and Confirmation

First, register your validation and confirmation URLs:

Validation Endpoint

Confirmation Endpoint

Response Models

The SDK provides type-safe response models for all API responses:

Security Best Practices

  1. Environment Variables:

    • Store all sensitive credentials in environment variables
    • Never commit credentials to version control
    • Use .env files for local development
  2. SSL/TLS:

    • Always use HTTPS for callback URLs
    • Set verifySSL to true in production
    • Keep SSL certificates up to date
  3. Error Handling:

    • Implement comprehensive error logging
    • Never expose sensitive error details to users
    • Monitor failed transactions
  4. Data Validation:
    • Validate all incoming callback data
    • Implement request signing where possible
    • Use type-safe response models

Handling Callbacks

Create a callback handler for your endpoint:

Error Handling

The SDK provides comprehensive error handling through custom exceptions:

Logging

The SDK includes comprehensive logging capabilities:

Log File Example

json { "OriginatorConversationID": "2c22-4733-b801-a1eaa3f9763c", "ConversationID": "AG_20240211_70101d5c7e1c4fbf514f", "ResponseCode": "0", "ResponseDescription": "Accept the service request successfully." } json { "Result": { "ResultType": 0, "ResultCode": 0, "ResultDesc": "The service request is processed successfully.", "OriginatorConversationID": "cd88-49b1-80c9-172990525931", "ConversationID": "AG_20230116_7010211995599455bcb1", "TransactionID": "RAG0000000", "ResultParameters": { "ResultParameter": [ { "Key": "AccountBalance", "Value": "Working Account|ETB|0.00|0.00|0.00|0.00&Utility Account|ETB|101090.00|101090.00|0.00|0.00" } ] } } } `

Testing

Run the test suite:

`

The SDK includes comprehensive tests:

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
  3. Write your changes
  4. Write tests for your changes
  5. Run the tests
  6. Submit a pull request

Please read our Contributing Guide for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support and questions:

Changelog

See CHANGELOG.md for release history.

Response Models

The SDK provides type-safe response models for all API responses. These models make it easier to work with API responses and provide better IDE support.


All versions of php-mpesa with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-curl Version *
ext-json Version *
guzzlehttp/guzzle Version ^7.0
vlucas/phpdotenv Version ^5.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mesasdk/php-mpesa contains the following files

Loading the files please wait ....