bnzo / laravel-fintecture
An opinionated Fintecture wrapper for Laravel apps.
Fund package maintenance!
bnzo
Requires
- php: ^8.3
- fintecture/fintecture-sdk-php: ^2.6
- illuminate/contracts: ^10.0||^11.0||^12.0
- spatie/laravel-data: ^4.17
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- guzzlehttp/psr7: ^2.7
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- php-http/mock-client: ^1.6
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
- spatie/laravel-ray: ^1.35
README
Laravel Fintecture
An opinionated Fintecture wrapper for Laravel apps.
⚠️ This package is under developement, do not use it in production. ⚠️
Installation
You can install the package via composer:
composer require bnzo/laravel-fintecture
You can publish the config file with:
php artisan vendor:publish --tag="laravel-fintecture-config"
This is the contents of the published config file:
return [ 'app_id' => env('FINTECTURE_APP_ID'), 'app_secret' => env('FINTECTURE_APP_SECRET'), 'base_url' => env('FINTECTURE_BASE_URL'), 'environement' => env('FINTECTURE_ENVIRONMENT', 'sandbox'), // sandbox or production 'private_key' => env('FINTECTURE_PRIVATE_KEY') // base64 encoded private key ];
Usage
Create a RequestToPay URL
This is a simple call using a basic PaymentRequestData object.
Please refer to the next section if you need more payment parameters such as currency, expiration time, and method ( link, sms, email ).
use Bnzo\Fintecture\Data\PaymentRequestData; use Bnzo\Fintecture\Facades\Fintecture; $paymentData = new PaymentData( new AttributesData( amount: '272.00', communication: 'test' ), new CustomerData( email: 'julien.lefebre@my-business-sarl.com', name: 'Julien Lefebvre' ) ); $sessionData = Fintecture::generate( paymentData: $paymentData ); $sessionData->sessionId; //d2e30e2c0b9e4ce5b26f59dc386b21b2 $sessionData->url; //https://fintecture.com/v2/85b0a547-5c18-4a16-b93b-2a4f5f03127d
Create a PaymentRequestData
Not all data fields are mandatory, please refer to each Data classes to see what you can use and what are default values.
use Bnzo\Fintecture\Data\PaymentData; $paymentRequestData = new PaymentData( new AttributesData( amount: '272.00', communication: 'Order #1', currency: Currency::EUR, // default Currency::EUR language: 'en' //default App::getLocale() state: "1" //default null ), new CustomerData( email: 'julien.lefebre@my-business-sarl.com', name: 'Julien Lefebvre', address: new AddressData( street: '1 rue de la paix', zip: '75000', city: 'Paris', country: 'FR', ), ), new SettingsData( due_date: 86400, // default 84000 expiry: 86400, // default 84000 method: Method::Link // default Link permanent: false, // default false redirectUri: "https://myapp.test/finctecture/callback" //default null scheduled_expiration_policy: ScheduledExpirationPolicy::Immediate, // default Immediate ), );
Webhooks
Webhooks can be receive at this url /finctecure/webhook
- First, make sure to configure the webhook endpoint in your fintecture app:
- Disable CSRF tokens for this route in you bootstrap app.php file:
//bootstrap/app.php ... ->withMiddleware(function (Middleware $middleware) { $middleware->validateCsrfTokens(except: [ '/fintecture/webhook', ]); }) ...
- You can create a listener like so:
php artisan make:listener -e \\Bnzo\\Fintecture\\Events\\PayementCreated
// app/Listeners/ValidateBankTransfer.php namespace App\Listeners; use Bnzo\Fintecture\Events\PaymentCreated; class ValidateBankTransfer { public function handle(PaymentCreated $event): void { return "payment created for session {$event->sessionId}"; } }
For now, you can create listeners for the following events, but more can be added in the route file web.php
PaymentCreated
and PaymentUnsuccessful
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.