emagombe/mpesa-api

There is no license information available for the latest version (v4.0.1) of this package.

API em PHP para M-PESA (Moambique)

Installs: 369

Dependents: 0

Suggesters: 0

Security: 0

Stars: 25

Watchers: 1

Forks: 9

Open Issues: 0

pkg:composer/emagombe/mpesa-api

v4.0.1 2025-11-22 16:23 UTC

This package is auto-updated.

Last update: 2025-12-22 16:39:58 UTC


README

License: GPL v3

English | Português

PHP API for M-PESA integration (Mozambique).

Installation

composer require emagombe/mpesa-api

Configuration

Get your credentials at https://developer.mpesa.vm.co.mz/

use emagombe\Mpesa;

$mpesa = Mpesa::init(
    $api_key,        // API Key from portal
    $public_key,     // Public Key from portal
    "development"    // "development" or "production"
);

Operations

C2B (Client → Business)

$response = $mpesa->c2b([
    "value" => 10,
    "client_number" => "258840000000",
    "agent_id" => 171717,
    "transaction_reference" => 1234567,
    "third_party_reference" => 33333
]);

print_r($response);

B2C (Business → Client)

$response = $mpesa->b2c([
    "value" => 10,
    "client_number" => "258840000000",
    "agent_id" => 171717,
    "transaction_reference" => 1234567,
    "third_party_reference" => 33333
]);

print_r($response);

B2B (Business → Business)

$response = $mpesa->b2b([
    "value" => 10,
    "agent_id" => 171717,
    "agent_receiver_id" => 979797,
    "transaction_reference" => 1234567,
    "third_party_reference" => 33333
]);

print_r($response);

Reversal

$response = $mpesa->reversal([
    "value" => 10,
    "security_credential" => "",
    "indicator_identifier" => "",
    "transaction_id" => "",
    "agent_id" => 171717,
    "third_party_reference" => 33333
]);

print_r($response);

Query Status

$response = $mpesa->status([
    "transaction_id" => "",
    "agent_id" => 171717,
    "third_party_reference" => 33333
]);

print_r($response);

Customer Name

Note: Requires production credentials.

$response = $mpesa->customer_name([
    "client_number" => "258840000000",
    "agent_id" => 171717,
    "third_party_reference" => 33333
]);

print_r($response);

Success Response

{
    "output_ResponseCode": "INS-0",
    "output_ResponseDesc": "Request processed successfully",
    "output_TransactionID": "...",
    "output_ConversationID": "...",
    "output_ThirdPartyReference": "33333"
}

License

GPL v3