| Main | Dev | Coverage | Version |
|---|---|---|---|
This package provides a small client for interacting with the Bixi API to process payments and receive responses.
- Simple and intuitive client setup.
- Comprehensive test coverage using Pest.
- PHP 8.3 or higher
- Composer
- GuzzleHTTP
- Pest (for testing)
Install the package via Composer:
composer require bixi/clientuse 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());
}You can access different parts of the response using methods like getId(), getAttributes(), and getAttribute():
$data = $response->toArray(); // Convert response to an array
$id = $response->getId(); // Transaction ID
$attributes = $response->getAttributes(); // All attributes
$amount = $response->getAttribute('amount'); // Specific attributeWhen an error occurs, a ClientException will be thrown with detailed error messages:
catch (ClientException $e) {
foreach ($e->getErrors() as $error) {
echo "Error Code: {$error['code']} - {$error['detail']}" . PHP_EOL;
}
}This package includes comprehensive test coverage using the Pest PHP testing framework. To run the tests, use the following command:
./vendor/bin/pestThis package is licensed under the MIT license. Please see the LICENSE file for more information.
Contributions are welcome! Please feel free to open issues or submit pull requests.
For the complete list of changes, please see the changelog file.
For support or inquiries, please contact the package maintainer at hi@bixi.so.