0

我想这个问题不是 Sage Pay 特定的问题,尽管它与我的问题有关,所以希望你能帮助我解决这个棘手的问题。

这是我想要做的:

  • 主要任务是从 Sage Pay Reporting API 检索数据 - 就像一个魅力
  • 从 xml 输出文件中读取并收集变量 - 不工作

下面的代码确实显示了将我重定向到 Sage Pay 站点后的交易列表,但我只是不知道如何获取例如单笔交易的金额并将其存储。

这是xml 输出的样子:

任何答案/解决方案?我感谢您的帮助!

<?

$command = 'getTransactionList';
$vendor = 'vendorname';
$user = 'username';
$password = 'pwd';
$startdate = '01/05/2013 00:00:01';
$enddate = '31/05/2013 23:59:59';

$string = '<command>'.$command.'</command><vendor>'.$vendor.'</vendor><user>'.$user.'</user><startdate>'.$startdate.'</startdate><enddate>'.$enddate.'</enddate>';


$crypt = MD5($string . '<password>' . $password . '</password>');

$curl = curl_init('https://test.sagepay.com/access/access.htm'); 
curl_setopt($curl, CURLOPT_FAILONERROR, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);   
$result = curl_exec($curl); 

$rxml = simplexml_load_string($result);
echo $rxml->transactions->transaction[0]->amount;

?>

<HTML>

<BODY>


<form method="post" action="https://test.sagepay.com/access/access.htm">

<input type="hidden" name="XML" value="<vspaccess><?php echo $string; ?><signature><?php echo $crypt; ?></signature></vspaccess>">
<input type="submit" name="Button" value="Send">

</form>
</BODY>
</HTML>
4

1 回答 1

1

替换 $rxml = simplexml_load_string($result);

$rxml = 新的SimpleXMLElement($result);

于 2013-11-23T07:11:45.693 回答