【问题标题】:Integrating PayUMoney in Laravel 5.6在 Laravel 5.6 中集成 PayUMoney
【发布时间】:2019-04-24 08:06:49
【问题描述】:

我正在尝试将 PayUMoney 集成到 Laravel 5.6 中。根据 PayUMoney Redirect Checkout 文档,需要填写表格并提交给“https://sandboxsecure.payu.in/_payment”(使用沙箱 url 进行测试)。 提交成功填写必要字段的 html 表单会将我重定向到支付网关页面并且工作正常。但我想在我的 Laravel 控制器中实现它。我做了以下事情:

我的路线是:

    Route::get('book/placeOrder', ['uses' => 'BooksController@placeOrder', 'as' => 'placeOrder']);
Route::get('payumoney/surl', ['uses' => 'BooksController@surl', 'as' => 'payumoneysurl']);
    Route::get('payumoney/furl', ['uses' => 'BooksController@furl', 'as' => 'payumoneyfurl']);

BooksController 中的placeOrder 函数:

public function sendCurlPostRequest(){
    //code to add order and order details go here

    $salt = "[my merchant salt]";
    $hash_string = '';
    $hash_string .= "[hash string as per the payumoney checkout document]";
    $hash_string .= $salt;
    $hash = strtolower(hash('sha512', $hash_string));

    $data1 = [
        'key' => "[merchant key]",
        'hash' => $hash,
        'txnid' => "or1234txn",
        'amount' => "10",
        'firstname' => "[sample customer name]",
        'email' => "[sample email]",
        'phone' => "[sample phone number]",
        'productinfo' => "book",
        'surl' =>  "[route to success page]",
        'furl' => "[route to failure page]",
        'service_provider' => "payu_paisa",
    ];

    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL => "https://sandboxsecure.payu.in/_payment",
        CURLOPT_RETURNTRANSFER => false,
        CURLOPT_FOLLOWLOCATION => 1,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => $data1,
    ));

    $response = curl_exec($curl);

    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
        echo "cURL Error #:" . $err;
    } else {
        //print_r(json_decode($response));
        //print_r($response);
    }

}

单击购物车页面中的结帐按钮时,我确实被重定向到 PayUMoney 页面,但该页面未完全加载。仅显示页面的 html 标题和页面加载器。由于页面没有加载,所以我只能看到加载器。

你能帮我在我的 Laravel 控制器方法中实现 PayUMoney 支付网关(最好没有任何第三方插件)的正确方法吗?

请指出必要的解决方案...

谢谢

【问题讨论】:

    标签: laravel-5 payment-gateway payumoney


    【解决方案1】:

    我自己刚刚开始为客户使用 PayU - 您是否考虑过使用官方 SDK?

    https://github.com/PayU-EMEA/openpayu_php

    或非官方

    https://github.com/tzsk/payu

    【讨论】:

    • 感谢您推荐我的套餐?
    猜你喜欢
    • 2018-11-23
    • 2018-08-28
    • 2021-05-29
    • 2017-06-14
    • 2018-12-10
    • 1970-01-01
    • 2019-02-09
    • 1970-01-01
    • 2015-12-26
    相关资源
    最近更新 更多