首先,我要说的是,我对SOAP/WSDL/API比较陌生,所以这篇文章会有点冗长,因为我不知道发生了什么。在过去的几个小时里,我一直在谷歌上搜索东西,但一无所获。我希望这里有人能给我指引正确的方向,这样我才能继续前行。
我正在尝试利用FirstData的API来制作一个PHP支付脚本。我在使用PHP通过他们的应用程序接口访问他们的WSDL时遇到了问题。我的卷曲是(基于他们的documentation):
$wsdl = "https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl";
$userid = "WSxxxxxxxxxxx._.1";
$password = "xxxxxxxxxx";
$pemlocation = realpath("WSxxxxxxxxxx._.1.pem");
$kslocation = realpath("WSxxxxxxxxxx._.1.key");
$keyname = "ckp_xxxxxxxx";
$transactiontype = "sale";
$creditcardnumber = "4111111111111111";
$cardexpirationmonth = "10";
$cardexpirationyear = "12";
$chargetotal = "1";
$body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$body .= "<SOAP-ENV:Envelope xmlns:SOAP- ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">";
$body .= "<SOAP-ENV:Header />";
$body .= "<SOAP-ENV:Body>";
$body .= "<fdggwsapi:FDGGWSApiOrderRequest xmlns:fdggwsapi= \"http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi\">";
$body .= "<v1:Transaction xmlns:v1= \"http://secure.linkpt.net/fdggwsapi/schemas_us/v1\">";
$body .= "<v1:CreditCardTxType>";
$body .= "<v1:Type>";
$body .= $transactiontype;
$body .= "</v1:Type>";
$body .= "</v1:CreditCardTxType>";
$body .= "<v1:CreditCardData>";
$body .= "<v1:CardNumber>";
$body .= $creditcardnumber;
$body .= "</v1:CardNumber>";
$body .= "<v1:ExpMonth>";
$body .= $cardexpirationmonth;
$body .= "</v1:ExpMonth>";
$body .= "<v1:ExpYear>";
$body .= $cardexpirationyear;
$body .= "</v1:ExpYear>";
$body .= "</v1:CreditCardData>";
$body .= "<v1:Payment>";
$body .= "<v1:ChargeTotal>";
$body .= $chargetotal;
$body .= "</v1:ChargeTotal>";
$body .= "</v1:Payment>";
$body .= "</v1:Transaction>";
$body .= "</fdggwsapi:FDGGWSApiOrderRequest>";
$body .= "</SOAP-ENV:Body>";
$body .= "</SOAP-ENV:Envelope>";
$ch = curl_init($wsdl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$userid:$password");
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSLCERT, $pemlocation);
curl_setopt($ch, CURLOPT_SSLKEY, $kslocation);
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $keyname);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
print_r($result);它返回一个HTTP Status 401 - type: Status report | description: This request requires HTTP authentication (). | JBossWeb/2.0.0.GA。根据他们的文档OpenSSL,SSL certificate和TCP Port 1129是必需的。由于我没有得到任何返回,我认为这是因为我的OpenSSL没有在我的XAMPP上设置。如果这没有任何意义(?)跳过下一步。
我尝试在XAMPP下在apache中设置我的SSL。xampp\apache\makecert收益率:
Unable to load config info from ./bin/openssl.cnf
Error opening Private Key privkey.pem
6264:error:02001002:system library:fopen:No such file or directory:.\crypto\bio\bass_file.c:356:fopen('privkey.pem','rb')
6264:error:20064002:BIO routines:FILE_CTRL:system lib:.\crypto\bio\file.c:358:unable to load Private Key
Loading 'screen' into random state - done
server.csr: No such file or directory
Could Not Find c:\xampp\apache\.rnd
Could Not Find c:\xampp\apache\prikey.pem
Could Not Find c:\xampp\apache\server.csr
The system cannot find the file specified.
The system cannot find the file specified.我的openssl.cnf位于@ c:\xampp\php\extras\openssl\openssl.cnf。我做了一个openssl req -new -key digitss.key -out digitss.csr -config "c:\xampp\php\extras\openssl\openssl.cnf",让它起作用了,但最后什么也没做。我不确定如何让SSL运行。
无论如何,如果有人能对我的问题有所了解,我将不胜感激。我不知道是因为我的PHP、WSDL变量,还是因为我尝试在没有$body的情况下访问WSDL(或者是三者的组合)。我已经看到了我使用的代码的一些变体,所以我认为它是正确的。我有一个FirstData设置的试用帐户,以及.pem和.key文件,如果他们想要帮助我调查这个问题,我可以向任何人发送这些文件。我完全不知所措!
提前谢谢你,
Tre
发布于 2011-10-05 23:33:55
我相信你混淆了第一个数据API。
First Data API有两个:
Web服务API通过端口443发送,传统API通过端口1129发送。
您希望对上面在curl请求中列出的代码使用端口443。
https://stackoverflow.com/questions/7642347
复制相似问题