此代碼用於將詳細信息發送到支付網關。當我使用我的普通窗體的代碼時,它工作正常,但在PHP中使用cURL時它不起作用,並給出了「對象被移動」的結果。使用PHP集成的交易快速cURL不起作用?
我的問題的解決方案是什麼?如何在交易快遞網關中使用cURL進行付款轉賬?
這是導致問題的代碼:
function httpPost($url,$params)
{
$postData = '';
//create name value pairs seperated by &
foreach($params as $k => $v)
{
$postData .= $k . '='.$v.'&';
}
rtrim($postData, '&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, count($postData));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$output=curl_exec($ch) or die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));
curl_close($ch);
return $output;
}
$params = array(
"HostedKey" => "xxxxxxxxxxxxxxxxxxx",
"Gateway_ID" => "xxxxxxxx",
"IndustryCode" => "2",
"Amount" => "",
"RecurringType" => "N",
"RecurringAmount" => "",
"RURL" => "http://www.example.com",
"CURL" => "http://www.example.com",
"AVSRequired" => "N",
"CVV2Required" => "Y",
"EmailRequired" => "Y",
"PostRspMsg" => "N",
"FullName" => "my name",
"CustRefID" => "11111111"
);
echo httpPost("https://hosted.transactionexpress.com/Transaction/Transaction/Index/",$params);