承接 ashikkaiser/laravel-webmoney-merchant 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ashikkaiser/laravel-webmoney-merchant

Composer 安装命令:

composer require ashikkaiser/laravel-webmoney-merchant

包简介

WebMoneyMerchant payments for Laravel

README 文档

README

Latest Stable Version Build Status SensioLabsInsight Quality Score Total Downloads License

Accept payments via WebMoney Merchant (merchant.webmoney.ru) using this Laravel framework package (Laravel).

  • receive payments, adding just the two callbacks
  • receive payment notifications via your email or Slack

You can accept payments with WebMoney Merchant via WebMoney, credit cards etc.

Installation

You can install the package through Composer:

composer require ashikkaiser/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 

Configuration

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:

    • Merchant name;
    • Secret Key;
    • Secret Key X20;
    • Result URL;
    • Control sign forming method = SHA256;
    • Necessarily require signature payment form = ON;
    • Process payments with unique only lmi_payment_no = 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

Usage

  1. Generate an HTML payment form with enabled payment methods:
$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

  1. Process the request from WebMoneyMerchant:
WebMoneyMerchant::payOrderFromGate(Request $request)

Important

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)

Example

The process scheme:

  1. The request comes from merchant.webmoney.ru GET http://yourproject.com/webmoney/result to check if your website is available.
  2. The request comes from merchant.webmoney.ru POST http://yourproject.com/webmoney/result (with params).
  3. The functionExampleController@payOrderFromGate runs the validation process (auto-validation request params).
  4. The static function searchOrderFilter will be called (see config/webmoney-merchant.php searchOrderFilter) to search the order by the unique id.
  5. If the current order status is NOT 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";
    }
    
}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please send me an email at actionmanager@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

ashikkaiser/laravel-webmoney-merchant 适用场景与选型建议

ashikkaiser/laravel-webmoney-merchant 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 06 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「payments」 「laravel-webmoney-merchant」 「webmoney-merchant」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ashikkaiser/laravel-webmoney-merchant 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ashikkaiser/laravel-webmoney-merchant 我们能提供哪些服务?
定制开发 / 二次开发

基于 ashikkaiser/laravel-webmoney-merchant 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-06