带有PHP集成的Transaction express cURL不起作用?

带有PHP集成的Transaction express cURL不起作用?,php,curl,Php,Curl,此代码用于向支付网关发送详细信息。当我使用规范形式的代码时,它工作得很好,但在PHP中与cURL一起使用时,它不工作,并给出“objectismoved”的结果 我的问题有什么解决办法?如何在Transaction express网关中使用cURL进行支付转账 以下是导致问题的代码: function httpPost($url,$params) { $postData = ''; //create name value pairs seperated by &

此代码用于向支付网关发送详细信息。当我使用规范形式的代码时,它工作得很好,但在PHP中与cURL一起使用时,它不工作,并给出“objectismoved”的结果

我的问题有什么解决办法?如何在Transaction express网关中使用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);

出于安全原因,我认为存在ssl问题

你必须做一些类似的事情

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);


这适用于我的PayPal支付:

 $pp_hostname = "www.paypal.com";
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);      
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));

 $res = curl_exec($ch);
 curl_close($ch);

为什么要用卷发?这是一种过时的使用API的方式

在我的示例中,使用soapwsdl实现更健壮的面向对象方法


关于

还有另一种选择,即呼叫交易快速支付方式。 让我们以sendTran mathod为例。 代码如下所示

$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));
$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));