I guess this question is not a Sage Pay specific question, although it's being mentioned in relation to my problem, so hope you're able to help me with this tricky issue.
Here's what I want to do:
- The main task is to retrieve data from the Sage Pay Reporting API - works like a charm
- Read and collect the variables from the xml output file - not working
The code below does show the list of transactions after redirecting me to the Sage Pay site but I just can't figure out how to get e.g. the amount of a single transaction and store it.
Here is what the xml output looks like:
Any answers/solutions? I appreciate your help!
<?
$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>