2015-07-01 47 views
4

此代碼用於將詳細信息發送到支付網關。當我使用我的普通窗體的代碼時,它工作正常,但在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); 

回答

0

我認爲這是出於安全原因,SSL的問題

你必須做一些像

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 

OR

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); 
0

這適用於我的PayPal付款方式:

0

有呼叫交易快車付款gatway另一種選擇。 讓我們以sendTran方法爲例。代碼將如下所示。

$client = new SoapClient("https://ws.cert.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl",array('exceptions'=>FALSE)); 

$params = array("tranCode" => 1, 
       "reqAmt" => 0200 
       ); 

$SendTran = $client->__soapCall("SendTran", array("parameters" => $params));