openpesa / php-pesa

Open payment integration toolkit for PHP
https://openpesa.github.io/php-pesa/
MIT License
27 stars 18 forks source link
hackertoberfest hacktoberfest mpesa mpesa-api mpesa-payments mpesa-sdk openapi pesa-sdk php tanzania

Pesa SDK for PHP


Version 2 | Work in Progress 🚧

Latest Version on Packagist Test documentation Hits codecov.io Total Downloads

The Pesa SDK for PHP makes it easy for developers to access OpenAPI in their PHP code, and build robust applications and software using services like Customber 2 Bussiness, Query etc.

Documentation

Take a look at the API docs here.

Getting Started

  1. Sign up for OpenAPI Portal – Before you begin, you need to sign up for an account and retrieve your credentials.

  2. Minimum requirements – To run the SDK, your system will need to meet the minimum requirements, including having PHP >= 7.1.

  3. Install the SDK – Using [Composer] is the recommended way to install the Pesa SDK for PHP. The SDK is available via [Packagist] under the openpesa/php-pesa package. If Composer is installed globally on your system, you can run the following in the base directory of your project to add the SDK as a dependency:

    composer require openpesa/pesa

    Please see the Installation section of the User Guide for more detailed information about installing the SDK through Composer and other means.

  4. Using the SDK – The best way to become familiar with how to use the SDK is to read the User Guide.

Usage

Quick Examples


require 'vendor/autoload.php';

use Openpesa\SDK\Pesa;

// Intiate with credentials
$pesa = new Pesa([
            'api_key' => 'YOUR_API_KEY',
            'public_key' => 'PUBLIC_KEY',
            'client_options' => [],
        ],'sandbox');

// Setup the transaction
$data = [
    'input_Amount' => '10000',
    'input_Country' => 'TZN',
    'input_Currency' => 'TZS',
    'input_CustomerMSISDN' => '255766303775',
    'input_ServiceProviderCode' => '000000',
    'input_ThirdPartyConversationID' => 'rerekf',
    'input_TransactionReference' => rand(),
    'input_PurchasedItemsDesc' => 'Test Two Item'
];

// Execute
$result = $pesa->c2b($data);

// Print results
var_dump($result);

For more example check pesa-demo-example.

Testing

composer test

Opening Issues

If you have a feature requrest or you encounter a bug, please file an issue on our issue tracker on GitHub.

Resources

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please review our CONTRIBUTING for details.

Security

If you discover any security related issues, please email alphaolomi@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.