 <?php
$dbHost = 'localhost';
$dbUser = 'getidbiz_getidw';
$dbPass = 'g3t!d';
$dbName = 'getidbiz_wines2u';

$dbConn = mysql_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($dbName) or die('Cannot select database. ' . mysql_error());
		
		$B_merch_ID = $_POST["Shop"];
		$B_amount = $_POST["Amount"];
		$B_curr = trim($_POST["Currency"]);
		$B_order_id = $_POST["Ref"];

	$result = mysql_query("set names 'utf8'");
	$result = mysql_query("SELECT * FROM cc_transactions WHERE cc_ref='".$B_order_id."'");
		
	if (!$result) {
		echo "[BAD], ".$B_merch_ID."=90003432, ".$B_amount."=".$sum.", ".$B_curr."=978, ".$B_order_id."=".$orderdata['ref'];
	} else {
		$row = mysql_fetch_row($result);
		$cc_amount = $row[2];
		$cc_ref = $row[1];
		$cc_amount=$cc_amount/100;
		$sum = number_format($cc_amount, 2, '.', '');
		
		if (($B_merch_ID=="90003432") && ($B_amount==$sum) && ($B_curr=="978") && ($B_order_id==$cc_ref)) {
		echo "[OK]";
		} else {
		echo "[NOK], Shop: ".$B_merch_ID."=90003432, Amount: ".$B_amount."=".$sum.", Currency: ".$B_curr."=978, Ref: ".$B_order_id."=".$cc_ref;
		}
	}
		mysql_close($dbConn);
		mysql_free_result($result);
?>