使用Curl在Laravel中重定向到PayUMoney
P粉877114798
P粉877114798 2023-07-22 20:17:03
0
1
469

我想使用Curl从我的PHP服务器重定向到PayUMoney支付网关。

我正在使用Laravel框架,但我不想使用HTML/Blade方法来触发支付网关。


$posted = array(); $posted['key'] = $MERCHANT_KEY; $posted['hash'] = $hash; $posted['txnid'] = $txnid; $posted['firstname'] = $firstname; $posted['email'] = $email; $posted['phone'] = $phone; $posted['amount'] = $amount; $posted['productinfo'] = $productinfo; $posted['surl'] = $surl; $posted['furl'] = $furl; ini_set('display_errors', 1); $c = curl_init(); $url = "https://test.payu.in/_payment"; curl_setopt_array($c, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 0, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $posted, )); $response = curl_exec($c);

但是这段代码显示的输出如下,因此无法完全重定向到支付网关(https://i.stack.imgur.com/WmDFS.png)。

P粉877114798
P粉877114798

全部回复 (1)
P粉020085599
$posted = array( 'key' => $MERCHANT_KEY, 'hash' => $hash, 'txnid' => $txnid, 'firstname' => $firstname, 'email' => $email, 'phone' => $phone, 'amount' => $amount, 'productinfo' => $productinfo, 'surl' => $surl, 'furl' => $furl, ); $url = "https://test.payu.in/_payment"; $c = curl_init(); curl_setopt_array($c, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($posted), CURLOPT_HEADER => false, )); curl_setopt($c, CURLOPT_VERBOSE, true); curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); $response = curl_exec($c); curl_close($c);

将页面重定向到PayUmoney支付网关。

return Redirect::away($url)->withInput($request->input());

或者可以用:

header("Location: $url"); exit;
    最新下载
    更多>
    网站特效
    网站源码
    网站素材
    前端模板
    关于我们 免责声明 Sitemap
    PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!