Web 服务返回错误
Error returned in Web Service
我一直在努力调试它。我 运行 没主意了。我有以下简单的 PHP 代码。
$url = "https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"&txnMode=".$txnMode."&txnRequest=".urlencode($ch));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
不幸的是,每次我尝试 运行 时,我总是遇到 XML 请求的问题。这是请求。
$txnRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$txnRequest .= "<ccAuthRequestV1 xmlns=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\">\n";
$txnRequest .= "<merchantAccount>\n";
$txnRequest .= "<accountNum>".$account."</accountNum>\n";
$txnRequest .= "<storeID>".$merchantId."</storeID>\n";
$txnRequest .= "<storePwd>".$merchantPwd."</storePwd>\n";
$txnRequest .= "</merchantAccount>\n";
$txnRequest .= "<merchantRefNum>".$merchantRefNum."</merchantRefNum>\n";
$txnRequest .= "<amount>".$amount."</amount>\n";
$txnRequest .= "<card>\n";
$txnRequest .= "<cardNum>".$cardNum."</cardNum>\n";
$txnRequest .= "<cardExpiry>\n<month>".$eMonth."</month>\n<year>".$eYear."</year>\n</cardExpiry>\n";
$txnRequest .= "<cardType>".$cardType."</cardType>\n";
$txnRequest .= "<cvdIndicator>".$cvdIndicator."</cvdIndicator>\n";
$txnRequest .= "<cvd>".$cvd."</cvd>\n";
$txnRequest .= "</card>\n";
$txnRequest .= "<billingDetails>\n";
$txnRequest .= "<cardPayMethod>WEB</cardPayMethod>\n";
$txnRequest .= "<firstName>".$firstName."</firstName>\n";
$txnRequest .= "<lastName>".$lastName."</lastName>\n";
$txnRequest .= "<street>".$bStreet."</street>\n";
$txnRequest .= "<city>".$bCity."</city>\n";
$txnRequest .= "<state>".$bState."</state>\n";
$txnRequest .= "<country>".$bCountry."</country>\n";
$txnRequest .= "<zip>".$bZip."</zip>\n";
$txnRequest .= "<phone>".$bPhone."</phone>\n";
$txnRequest .= "<email>".$bEmail."</email>\n";
$txnRequest .= "</billingDetails>\n";
$txnRequest .= "</ccAuthRequestV1>";
谁能提供一些关于编码不正确的见解?
我认为@Steve 走在正确的轨道上。也许你的意思是 urlencode($txnRequest))
此外,请在发送前验证您的 xml。
@aynber 是正确的,看起来您没有对请求的正确部分进行编码。
我相信正确的做法应该是这样的。
$url = "https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"&txnMode=".$txnMode."&txnRequest=".urlencode($txnRequest));
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 = curl_exec($ch);
希望这对您有所帮助。
我一直在努力调试它。我 运行 没主意了。我有以下简单的 PHP 代码。
$url = "https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"&txnMode=".$txnMode."&txnRequest=".urlencode($ch));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
不幸的是,每次我尝试 运行 时,我总是遇到 XML 请求的问题。这是请求。
$txnRequest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$txnRequest .= "<ccAuthRequestV1 xmlns=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\">\n";
$txnRequest .= "<merchantAccount>\n";
$txnRequest .= "<accountNum>".$account."</accountNum>\n";
$txnRequest .= "<storeID>".$merchantId."</storeID>\n";
$txnRequest .= "<storePwd>".$merchantPwd."</storePwd>\n";
$txnRequest .= "</merchantAccount>\n";
$txnRequest .= "<merchantRefNum>".$merchantRefNum."</merchantRefNum>\n";
$txnRequest .= "<amount>".$amount."</amount>\n";
$txnRequest .= "<card>\n";
$txnRequest .= "<cardNum>".$cardNum."</cardNum>\n";
$txnRequest .= "<cardExpiry>\n<month>".$eMonth."</month>\n<year>".$eYear."</year>\n</cardExpiry>\n";
$txnRequest .= "<cardType>".$cardType."</cardType>\n";
$txnRequest .= "<cvdIndicator>".$cvdIndicator."</cvdIndicator>\n";
$txnRequest .= "<cvd>".$cvd."</cvd>\n";
$txnRequest .= "</card>\n";
$txnRequest .= "<billingDetails>\n";
$txnRequest .= "<cardPayMethod>WEB</cardPayMethod>\n";
$txnRequest .= "<firstName>".$firstName."</firstName>\n";
$txnRequest .= "<lastName>".$lastName."</lastName>\n";
$txnRequest .= "<street>".$bStreet."</street>\n";
$txnRequest .= "<city>".$bCity."</city>\n";
$txnRequest .= "<state>".$bState."</state>\n";
$txnRequest .= "<country>".$bCountry."</country>\n";
$txnRequest .= "<zip>".$bZip."</zip>\n";
$txnRequest .= "<phone>".$bPhone."</phone>\n";
$txnRequest .= "<email>".$bEmail."</email>\n";
$txnRequest .= "</billingDetails>\n";
$txnRequest .= "</ccAuthRequestV1>";
谁能提供一些关于编码不正确的见解?
我认为@Steve 走在正确的轨道上。也许你的意思是 urlencode($txnRequest))
此外,请在发送前验证您的 xml。
@aynber 是正确的,看起来您没有对请求的正确部分进行编码。
我相信正确的做法应该是这样的。
$url = "https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"&txnMode=".$txnMode."&txnRequest=".urlencode($txnRequest));
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 = curl_exec($ch);
希望这对您有所帮助。