Rumah > Soal Jawab > teks badan
Saya ingin mengubah hala dari pelayan PHP saya ke gerbang pembayaran PayUMoney menggunakan Curl.
Saya menggunakan rangka kerja Laravel tetapi saya tidak mahu menggunakan kaedah HTML/Blade untuk mencetus get laluan pembayaran.
$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);
Tetapi kod ini menunjukkan output seperti di bawah, jadi ia tidak boleh diubah hala sepenuhnya ke gerbang pembayaran (https://i.stack.imgur.com/WmDFS.png).
P粉0200855992023-07-23 14:22:17
$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);
Ubah hala halaman ke gerbang pembayaran PayUmoney.
return Redirect::away($url)->withInput($request->input());
Atau boleh guna:
header("Location: $url"); exit;