<?php
require_once '../functions.php';
require_once '../hipay_mapi_php5_1_0/mapi_package.php';
//Base save in test database
$request = '';
foreach ($_REQUEST as $var => $val) {
	$request .= $var . ' = ' . $val . ' | ' . "\n";
}
$db = connect();

if ($db) {
	$query = "INSERT INTO notifications SET message = '" . $request . "'" ;
	$result = mysql_query($query);
	if ($result) {
		echo "saved";
	}
}
else echo "not saved";

echo "<pre>";
var_dump($_REQUEST);
echo "</pre>";
/*
// Receipt of the notification from the Hipay platform
// The XML feed [C] is sent by POST, in the field “xml”
// The function analyzeNotificationXML processes the XML feed from the Hipay platform
$r=HIPAY_MAPI_COMM_XML::analyzeNotificationXML($_POST[‘xml’], &$operation, &$status, &$date, &$time, &$transid, &$amount, &$currency, &$idformerchant, &$merchantdatas, &$emailClient, &$subscriptionId, &$refProduct);
// An error occurs
if ($r===false) {
	// Error log, in a text file on the server
	file_put_contents("result.txt", "Erreur");
} else {
	// The feed was processed
	// Here, the merchant can update his database for orders etc.
	file_put_contents("result.txt",
	"operation=$operation\n
	status=$status\n
	date=$date\n
	time=$time\n
	transaction_id=$transid\n
	amount=$amount\n
	currency=$currency\n
	idformerchant=$idformerchant\n
	merchantData=". print_r($merchantdatas,true)."\n
	emailClient=$emailClient\n
	subscriptionId=$subscriptionId\n
	refProduct=".print_r($refProduct,true));
}
*/
?>