PHP code example of delfimcelestino / mpesa-connect-php

1. Go to this page and download the library: Download delfimcelestino/mpesa-connect-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

delfimcelestino / mpesa-connect-php example snippets




pesaConnectPhp\Mpesa;

// Substitua pelos valores reais
$mpesa = new Mpesa('your-public-key', 'your-api-key', 'your-service-provider-code', 'sandbox');



$result = $mpesa->c2b('TX123456', '258855555555', 10.00, 'REF123');
print_r($result);



$result = $mpesa->b2c('TX123456', '258855555555', 10.00, 'REF123');
print_r($result);



$result = $mpesa->transactionReversal(
    'TX123456',
    'SEC123',
    'INIT123',
    'REF123',
    'SERVICE123',
    10.00
);
print_r($result);



$result = $mpesa->status('REF123', 'QUERY123');
print_r($result);

$mpesa = new Mpesa('your-public-key', 'your-api-key', 'your-service-provider-code', 'sandbox');
bash
composer