Hi all,
I want to add 5.5% fees to the field amount before sending it to the payment gateway..I am able to add the fees and show in a text box. But I couldn't send to payment gateway..It says "Checksum error". Please help!
The working version is given
here
Enter a dummy name, dummy email, dummy phone, amount and click submit.. It will reload once and take to payment gateway's page which will show checksum error.
The error is with the field "amount". Actually Payu provide the code
<input name="amount" value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount'] ?>" />
But I just want to add 5.5% to that amount.
<?php
$MERCHANT_KEY = "JBZaLc";
$SALT = "GQs7yium";
$PAYU_BASE_URL = "https://test.payu.in";
$action = '';
$posted = array();
if(!empty($_POST)) {
foreach($_POST as $key => $value) {
$posted[$key] = $value;
}
}
$formError = 0;
if(empty($posted['txnid'])) {
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
} else {
$txnid = $posted['txnid'];
}
$hash = '';
$hashSequence = "key|txnid|firstname|email|productinfo|amount|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if(empty($posted['hash']) && sizeof($posted) > 0) {
if(
empty($posted['key'])
|| empty($posted['txnid'])
|| empty($posted['firstname'])
|| empty($posted['email'])
|| empty($posted['productinfo'])
|| empty($posted['amount'])
|| empty($posted['phone'])
|| empty($posted['surl'])
|| empty($posted['furl'])
|| empty($posted['service_provider'])
) {
$formError = 1;
} else {
$hashVarsSeq = explode('|', $hashSequence);
$hash_string = '';
foreach($hashVarsSeq as $hash_var) {
$hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : '';
$hash_string .= '|';
}
$hash_string .= $SALT;
$hash = strtolower(hash('sha512', $hash_string));
$action = $PAYU_BASE_URL . '/_payment';
}
} elseif(!empty($posted['hash'])) {
$hash = $posted['hash'];
$action = $PAYU_BASE_URL . '/_payment';
}
?>
<html>
<head>
<script>
var hash = '<?php echo $hash ?>';
function submitPayuForm() {
if(hash == '') {
return;
}
var payuForm = document.forms.payuForm;
payuForm.submit();
}
</script>
<!--
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,300,600,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<!--
<!--
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!--
<link rel="stylesheet" href="foundation/stylesheets/foundation.min.css">
<link rel="stylesheet" href="foundation/stylesheets/app.css">
<script src="foundation/javascripts/modernizr.foundation.js"></script>
<!--
<!--
<script src="js/foundation-datepicker.js"></script>
<link rel="stylesheet" href="stylesheets/foundation-datepicker.css">
<!--
<link rel="stylesheet" href="stylesheets/example.css">
<!--
<script language="javascript">
function KeyUpEvent()
{
var txt1 = document.getElementById("txt1");
var txt2 = document.getElementById("txt2");
var amount = document.getElementById("amount");
if ((txt1.value != "") && (txt2.value != ""))
{
amount.value = parseInt(txt1.value) + parseInt(txt1.value) * (txt2.value);
}
}
</script>
</head>
<body onload="submitPayuForm()">
<h2>Homestaysatwaya