好的,我有我的匯豐銀行處理使用API的這個php文件,我對其他兩個網站的工作很好,但是其他兩個網站上的SAME文件失敗了,我不知道爲什麼。我的網絡開發難倒了,並決定建立一個測試文件,下面是測試文件代碼:收到的HTTP方法無效。只有POST被接受
<?php
echo "payment processing...";
$amount = 100;// round($_POST["realamount"], 2) * 100;
$fullName = "test";//$_POST['name'];
$Address1 = "test";//$_POST['address1'];
$Address2 = "test";//$_POST['address2'];
$city ="test";// $_POST['city'];
$county = $city;
$postcode = "test";//$_POST['zipcode'];
$country = "GRB";//$_POST['country'];
$phone = "test";//$_POST['telephone'];
$email = "[email protected]";//$_POST['emailaddress'];
$cardNumber = "337877666233434";//$_POST['cardNumber'];
$cardExp = "03/2011";//$_POST['ccmonth'] . "/" . substr($_POST["ccyear"],2,2);
$cvdIndicator = "111";//$_POST['cvdIndicator'];
$cvdValue = "111";//$_POST['cvdValue'];
$issueNumber = "111";//$_POST['issueNumber'];
$cardType = "VI";//$_POST['cardType'];
$testRead = "<?xml version='1.0' encoding='UTF-8'?>
<EngineDocList>
<DocVersion>1.0</DocVersion>
<EngineDoc>
<ContentType>OrderFormDoc</ContentType>
<User>
<Name>xxx</Name>
<Password>xxx</Password>
<ClientId>xxx</ClientId>
</User>
<Instructions>
<Pipeline>PaymentNoFraud</Pipeline>
</Instructions>
<OrderFormDoc>
<Mode>P</Mode>
<Comments/>
<Consumer>
<Email/>
<PaymentMech>
<CreditCard>
<Number>".$cardNumber."</Number>
<Expires DataType='ExpirationDate' Locale='840'>".$cardExp."</Expires>
<Cvv2Val>".$cvdValue."</Cvv2Val>
<Cvv2Indicator>".$cvdIndicator."</Cvv2Indicator>
<IssueNum>".$issueNumber."</IssueNum>
</CreditCard>
</PaymentMech>
</Consumer>
<Transaction>
<Type>Auth</Type>
<CurrentTotals>
<Totals>
<Total DataType='Money' Currency='826'>".$amount."</Total>
</Totals>
</CurrentTotals>
</Transaction>
</OrderFormDoc>
</EngineDoc>
</EngineDocList>";
?>
<?php
//$url = "https://www.uat.apixml.netq.hsbc.com";
$url = "https://www.secure-epayments.apixml.hsbc.com/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$testRead);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result_tmp = curl_exec ($ch);
curl_close ($ch);
///////////////////////////////////////
// use XML Parser result
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE,1);
xml_parse_into_struct($xml_parser, $result_tmp, $vals, $index);
xml_parser_free($xml_parser);
//print_r($vals); // print all the arrays.
//print_r($vals[29]); // print only the selected array.
$val1 = $vals[21];
// ProcReturnMsg
$paymentResult = $val1[value];
$result_tmp = "";
$k=0;
$findthis = false;
$findthis2 = false;
foreach ($vals as $val) {
$result_tmp.= $k."{";
foreach($val as $d => $a) {
$result_tmp.="[".$d."]".$a;
if($d=="tag" && $a=="TransactionStatus"){
$findthis = true;
}
if($d=="value" && $findthis){
$tResult = $a;
$findthis = false;
}
if($d=="tag" && $a=="Text"){
$findthis2 = true;
}
if($d=="value" && $findthis2){
$tResult2 = $a;
$findthis2 = false;
}
}
$result_tmp.= "}";
$k++;
}
echo $tResult2.$tResult;
?>
這裏是網站的一個不工作gs.net 的輸出是一個例子: 支付處理。 ..收到的HTTP方法無效。只接受POST。
當我上傳此完全相同的文件,我的一些其他的網絡主機如鑑於: HGL working example 這裏的輸出是支付處理...無法確定卡的類型。 ('length'是'15')E 這聽起來像是一個錯誤信息,但基本上這個錯誤並不重要,所以後者就是我們試圖在第一個鏈接中實現的。
我甚至上傳了這個文件到我的一些非常基本的主機帳戶,有時它會工作,有時它不會,所以我猜這是什麼與託管公司允許或已打開/關閉。
有什麼想法嗎?
謝謝
是實際的產品代碼?也就是說,您將POST變量直接粘貼到XML中作爲純文本?注入漏洞已經成熟。 – Hamish 2012-03-04 00:43:20
不太清楚你的意思,但這是一個測試文件,頂部的信息,如卡號等。我想你是指,這不包括在真實文件中。 – user1171523 2012-03-04 00:46:48
您是否可以使用其他方法(如命令行卷曲)將'$ testRead'變量的評估內容作爲POST請求發送到'$ url',並接收成功響應?也許你遇到了PHP引用的問題,這會導致API的奇怪反應。 – imm 2012-03-04 01:42:38