logo
Blog single photo

Please ensure that the hash used in transaction request is calculated using the correct formula. Please note the correct formula for calculating the value of hash payumoney


                        

<?php  

$txnid = $_GET['cust'];
    $MERCHANT_KEY = "gtKFFx";
    $SALT = "eCwWELxi";   
    if($h_action3=='onlinepay'){               
    $posted = array();
    if(!empty($_POST)) {
      foreach($_POST as $key => $value) {   
        $posted[$key] = $value;        
      }
    }
    $formError = 0;
    if(empty($posted['txnid'])) {
      // Generate random transaction id
      $txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
    } else {
      $txnid = $posted['txnid'];
    }
    $hash = '';
    // Hash Sequence
    $hashSequence = "key|txnid|amount|productinfo|firstname|email|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['amount'])
              || empty($posted['firstname'])
              || empty($posted['email'])
              || empty($posted['phone'])
              || empty($posted['productinfo'])
              || empty($posted['surl'])
              || empty($posted['furl'])
             
      ) {
        $formError = 1;
       
      } else {
        //$posted['productinfo'] = json_encode(json_decode('[{"name":"tutionfee","description":"","value":"500","isRequired":"false"},{"name":"developmentfee","description":"monthly tution fee","value":"1500","isRequired":"false"}]'));
        $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';           
      }
    }        
        $url="https://test.payu.in/_payment";
    }
?>

 

<form name="form2" role="form" action="<?php echo $url; ?>" method="POST">

        <input type="hidden" name="h_action3"/>
        <input type="hidden" name="key" value="<?php echo $MERCHANT_KEY ?>" />
        <input type="hidden" name="hash" value="<?php echo $hash ?>"/>
        <input type="hidden" name="txnid" value="<?php echo $txnid ?>" />
        <input type="hidden" name="amount" id="amount" value="" />
        <input type="hidden" name="productinfo" id="productinfo" value="" />
        <input type="hidden" name="firstname" value="<?php echo  $username; ?>" />
        <input type="hidden" name="email" value="<?php echo  $cemail; ?>" />
        <input type="hidden" name="phone" id="phone" value="" />
        <input type="hidden" name="service_provider" value="" size="64" />
        <input type="hidden" name="surl" value="http://urdo.in/success.php" />
        <input type="hidden" name="furl" value="http://urdo.in/failure.php" />
</form>

Top