PHP code example of bixi / client

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

    

bixi / client example snippets


use Bixi\Client\Bixi;

$apiToken = 'Your-API-Token';
$bixi = new Bixi($apiToken);

try {
    $response = $bixi->pay([
        'memo' => 'credit',
        'accountNumber' => '+252600000000',
        'accountType' => 'mmt',
        'receiptId' => '123456',
        'amount' => 1.00,
        'description' => 'Payment for invoice No. 123456',
    ]);

    echo "Transaction Successful! Transaction ID: " . $response->getId() . PHP_EOL;
    print_r($response->toArray());
} catch (ClientException $e) {
    echo "Error: {$e->getMessage()}" . PHP_EOL;
    print_r($e->getErrors());
}

$id = $response->getId(); // Transaction ID
$attributes = $response->getAttributes(); // All attributes
$amount = $response->getAttribute('amount'); // Specific attribute

catch (ClientException $e) {
    foreach ($e->getErrors() as $error) {
        echo "Error Code: {$error['code']} - {$error['detail']}" . PHP_EOL;
    }
}