eminisolomon / safehaven
A concise Laravel package for easy integration with Safe Haven MFB's API, offering simplified access to banking features
Requires
- php: ^8.2
- firebase/php-jwt: ^6.11
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- laravel/pint: ^1.24
- mockery/mockery: ^1.6
- orchestra/testbench: ^10.2
- pestphp/pest: ^3.8
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/phpstan: ^2.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Safe Haven MFB integration for Laravel, other PHP frameworks, and vanilla PHP.
Installation
You can install the package via composer:
composer require eminisolomon/safehaven
Publishing the config file
php artisan vendor:publish --provider="Eminisolomon\SafeHaven\SafeHavenServiceProvider" --tag="config"
Vanilla PHP and other frameworks
The framework-neutral client only requires Composer and environment variables:
composer require eminisolomon/safehaven
use Eminisolomon\SafeHaven\SafeHavenClient; $safeHaven = SafeHavenClient::fromEnvironment(); $accounts = $safeHaven->account()->getAccounts();
Set SAFE_HAVEN_CLIENT_ID, SAFE_HAVEN_COMPANY_DOMAIN, and SAFE_HAVEN_PRIVATE_KEY. Use SAFE_HAVEN_ENVIRONMENT=production for live requests.
Laravel usage
use Eminisolomon\SafeHaven\SafeHaven; //Create Account $accountType = "Savings"; $accountName = "Solomon Olatunji"; SafeHaven::account()->createAccount($accountType, $accountName, [ "verified" => true, "notes" => "" ]);
For more information, please refer to the package documentation.
Automatic API Token Refresh
For seamless and uninterrupted access to API endpoints, it's recommended to integrate an automated mechanism in your Laravel application. This mechanism will be responsible for generating client assertions and subsequently exchanging them for API tokens. By doing so, the API token gets refreshed automatically before it reaches its expiration, ensuring your API interactions remain consistent and uninterrupted. To implement this, simply add the provided script to your Laravel application's cron job configuration
Step 1: Import ApiRequestor from Eminisolomon\SafeHaven.
use Eminisolomon\SafeHaven\ApiRequestor;
Step 2: Update schedule in app/Console/Kernel.php to refresh the token every 30 minutes.
protected function schedule(Schedule $schedule) { $schedule->call(function () { (new ApiRequestor())->token(); })->everyThirtyMinutes(); }
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email iamsolomonolatunji@gmail.com instead of using the issue tracker.
Credits
- Solomon Olatunji
- Contributions are welcome—please see CONTRIBUTING.
License
The MIT License (MIT). Please see License File for more information.