<?php
require '../library/database.php';

if (getIP() == '203.151.205.45' || getIP() == '203.151.205.33' || getIP() == '18.143.213.62' || getIP() == '13.215.225.183' || getIP() == '54.254.171.101' || getIP() == '18.141.54.201' || getIP() == '54.151.232.117' || getIP() == '54.255.79.153') {

	$json_str = file_get_contents('php://input');
	$json_obj = json_decode($json_str);

	if ($json_obj->resultCode === '00') {
		$referenceNo = $con->real_escape_string($json_obj->referenceNo);
		$gbpReferenceNo = $con->real_escape_string($json_obj->gbpReferenceNo);
		$amount = (float)$con->real_escape_string($json_obj->amount);
		$userid = $con->real_escape_string($json_obj->merchantDefined1);
		$accid = $con->real_escape_string($json_obj->merchantDefined2);

		$con->query("UPDATE donate SET amount={$amount}, gbpReferenceNo='{$gbpReferenceNo}',`status`=1, updated_at=NOW() WHERE referenceNo='{$referenceNo}'");
	}
} else {
	die('Access Denied');
}
