allanvb / laravel-walletone
Laravel integration of walletone.com payment gateway
Requires
- php: >=7.0
- illuminate/support: ^5.5 || ^6 || ^7
This package is auto-updated.
Last update: 2025-03-12 06:52:41 UTC
README
Laravel package for integrating WalletOne payment gateway into laravel app
Package that integrates WalletOne API into your Laravel app.
Install
Via Composer
$ composer require allanvb/laravel-walletone
If you're using Laravel 5.5 or above, the package will automatically register provider and facade.
Laravel 5.4 and below
Add Allanvb\LaravelWalletOne\Providers\WalletoneServiceProvider
to the providers
array in your config/app.php
:
'providers' => [ // Other service providers... Allanvb\LaravelWalletOne\Providers\WalletoneServiceProvider::class, ],
Add an alias in your config/app.php
:
'aliases' => [ ... 'WalletOne' => Allanvb\LaravelWalletOne\Facades\WalletOne::class, ],
Or you can use
the facade class when needed:
use Allanvb\LaravelWalletOne\Facades\WalletOne;
Configuration
You can use php artisan vendor:publish
to copy the configuration file to your app's config directory:
$ php artisan vendor:publish --provider="Allanvb\LaravelWalletOne\Providers\WalletoneServiceProvider" --tag="config"
Then update config/wallet-one.php
with your credentials. Also you can update your .env
file with the following:
WALLETONE_MERCHANT=merchant_id WALLETONE_SECRET=secret_key WALLETONE_SIGNATURE=signature_method WALLETONE_CURRENCY=currency WALLETONE_SUCCESS=success_url WALLETONE_FAIL=fail_url
Usage:
To use the WalletOne Library you can access the facade, or request the instance from the service container:
WalletOne::make($orderID, $amount, $description, $options);
Or
app('walletone')->make($orderID, $amount, $description, $options);
Parameters:
$orderID
- (string) ID of user order on your e-commerce (required).$amount
- (float) Amount of money the user has to pay (required).$description
- (string) Payment description (required).$options
- (array) Any other options you want to save on WalletOne service, or get back in response.
In order to create payment form for user, you have to get all post params by using getParams()
method.
$params = WalletOne::getParams();
Then send this params to your view and create form.
As form action use WalletOne::API_URL
.
In order to get response from WalletOne service, you have to define a post
route inside your web.php
.
This route should use \Allanvb\LaravelWalletOne\Http\Middleware\WalletonePay::class
middleware.
You can add this middleware to your Kernel.php
inside App\Http
folder.
protected $routeMiddleware = [ // Other service providers... 'walletone-payment' => \Allanvb\LaravelWalletOne\Http\Middleware\WalletonePay::class ];
Then you can use it as following:
Route::post('/payment-webhook', 'YourController')->middleware('walletone-payment');
NOTE:
- Your controller should return
WalletOne::response()
method ! - Don't forget to add your route into
$except
param ofVerifyCsrfToken
middleware !
Each request to your route will generate a SuccessPayment
or FailedPayment
event,
so all you have to do is to define a event listener for each of them.
Security
If you discover any security related issues, please email alan.vb@mail.ru instead of using the issue tracker.
Credits
This package is actually a continuity of pdazcom/laravel-walletone whose author is Konstantin A.
License
The MIT License (MIT). Please see License File for more information.