bigenergy/laravel-freekassa-ru is a Laravel package for freekassa.ru payments for laravel 9.0+.
It currently has 0 GitHub stars and 7 downloads on Packagist (latest version 1.1.1).
Install it with composer require bigenergy/laravel-freekassa-ru.
Discover more Laravel packages by bigenergy
or browse all Laravel packages to compare alternatives.
Last updated
Accept payments via FreeKassa.ru (freekassa.ru) using this Laravel framework package (Laravel).
Require this package with composer.
composer require bigenergy/laravel-freekassa-ru dev-main
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
Weishaypt\FreeKassa\FreeKassaServiceProvider::class,
Add the FreeKassa facade to your facades array:
'FreeKassa' => Weishaypt\FreeKassa\Facades\FreeKassa::class,
Copy the package config to your local config with the publish command:
php artisan vendor:publish --provider="Weishaypt\FreeKassa\FreeKassaServiceProvider"
Once you have published the configuration files, please edit the config file in config/freekassa.php.
project_id, secret_key and secret_key_second params and paste into config/freekassa.phpconfig/freekassa.phpsearchOrder and paidOrderFreeKassa::handle method$amount = 100; // Payment`s amount
$url = FreeKassa::getPayUrl($amount, $order_id);
$redirect = FreeKassa::redirectToPayUrl($amount, $order_id);
You can add custom fields to your payment:
$rows = [
'time' => Carbon::now(),
'info' => 'Local payment'
];
$url = FreeKassa::getPayUrl($amount, $order_id, $desc, $payment_methood, $rows);
$redirect = FreeKassa::redirectToPayUrl($amount, $order_id, $desc, $payment_methood, $rows);
$desc and $payment_methood can be null.
FreeKassa::handle(Request $request)
You must define callbacks in config/freekassa.php to search the order and save the paid order.
'searchOrder' => null // FreeKassaController@searchOrder(Request $request)
'paidOrder' => null // FreeKassaController@paidOrder(Request $request, $order)
The process scheme:
freekassa.ru GET / POST http://yourproject.com/freekassa/result (with params).FreeKassaController@handlePayment runs the validation process (auto-validation request params).searchOrder will be called (see config/freekassa.php searchOrder) to search the order by the unique id.paid in your database, the method paidOrder will be called (see config/freekassa.php paidOrder).Add the route to routes/web.php:
Route::get('/freekassa/result', 'FreeKassaController@handlePayment');
Note: don't forget to save your full route url (e.g. http://example.com/freekassa/result ) for your project on freekassa.ru.
Create the following controller: /app/Http/Controllers/FreeKassaController.php:
class FreeKassaController extends Controller
{
/**
* Search the order in your database and return that order
* to paidOrder, if status of your order is 'paid'
*
* @param Request $request
* @param $order_id
* @return bool|mixed
*/
public function searchOrder(Request $request, $order_id)
{
$order = Order::where('id', $order_id)->first();
if($order) {
$order['_orderSum'] = $order->sum;
// If your field can be `paid` you can set them like string
$order['_orderStatus'] = $order['status'];
// Else your field doesn` has value like 'paid', you can change this value
$order['_orderStatus'] = ('1' == $order['status']) ? 'paid' : false;
return $order;
}
return false;
}
/**
* When paymnet is check, you can paid your order
*
* @param Request $request
* @param $order
* @return bool
*/
public function paidOrder(Request $request, $order)
{
$order->status = 'paid';
$order->save();
//
return true;
}
/**
* Start handle process from route
*
* @param Request $request
* @return mixed
*/
public function handlePayment(Request $request)
{
return FreeKassa::handle($request);
}
}
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please send me an email at [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.