bixi / client
A PHP client for Bixi payment processor.
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.9
Requires (Dev)
- laravel/pint: ^1.18
- mockery/mockery: ^1.6
- pestphp/pest: ^3.5
- phpstan/phpstan: ^1.12
- rector/rector: ^1.2
- spatie/invade: ^2.1
- symfony/var-dumper: ^7.1
README
Main | Dev | Coverage |
---|---|---|
This package provides a small client for interacting with the Bixi API to process payments and receive responses.
Features
- Simple and intuitive client setup.
- Comprehensive test coverage using Pest.
Requirements
- PHP 8.3 or higher
- Composer
- GuzzleHTTP
- Pest (for testing)
Installation
Install the package via Composer:
composer require bixi/client
Getting Started
Step 1: Initialize the Client
use Bixi\Client\Bixi; $apiToken = 'Your-API-Token'; $bixi = new Bixi($apiToken);
Step 2: Making a Payment Request
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()); }
Step 3: Handling Responses
You can access different parts of the response using methods like getId()
, getAttributes()
, and getAttribute()
:
$id = $response->getId(); // Transaction ID $attributes = $response->getAttributes(); // All attributes $amount = $response->getAttribute('amount'); // Specific attribute
Step 4: Handling Exceptions
When 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; } }
Testing
This package includes comprehensive test coverage using the Pest PHP testing framework. To run the tests, use the following command:
./vendor/bin/pest
License
This package is licensed under the MIT license. Please see the LICENSE
file for more information.
Contributing
Contributions are welcome! Please feel free to open issues or submit pull requests.
Changelog
For the complete list of changes, please see the changelog file.
Contact
For support or inquiries, please contact the package maintainer at hi@bixi.so.