我正在与支付网关集成项目合作。我需要向网站url提交请求并解析响应。两者都是xml格式。应该使用REST API完成。
我尝试使用Ajax,但最终没有结果。
form.php
<form method="post" action="process.php">
<input type="hidden" name="TransactionType" value="SALE">
<input type="hidden" name="TerminalID" value="TESTTERMINAL">
<input type="number" name="CardNum" value="4000300020001000"><br>
<input type="number" name="CardExpMonth" value="12"><br>
<input type="number" name="CardExpYear" value="14"><br>
<input type="number" name="TotalAmount" value="9999"><br>
<input type="submit" value="Submit">
</form>
process.php
<?php
extract($_POST);
$url = " https://testgtwy.ippay.com/ippay";
//convert form data into xml format
$xmldata = "<?xml version='1.0' encoding='UTF-8' ?>
<ippay>
<TransactionType>SALE</TransactionType>
<TerminalID>TESTTERMINAL</TerminalID>
<CardNum>$_POST[CardNum]</CardNum>
<CardExpMonth>$_POST[CardExpMonth]</CardExpMonth>
<CardExpYear>$_POST[CardExpYear]</CardExpYear>
<TotalAmount>$_POST[TotalAmount]</TotalAmount>
</ippay> ";
$xml = simplexml_load_string($xmldata) or die("Error: cannot create object");
$json = json_encode($xml);
$array = json_decode($json, TRUE);
?>
如何将这些xml数据发布到该URL中并显示响应?预先感谢