Package Data | |
---|---|
Maintainer Username: | actionm |
Maintainer Contact: | actionmanager@gmail.com (actionm) |
Package Create Date: | 2017-02-12 |
Package Last Update: | 2018-01-22 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-13 15:00:17 |
Package Statistics | |
---|---|
Total Downloads: | 650 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 7 |
Total Open Issues: | 2 |
Accept payments via WebMoney Merchant (merchant.webmoney.ru) using this Laravel framework package (Laravel).
You can accept payments with WebMoney Merchant via WebMoney, credit cards etc.
You can install the package through Composer:
composer require actionm/laravel-webmoney-merchant
Add the service provider to the providers
array in config/app.php
:
'providers' => [
ActionM\WebMoneyMerchant\WebMoneyMerchantServiceProvider::class,
]
Add the WebMoneyMerchant
facade to your facades array:
'WebMoneyMerchant' => ActionM\WebMoneyMerchant\Facades\WebMoneyMerchant::class,
Publish the configuration file and views
php artisan vendor:publish --provider="ActionM\WebMoneyMerchant\WebMoneyMerchantServiceProvider"
Publish only the configuration file
php artisan vendor:publish --provider="ActionM\WebMoneyMerchant\WebMoneyMerchantServiceProvider" --tag=config
Publish only the views
php artisan vendor:publish --provider="ActionM\WebMoneyMerchant\WebMoneyMerchantServiceProvider" --tag=views
Once you have published the configuration files, please edit the config file in config/webmoney-merchant.php
.
Create an account on merchant.webmoney.ru
Set your project settings:
SHA256
;ON
;ON
;After the configuration has been published, edit config/webmoney-merchant.php
Copy the Secret Key X20
and Secret Key
params and paste into config/webmoney-merchant.php
Set the callback static function for searchOrderFilter
and paidOrderFilter
Set notification channels (email and/or Slack) and Slack webhook_url
$payment_amount = Order amount
$payment_no = Unique order number in your project, numbers only from 1 to 2147483647
$item_name = Name of your order item, only latin characters.
WebMoneyMerchant::generatePaymentForm($payment_amount, $payment_no, $item_name);
Customize the HTML payment form in the published view:
app/resources/views/vendor/webmoney-merchant/payment_form.blade.php
WebMoneyMerchant::payOrderFromGate(Request $request)
You must define callbacks in config/webmoney-merchant.php
to search the order and save the paid order.
'searchOrderFilter' => null // ExampleController:searchOrderFilter($request)
'paidOrderFilter' => null // ExampleController::paidOrderFilter($request,$order)
The process scheme:
merchant.webmoney.ru
GET
http://yourproject.com/webmoney/result
to check if your website is available.merchant.webmoney.ru
POST
http://yourproject.com/webmoney/result
(with params).ExampleController@payOrderFromGate
runs the validation process (auto-validation request params).searchOrderFilter
will be called (see config/webmoney-merchant.php
searchOrderFilter
) to search the order by the unique id.paid
in your database, the static function paidOrderFilter
will be called (see config/webmoney-merchant.php
paidOrderFilter
).Add the route to routes/web.php
:
Route::post('/webmoney/result', 'ExampleController@payOrderFromGate');
Route::get('/webmoney/result', 'ExampleController@payOrderFromGateOK');
Note: don't forget to save your full route url (e.g. http://example.com/webmoney/result ) for your project on merchant.webmoney.ru.
Create the following controller: /app/Http/Controllers/ExampleController.php
:
class ExampleController extends Controller
{
/**
* Search the order if the request from WebMoney Merchant is received.
* Return the order with required details for the webmoney request verification.
*
* @param Request $request
* @param $order_id
* @return mixed
*/
public static function searchOrderFilter(Request $request, $order_id) {
// If the order with the unique order ID exists in the database
$order = Order::where('unique_id', $order_id)->first();
if ($order) {
$order['WEBMONEY_orderSum'] = $order->amount; // from your database
// if the current_order is already paid in your database, return strict "paid";
// if not, return something else
$order['WEBMONEY_orderStatus'] = $order->order_status; // from your database
return $order;
}
return false;
}
/**
* When the payment of the order is received from WebMoney Merchant, you can process the paid order.
* !Important: don't forget to set the order status as "paid" in your database.
*
* @param Request $request
* @param $order
* @return bool
*/
public static function paidOrderFilter(Request $request, $order)
{
// Your code should be here:
YourOrderController::saveOrderAsPaid($order);
// Return TRUE if the order is saved as "paid" in the database or FALSE if some error occurs.
// If you return FALSE, then you can repeat the failed paid requests on the WebMoney Merchant website manually.
return true;
}
/**
* Process the request from the WebMoney Merchant route.
* searchOrderFilter is called to search the order.
* If the order is paid for the first time, paidOrderFilter is called to set the order status.
* If searchOrderFilter returns the "paid" order status, then paidOrderFilter will not be called.
*
* @param Request $request
* @return mixed
*/
public function payOrderFromGate(Request $request)
{
return WebMoneyMerchant::payOrderFromGate($request);
}
/**
* Returns the service status for WebMoney Merchant request
*/
public function payOrderFromGateOK()
{
return "YES";
}
}
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING for details.
If you discover any security related issues, please send me an email at actionmanager@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.