dinhdjj / laravel-thesieure
Provide a helper interface to communicate with thesieure easily
Requires
- php: ^8.1
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- guzzlehttp/guzzle: ^7.4
- guzzlehttp/promises: ^1.5
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2023-11-09 18:26:56 UTC
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Installation
You can install the package via composer:
composer require dinhdjj/laravel-thesieure
You can publish the config file with:
php artisan vendor:publish --tag="thesieure-config"
This is the contents of the published config file:
// config for dinhdjj/laravel-thesieure return [ 'domain' => env('THESIEURE_DOMAIN', 'thesieure.com'), 'partner_id' => env('THESIEURE_PARTNER_ID'), 'partner_key' => env('THESIEURE_PARTNER_KEY'), /** * The callback will be call when thesieure callback to server. */ 'callback' => [ 'route' => [ 'name' => 'thesieure.callback', 'uri' => 'api/thesieure/callback', 'middleware' => [ 'api', ], 'method' => 'post', ], ], /** * Used when fetch card types from thesieure server. */ 'fetch_card_types' => [ 'cache' => [ 'enabled' => true, 'key' => 'thesieure.card_types', 'ttl' => 60 * 5, // 5 minutes, 'store' => null, // used default store ], ], ];
Usage
Firstly, you should register logic to handle the callback from thesieure.
// app/Providers/AppServiceProvider.php public function boot() { \Thesieure::onCallback(function(Dinhdjj\Thesieure\Types\ApprovedCard $card){ // Each property of $card equivalent to thesieure's attributes read more on `thesieure` // Besides, $card also have some helper methods if($card->isApproving()){ // Do something } if($card->isSuccess()){ $receivedValue = $card->getReceivedValue(); $realFaceValue = $card->getRealFaceValue(); // Do something } if($card->isError()){ // Do something } }); }
Next, you should register the callback in thesieure. By default, the callback route ispost
:/api/thesieure/callback
.
Finally, when you need to send a card to thesieure
approve:
\Thesieure::approveCard('VIETTEL', 20000, '20002346728333', '239847923483242432', 'anything'); \Thesieure::updateApprovedCard('VIETTEL', 20000, '20002346728333', '239847923483242432', 'anything');
When thesieure
response the result, error or when you call approveCard
, updateApprovedCard
method, closure you transfer to \Thesieure::onCallback
will be invoked. All things you need to do is register logic in \Thesieure::onCallback
.
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.