使用php发送3D安全请求

时间:2013-07-09 21:38:27

标签: php xml 3d-secure

我正在尝试实现3d安全性。我有一个xml包含3d secure.Like所需的一些数据:

<CardinalMPI>
<MsgType>cmpi_lookup</MsgType>
<Version>1.7</Version>
<ProcessorId>xxx</ProcessorId>
<MerchantId>xxxxxx</MerchantId>
<TransactionPwd>xxxxxxxxxxx</TransactionPwd>
<TransactionType>C</TransactionType>
<Amount>56999</Amount>
<CurrencyCode>xxxxx</CurrencyCode>
<OrderNumber>xxxx</OrderNumber>
<CardNumber>xxx</CardNumber>
<CardExpMonth>xxx</CardExpMonth>
<CardExpYear>xxx</CardExpYear>
</CardinalMPI>

然后我如何使用上面的xml向http://msgtest.bankserv.co.za/maps/txns.asp请求并获得他们的回复?我尝试了卷曲,肥皂等,并得到了错误。请详细帮我解答一些问题。

我尝试过以下代码。如果此代码不正确,请告诉我。

$writer = new XMLWriter();
$writer->openMemory();

$writer->startElement("CardinalMPI");
$writer->writeElement("MsgType","cmpi_lookup");
$writer->writeElement("Version","1.7");
$writer->writeElement("ProcessorId","xxxxx");
$writer->writeElement("MerchantId","xxxxxxx");
$writer->writeElement("TransactionPwd","xxxxx");
$writer->writeElement("TransactionType","C");
$writer->writeElement("Amount",$xxxx);
$writer->writeElement("CurrencyCode","xxxx");
$writer->writeElement("OrderNumber","xxxxxxxxxx");
$writer->writeElement("CardNumber","'xxxxxxxxx");
$writer->writeElement("CardExpMonth","xx");
$writer->writeElement("CardExpYear","xxxx");
$writer->endElement();
$writer->endElement();
$writer->endDocument();
$request = $writer->outputMemory(true);

$serviceArguments =       array("validateRequest"=>"0","protocol"=>"v_xml","protocolVersion"=>"2.0","request"=> $request);
$client = new SoapClient("msgtest.bankserv.co.za/maps/txns.asp", array('local_cert'=> "certificate.pem"));
$result = $client->Execute($serviceArguments);
$xml=$result->ExecuteResult;

当我运行此代码时,我会遇到异常。

1 个答案:

答案 0 :(得分:0)

对于发布值,我们可以在php中使用CURL。在这里你可以使用:

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, "your url");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "yr_variable=".$your xml);
$result=curl_exec($ch);
curl_close($ch);