-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
74 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<?php | ||
echo "Failed Translation :("; | ||
print_r($_POST); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -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> | ||
|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<?php | ||
echo "Successfully translation :)"; | ||
print_r($_POST); | ||
?> |