Download the PHP package codexoft/mpesa-sdk without Composer

On this page you can find all versions of the php package codexoft/mpesa-sdk. 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 mpesa-sdk

M-Pesa PHP SDK

A comprehensive PHP SDK for integrating with Safaricom's M-Pesa payment services. This package provides a simple and elegant way to interact with various M-Pesa APIs, including STK Push, B2B, B2C, C2B, QR Code generation, tax remittance, and more.

Table of Contents

Features

Installation

Install the package via Composer:

Configuration

Basic Configuration

Using Environment Variables (Recommended)

Create a .env file:

Load configuration from environment:

Basic Usage

Initialize the SDK:

Available Methods

STK Push

Initiate an STK push request (M-Pesa Express):

STK Push Query

Check the status of an STK push request:

QR Code Generation

Generate a dynamic QR code for payments:

C2B URL Registration

Register URLs for C2B payment notifications:

B2C Payments

Send money to customers (Business to Customer):

B2B Payments

Make payments to other businesses:

B2B Express Checkout

Initiate a B2B Express Checkout (USSD Push):

Transaction Status

Query the status of any transaction:

Account Balance

Check your business account balance:

Transaction Reversal

Reverse a completed transaction:

Tax Remittance

Process tax payments to KRA:

Standing Orders (M-Pesa Ratiba)

Create recurring payment orders:

Frequency options:

Error Handling

The SDK implements comprehensive error handling:

Webhook Integration

Example webhook handler for callbacks:

Advanced Usage

Certificate Management

The SDK automatically handles certificates for different environments:

Phone Number Formatting

The SDK automatically formats phone numbers to the required format:

Access Token Management

Access tokens are automatically generated and managed by the SDK. You don't need to handle token generation or refreshing manually.

Requirements

Security Best Practices

  1. Environment Configuration

    • Use environment variables for sensitive data
    • Never commit credentials to version control
    • Use different credentials for sandbox and production
  2. SSL/TLS

    • Always use HTTPS for callbacks
    • Keep certificates up to date
    • Validate SSL certificates
  3. Error Handling

    • Log errors securely
    • Don't expose sensitive information in error messages
    • Implement proper error recovery
  4. Data Validation

    • Validate all input data
    • Sanitize callback data
    • Implement request signing if needed
  5. Access Control
    • Implement IP whitelisting for callbacks
    • Use strong passwords
    • Rotate credentials regularly

Testing

Sandbox Testing

Production Testing

Test Phone Numbers

For sandbox testing, use these test phone numbers:

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. Create a new Pull Request

License

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

Support

Community Support

Credits

Changelog

[1.0.0/1] - 2024-12-30

[1.0.2] - 2024-12-31

[Unreleased]


All versions of mpesa-sdk with dependencies

PHP Build Version
Package Version
No informations.
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 codexoft/mpesa-sdk contains the following files

Loading the files please wait ....