PHP code example of tumainimosha / laravel-tigopesa-push

1. Go to this page and download the library: Download tumainimosha/laravel-tigopesa-push 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/ */

    

tumainimosha / laravel-tigopesa-push example snippets


use Tumainimosha\TigopesaPush\TigopesaPush;

$customerMsisdn = '255652111222';
$amount = 1000;
$txnId = uniqid();

$tigopesaPushService = TigopesaPush::instance();
$response = $tigopesaPushService->postRequest($customerMsisdn, $amount, $txnId);

/** @var bool $success */
$success = $response['ResponseStatus'];

// EventServiceProvider.php

protected $listen = [
    ...
    \Tumainimosha\TigopesaPush\Events\TigopesaCallbackReceived::class => [
        \App\Listeners\TigopesaCallbackReceivedHandler::class,
    ],
];

// TigopesaCallbackReceivedHandler.php

public function handle(TigopesaCallbackReceived $event)
{
    $transaction = $event->transaction;
    
    // do your custom logic here
}


$tigopesaPushService = TigopesaPush::instance();

$tigopesaPushService->setUsername($account->username)
    ->setPassword($account->password)
    ->setBillerMsisdn($account->business_number)
    ->setTokenUrl(config('tigopesa-push.token_url'))
    ->setBillPayUrl(config('tigopesa-push.bill_pay_url'));
bash
php artisan vendor:publish --provider="Tumainimosha\TigopesaPush\TigopesaPushServiceProvider" --tag="config"
bash
php artisan migrate