PHP code example of djunehor / eyowo-php

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

    

djunehor / eyowo-php example snippets


use Djunehor\Eyowo\Api;

$production is an optional boolean parameter to specify if to use production URL or sandbox.
// Default is false
$eyowo = new Api($appKey, $production); //if appKey is not passed, package uses value in .env

// phone should be in the format 2348020000000
$eyowo->validate($phone);

// sends SMS to user phone
$eyowo->initiateAuthorization($phone);

// $code is the 6-digit number send to user phone
$eyowo->generateToken($phone, $code);
[
'success' => true,
'data' => [
'accessToken' => kjaskajs7a8s6as7a7s68a,
'refreshToken' => askhas7a7s6a7yajgsa67u
]

$walletToken = $eyowo->getAccessToken();
$refreshToken = $eyowo->getRefreshToken();

$eyowo->refreshToken($refreshToken);

$output = $eyowo->banks();
[
'success' => true,
'data' => [
    'banks' => [
            [
                        "bankCode" => "090270",
                        "bankName" => "AB MICROFINANCE BANK"
                    ]
...
]
    ]
]

$banks = $eyowo->getBanks();

            [
                        "bankCode" => "090270",
                        "bankName" => "AB MICROFINANCE BANK"
                    ]
...
]
 


//amount should be in kobo
$eyowo->transferToPhone($walletToken, $amount, $phone);

//amount should be in kobo
$eyowo->transferToPhone($walletToken, $amount, $accountName, $accountNumber, $bankCode);

$eyowo->balance($walletToken); returns raw API response
$balance = $eyowo->getBalance(); // returns int|float

// provider has to be one of ['mtn', 'glo', 'etisalat', 'airtel'];
$eyowo->vtu($walletToken, $amount, $phone, $provider);
 bash
    $ composer