0 レビュー
1 回答
sagepayレポートとphpの管理APIコード例
トランザクションをクエリするようにsagepayレポートAPIを設定しようとしています。
ここで別の質問からコードを取得しましたが、ほとんどの場合、返されたXMLを保存して、データベースに保存します。どうすればよいですか?
<?php
$command = 'getTransactionList';
$vendor = 'vendor';
$user = 'user';
$password = 'password';
$startdate = '01/10/2015 00:00:01';
$enddate = '31/10/2015 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 = new SimpleXMLElement($result);
?>
<html>
<body>
<form method="post" action="https://test.sagepay.com/access/access.htm" enctype="application/x-www-form-urlencoded">
<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>
ご協力いただきありがとうございます。
わからない
0
レビュー
答え :
解決策:
興味のある方は、以下に回答してください。
<?php
$command = 'getTransactionList';
$vendor = 'vendor';
$user = 'user';
$password = 'password';
$startdate = '20/10/2015 00:00:01';
$enddate = '22/10/2015 23:59:59';
$string = '<command>'.$command.'</command><vendor>'.$vendor.'</vendor><user>'.$user.'</user><startdate>'.$startdate.'</startdate><enddate>'. $enddate.'</enddate><txtypes><txtype>PAYMENT</txtype></txtypes><result>failure</result>';
$crypt = MD5($string . '<password>' . $password . '</password>');
$xml = 'XML=<vspaccess>'.$string.'<signature>'.$crypt.'</signature></vspaccess>';
$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_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
$result = curl_exec($curl);
$rxml = new SimpleXMLElement($result);
foreach($rxml->transactions->transaction as $transx)
{
echo '<p>Payment Type = '.$transx->transactiontype.'</p>';
echo '<p>Amount = '.$transx->amount.'</p>';
echo '<p>Name = '.$transx->cardholder.'</p>';
echo '<p>Result = '.$transx->result.'</p>';
}
?>
画面に情報をエコーしましたが、返されたデータを取得してデータベースに保存したり、クエリを実行したりできます。
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。