【发布时间】:2011-10-04 01:11:16
【问题描述】:
首先,让我说我对 SOAP/WSDL/API 比较陌生,所以这篇文章会有点冗长,因为我不知道发生了什么。在过去的几个小时里,我一直在谷歌上搜索东西,但没有运气。我希望这里有人可以为我指明正确的方向,以便我继续前进。
我正在尝试利用 FirstData 的 API 来制作 PHP 支付脚本。我在使用 PHP 通过他们的 API 访问他们的 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、$body var,还是我尝试在没有 SSL 的情况下访问 WSDL(或所有 3 个的组合)的事实。我已经看到了我使用的代码的一些变体,所以我认为它是正确的。我有一个 FirstData 试用帐户,以及 .pem 和 .key 文件,如果他们想帮助我调查,我可以发送给任何人。我完全迷失了!
提前致谢,
特雷
【问题讨论】:
-
tr3online 你能解决这个问题吗?如果是,您能否发布您对此问题的解决方案?