PHP code example of rafaelrogerio / mpesa-dependency

1. Go to this page and download the library: Download rafaelrogerio/mpesa-dependency 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/ */

    

rafaelrogerio / mpesa-dependency example snippets




Bluteki\MpesaGateway\Mpesa;

// configuring api access credentials
Mpesa::config(
    'enter you api key',
    'enter your public key',
    'host',
    'origin',
    'port',
    'service_provider_code'
);

$transactionReference = bin2hex(random_bytes(6)); 
$thirdPartyReference = bin2hex(random_bytes(6));
$response = Mpesa::c2b(1, '258849549369', $transactionReference, $thirdPartyReference);

echo '<pre>';
print_r($response->toArray());



Bluteki\MpesaGateway\Mpesa;

// configuring api access credentials
Mpesa::config(
    'enter you api key',
    'enter your public key',
    'host',
    'origin',
    'port',
    'service_provider_code'
);

$transactionReference = bin2hex(random_bytes(6)); 
$thirdPartyReference = bin2hex(random_bytes(6));
$response = Mpesa::b2c(1, '258849549369', $transactionReference, $thirdPartyReference);

echo '<pre>';
print_r($response->toArray());