Reputation: 5860
I need to create a return url which I have given to a payment gateway in which they will post their response parameters:
status
customerReferenceNo
referenceNo
merchantId
amount
checkSum
to the URL I given. All I want is an HTML page which could accept this parameters and store them to a database, the database part I can do it.
But the php code for accepting their values,I cant do that.i dont know whether they are using POST or GET:
status-4N
customerReferenceNo - 30An
referenceNo - 32 AN
merchantId - 10AN
amount - 9.2AN
checkSum - 64AN
This are the parameters they given in their documentation and they have also given respective field specification (I don't know what field specs is).
The status '0' will be successful transaction and if its a negative value, it's a failed transaction.
<?php
require("./connect.php");
if (count($_GET)==0 && count($_POST)==0)
{
?>
<h1 style="font-weight:bold; font-family:'RobotoThin' align='center';">ERROR. NO DATA FOUND</h1>
<?php
}
else
{
if($_SERVER['REQUEST_METHOD']=='POST')
{
$status = $_REQUEST['Status'];
$essrefno= $_REQUEST['TransactionId'];
$ref_no= $_REQUEST['ReferenceNo'];
$sql = "update `tablename` set `ess_ref_no`= '$essrefno',status='$status' where ref_no ='$ref_no'";
mysql_query($sql);
}
if($_SERVER['REQUEST_METHOD']=='GET')
{
$status = $_REQUEST['Status'];
$essrefno= $_REQUEST['TransactionId'];
$ref_no= $_REQUEST['ReferenceNo'];
//echo $status+$essrefno+$ref_no;
$sql = "update `tablename` set `ess_ref_no`= '$essrefno',status='$status' where ref_no ='$ref_no'";
mysql_query($sql);
}
//echo $sql;
?>
<?php
if ($status==0 )
{
?>
<h1 style="font-weight:normal; font-family:'RobotoThin';">Your transaction is successful and your transaction reference no for any further communication is <?php echo $ref_no; ?> .</h1>
<?php
}
else
{
?>
<h1 style="font-weight:normal; font-family:'RobotoThin';">Your transaction failed and your transaction reference no for any further communication is <?php echo $ref_no; ?>.</h1>
<?php
}
}
?>
This is the PHP I have made but it's not working. Moreover I have given something.html page to them and I don't know how this PHP be integrated to that HTML page using JavaScript or something? Is there someone who could help me?
Upvotes: 1
Views: 2587
Reputation: 4529
The superglobal $_REQUEST will contain both POST as GET data, so don't worry too much (yet) if they POST or GET the data.
Do a var_dump($_REQUEST);
to see the data that's been posted. Should be easy from that point on.
Upvotes: 2