集成payu货币支付网关的问题

问题描述

我正在尝试在我的网站中集成 payu 支付网关。我正在使用我的实时商家密钥和盐值。但是 payu 说“您似乎使用了不正确的密钥或盐值。”

Image for your reference

我和 payu 团队谈过很多次了。但他们说关键/盐工作正常。

这是我的代码

<?PHP require('top.PHP'); if(!isset($_SESSION['cart']) || count($_SESSION['cart'])==0){?>

<script>
    window.location.href='index.PHP';
</script>

if (isset($_POST['submit'])){
$receiver_name=get_safe_value($con,$_POST['receiver_name']);
$address=get_safe_value($con,$_POST['address']);
$mobile=get_safe_value($con,$_POST['mobile']);
$landmark=get_safe_value($con,$_POST['landmark']);
$city=get_safe_value($con,$_POST['city']);
$pincode=get_safe_value($con,$_POST['pincode']);
$payment_type=get_safe_value($con,$_POST['payment_type']);
$user_id=$_SESSION['USER_ID'];

foreach($_SESSION['cart'] as $key=>$val){
$productArr=get_product($con,'',$key);
$price=$productArr[0]['price'];
$qty=$val['qty'];
$cart_total=$cart_total+($price*$qty);}

$total_price=$cart_total;
$payment_status='pending';
if($payment_type=='cod'){
    $payment_status='success';
}
$order_status='1';
$added_on=date('Y-m-d h:i:s');

$txnid = substr(hash('sha256',mt_rand() . microtime()),20);
    
<?PHP    }   $cart_total=0;

MysqLi_query($con,"insert into `order`(receiver_name,user_id,address,mobile,landmark,city,pincode,payment_type,payment_status,order_status,added_on,total_price,txnid) values('$receiver_name','$user_id','$address','$mobile','$landmark','$city','$pincode','$payment_type','$payment_status','$order_status','$added_on','$total_price','$txnid')");

$order_id=MysqLi_insert_id($con);

foreach($_SESSION['cart'] as $key=>$val){
    $productArr=get_product($con,$key);
    $price=$productArr[0]['price'];
    $qty=$val['qty'];
    
    MysqLi_query($con,"insert into `order_detail`(order_id,product_id,qty,price) values('$order_id','$key','$qty','$price')");
}

unset($_SESSION['cart']);

if($payment_type=='payu'){
    $MERCHANT_KEY = "yQBrnOe6"; 
    $SALT = "62FzFJR4D4";
    $hash_string = '';
    $PAYU_BASE_URL = "https://secure.payu.in";
//  $PAYU_BASE_URL = "https://test.payu.in";
    $action = '';
    $posted = array();
    if(!empty($_POST)) {
      foreach($_POST as $key => $value) {    
        $posted[$key] = $value; 
      }
    }
    
    $userArr=MysqLi_fetch_assoc(MysqLi_query($con,"select * from users where id='$user_id'"));
    
    $formError = 0;
    $posted['txnid']=$txnid;
    $posted['amount']=$total_price;
    $posted['firstname']=$userArr['name'];
    $posted['email']=$userArr['email'];
    $posted['phone']=$userArr['mobile'];
    $posted['productinfo']="productinfo";
    $posted['key']=$MERCHANT_KEY ;
    $hash = '';
    $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'])
             
      ) {
        $formError = 1;
      } else {    
        $hashVaRSSeq = explode('|',$hashSequence);
        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';
    }


    $formHtml ='<form method="post" name="payuForm" id="payuForm" action="'.$action.'"><input type="hidden" name="key" value="'.$MERCHANT_KEY.'" /><input type="hidden" name="hash" value="'.$hash.'"/><input type="hidden" name="txnid" value="'.$posted['txnid'].'" /><input name="amount" type="hidden" value="'.$posted['amount'].'" /><input type="hidden" name="firstname" id="firstname" value="'.$posted['firstname'].'" /><input type="hidden" name="email" id="email" value="'.$posted['email'].'" /><input type="hidden" name="phone" value="'.$posted['phone'].'" /><textarea name="productinfo" style="display:none;">'.$posted['productinfo'].'</textarea><input type="hidden" name="surl" value="'.SITE_PATH.'payment_complete.PHP" /><input type="hidden" name="furl" value="'.SITE_PATH.'payment_fail.PHP"/><input type="submit" style="display:none;"/></form>';
    echo $formHtml;
    echo '<script>document.getElementById("payuForm").submit();</script>';
}else{  
    sentInvoice($con,$order_id);
    ?>
    <script>
        window.location.href='thank_you.PHP';
    </script>
    <?PHP
}   } ?>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)