Airtel SDK for PHP Applications

v1.0.0 2021-08-14 13:50 UTC

This package is auto-updated.

Last update: 2024-09-14 20:45:53 UTC


README

Airtel Africa Money API PHP SDK

安装

composer require stephencoduor\airtel

集合API

实例化

use Stephencoduor\Airtel\Collection;
$collectAPI = new Collection(
    array(
        'env'           => 'live',
        'client_id'     => 'YOUR_CLIENT_ID',
        'client_secret' => 'YOUR_CLIENT_SECRET',
        'public_key'    => 'YOUR_PUBLIC_KEY',
        'country'       => 'Transaction Country Code e.g KE',
        'currency'      => 'Transaction Currency Code e.g KES'
    )
);

STK/USSD推送

$collectAPI->authorize()->ussdPush($phone, $amount);

注意:不要在电话号码中发送国家代码。

如果您有缓存机制,则可以在每次创建新令牌时传递一个令牌到授权方法。您还可以传递一个回调函数作为第二个参数来更新您的令牌

$token = ''; // Get your token from database, redis or whichever cache you use.
$collectAPI->authorize($token, function($newToken) {
    print($newToken);
    // Save/update $newToken in your database
})->ussdPush($phone, $amount);

发放API

use Stephencoduor\Airtel\Disbursement;

$disburseAPI = new Disbursement(
    array(
        'env'           => 'live',
        'client_id'     => 'YOUR_CLIENT_ID',
        'client_secret' => 'YOUR_CLIENT_SECRET',
        'public_key'    => 'YOUR_PUBLIC_KEY',
        'country'       => 'Transaction Country Code e.g KE',
        'currency'      => 'Transaction Currency Code e.g KES'
    )
);

然后发送钱款

$disburseAPI->authorize()->send($phone, $amount);