Skip to content

Commit

Permalink
payUmoney successfully completed
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhuphp committed Oct 1, 2019
1 parent 351f625 commit c7e600e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 33 deletions.
1 change: 1 addition & 0 deletions payUmoney/failed.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php
echo "Failed Translation :(";
print_r($_POST);
?>
31 changes: 31 additions & 0 deletions payUmoney/hash_generator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
$json=array();
/* We need to convert the inputs into HASH as per PayU alogrithem */

#Sequence
/* hashSequence = key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||salt;
$hash = hash("sha512", $hashSequence); */

/* Required Parameters for Translation */
if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') == 0){
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
if(strcasecmp($contentType, 'application/json') == 0){

$salt = 'a3yMmYqqmA';

$data = json_decode(file_get_contents('php://input'));
$hash=hash('sha512', $data->key.'|'.$data->txnid.'|'.$data->amount.'|'.$data->productinfo.'|'.$data->firstname.'|'.$data->email.'|||||'.$data->udf5.'||||||'.$salt);

$json['success'] = $hash;

}
}
else
{
$json['error'] = "Failed";
}

echo json_encode($json);


?>
74 changes: 41 additions & 33 deletions payUmoney/index.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
<?php
/* Required Parameters for Translation */
if(isset($_POST) && !empty($_POST))
{
$key = $_POST['key'];
$txnid = $_POST['txnid'];
$amount = $_POST['amount'];
$firstname = $_POST['firstname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$productinfo = $_POST['productinfo'];
$surl = $_POST['surl'];
$furl = $_POST['furl'];
$service_provider = $_POST['service_provider'];
$salt = 'a3yMmYqqmA';
$udf5 = $_POST['udf5']; //optional (user define field udf)

/* We need to convert the inputs into HASH as per PayU alogrithem */
$hash=hash('sha512', $key.'|'.$txnid.'|'.$amount.'|'.$productinfo.'|'.$firstname.'|'.$email.'|'.$phone.'|||||'.$udf5.'||||||'.$salt);

}


?>

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
Expand All @@ -33,30 +8,30 @@
<head ></head>
<body>
<h1>PayUMoney Payment Request Form </h1>
<form action="https://sandboxsecure.payu.in/_payment" name="payuform" method=POST >
<input type="hidden" name="key" value="skGYhOaC" />
<form action="https://sandboxsecure.payu.in/_payment" name="payuform" method="POST" id="payuform" >
<input type="hidden" name="key" id="key" value="skGYhOaC" />
<input type="hidden" name="hash_string" value="" />
<input type="hidden" name="hash" />
<input type="hidden" name="txnid" value="siddhu123"/> <!--This is unique generated id from me-->
<input type="hidden" name="hash" id="hash" value="" />
<input type="hidden" name="txnid" id="txnid" value="<?php echo "Txn" . rand(10000,99999999)?>"/> <!--This is unique generated id from me-->
<table>
<tr>
<td><b>Mandatory Parameters</b></td>
</tr>
<tr>
<td>Amount: </td>
<td><input name="amount" value="5" /></td>
<td><input name="amount" id="amount" value="5" /></td>
<td>First Name: </td>
<td><input name="firstname" id="firstname" value="Siddhu" /></td>
</tr>
<tr>
<td>Email: </td>
<td><input name="email" id="email" value="[email protected]" /></td>
<td>Phone: </td>
<td><input name="phone" value="9912238386" /></td>
<td><input name="phone" id="phone" value="9912238386" /></td>
</tr>
<tr>
<td>Product Info: </td>
<td colspan="3"><textarea name="productinfo" > </textarea></td>
<td colspan="3"><textarea name="productinfo" id="productinfo" ></textarea></td>
</tr>
<tr>
<td>Success URI: </td>
Expand Down Expand Up @@ -110,13 +85,46 @@
</tr>
<tr>
<td>UDF5: </td>
<td><input name="udf5" /></td>
<td><input name="udf5" id="udf5" /></td>
<td>PG: </td>
<td><input name="pg" /></td>
</tr>
<td colspan="4"><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
$('#payuform').bind('keyup blur', function(){
$.ajax({
url: 'hash_generator.php',
type: 'post',
data: JSON.stringify({
key: $('#key').val(),
txnid: $('#txnid').val(),
amount: $('#amount').val(),
productinfo: $('#productinfo').val(),
firstname: $('#firstname').val(),
email: $('#email').val(),
phone: $('#phone').val(),
udf5: $('#udf5').val()
}),
contentType: "application/json",
dataType: 'json',
success: function(json) {
if (json['error']) {
alert(json['error']);
}
else if (json['success']) {
$('#hash').val(json['success']);
}
}
});
});

</script>

</body>
</html>
1 change: 1 addition & 0 deletions payUmoney/success.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php
echo "Successfully translation :)";
print_r($_POST);
?>

0 comments on commit c7e600e

Please sign in to comment.