2017-02-11 47 views
0

我正在codeigniter和集成payumeoney支付網關。在這裏我有一個註冊表單,並在表單中有各種領域現在我在做什麼我想要添加payumoney支付網關,但問題是,當我添加從我自己寫入fname或金額它工作正常,但是當我使用$這個 - >輸入 - >後( 'FIRST_NAME')它顯示錯誤,如以下 click to view the image (Here is the error in the image)Payumoney錯誤,同時集成codeigniter

下面是數據變量 the values for data array

我的代碼如下:

function checkout() { 
     $this->load->config('payu'); 
     $MERCHANT_KEY = $this->config->item('MERCHANT_KEY'); 
     $SALT = $this->config->item('SALT'); 
     $PAYU_BASE_URL = $this->config->item('PAYU_BASE_URL'); 
     $action = ''; 
     $txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20); 

     $udf1 = ''; 
     $udf2 = ''; 
     $udf3 = ''; 
     $udf4 = ''; 
     $udf5 = ''; 
     $amount = $this->input->post('corporate_plan_rate'); 
     $productinfo = 'test'; 
     $fname = $this->input->post('user_name'); 
     $email = $this->input->post('user_email'); 


     $data = array(
      'mkey' => $MERCHANT_KEY, 
      'tid' => $txnid, 
      'MERCHANT_KEY'=>$MERCHANT_KEY, 
      'txnid'=>$txnid, 
      'SALT'=>$SALT, 
//   'hash' => $hash, 
      'amount' => $amount, 
      'pinfo' => $productinfo, 
      'name' => $fname, 
      'productinfo'=>$productinfo, 
      'mailid' => $email, 
      'phoneno' => '9646403748', 
      'udf1' => $udf1, 
      'udf2' => $udf2, 
      'udf3' => $udf3, 
      'udf4' => $udf4, 
      'udf5' => $udf5, 
     ); 

     $this->load->view('payu/checkout.php', $data); 
    } 

,這裏是我的查看頁面:

<html> 
    <head> 
     <!--<script src="//code.jquery.com/jquery.min.js"></script>--> 
     <script> 
//   $(function() { 
//    setTimeout(function() { 
//     $('form').submit(); 
//    }, 2000) 
//   }); 
     </script> 
    </head> 
    <body> 
     <?php 
     $hashstring = $MERCHANT_KEY . '|' . $txnid . '|' . $amount . '|' . $productinfo . '|' . $name . '|' . $mailid . '|' . $udf1 . '|' . $udf2 . '|' . $udf3 . '|' . $udf4 . '|' . $udf5 . '||||||' . $SALT; 

     $hash = strtolower(hash('sha512', $hashstring)); 
     ?> 
     <h2>PayU Form</h2> 
     <br/> 
     <form method="post" name="payuForm" action="https://test.payu.in/_payment"> 

      <input name="key" type="hidden" value="<?php echo $mkey ?>" /> 
      <input name="txnid" type="hidden" value="<?php echo $tid ?>" /> 
      <input type="hidden" name="hash" value="<?php echo $hash ?>"/> 

      <input name="amount" type="hidden" value="<?php echo $amount; ?>" /> 

      <input name="productinfo" type="hidden" value="<?php echo $pinfo; ?>"> 

      <input type="hidden" name="service_provider" value="payu_paisa" size="64" /> 
      <input name="udf1" type="hidden" value=""> 
      <input name="udf2" type="hidden" value=""> 
      <input name="udf3" type="hidden" value=""> 
      <input name="udf4" type="hidden" value=""> 
      <input name="udf5" type="hidden" value=""> 

      <input name="firstname" id="firstname" type="hidden" value="<?php echo $name; ?>"/> 

      <input name="email" id="email" type="hidden" value='<?php echo $mailid; ?>'> 

      <input name="phone" type="hidden" value="<?php echo $phoneno; ?>"> 
      <input name="surl" type="hidden" value="<?php echo base_url('payu/success'); ?>" size="64" /> 
      <input name="furl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" size="64" /> 
      <input name="curl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" /> 

      <input type="submit" name="submit_form" value="Click Here for Payment" class="btn btn-info btn-block" > 
     </form> 
    </body> 
</html> 

請幫我找出問題並解決它..感謝名單

+0

當我在測試網址中使用原始商戶密鑰和鹽時,我從payumoney方得到了同樣的錯誤消息。所以我強烈建議你重新檢查你的商家密鑰和鹽。如果這不是你的問題,你可以發佈print_r($ data)值和問題。如果您希望發佈,您可以刪除商家密鑰,鹽和其他敏感信息。 –

+0

好吧,只用於測試帳戶。所以我發佈了$ data –

+0

嗨,詹姆斯我已經添加了print_r($ data)。請檢查我正在使用codeiginter –

回答

0

請完整下面的代碼替換

控制器功能
function checkout() 
{ 

     $MERCHANT_KEY = "enter your test merchant key here"; 
     $SALT = "enter your test salt here"; 

     $txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20); 

     $udf1 = ''; 
     $udf2 = ''; 
     $udf3 = ''; 
     $udf4 = ''; 
     $udf5 = ''; 
     $amount = $this->input->post('corporate_plan_rate'); 
     $productinfo = 'test_payment'; 
     $fname = $this->input->post('user_name'); 
     $email = $this->input->post('user_email'); 

     $hashstring = $MERCHANT_KEY . '|' . $txnid . '|' . $amount . '|' . $productinfo . '|'. $fname . '|' . $email .'|'.$udf1.'|' .$udf2.'|' .$udf3.'|'.$udf4.'|'.$udf5.'||||||'. $SALT; 

     $hash = strtolower(hash('sha512', $hashstring)); 

     $data = array(
      'mkey' => $MERCHANT_KEY, 
      'tid' => $txnid, 
      'hash' => $hash, 
      'amount' => $amount, 
      'pinfo' => $productinfo, 
      'name' => $fname, 
      'productinfo'=>$productinfo, 
      'mailid' => $email, 
      'phoneno' => '9646403748', 
     ); 

     $this->load->view('payu/checkout', $data); 
} 

現在完全替換以下代碼結帳視圖文件

<html> 
    <head> 
    </head> 
    <body> 

     <h2>PayU Form</h2> 
     <br/> 
     <form method="post" name="payuForm" action="https://test.payu.in/_payment"> 

      <input name="key" type="hidden" value="<?php echo $mkey ?>" /> 
      <input name="txnid" type="hidden" value="<?php echo $tid ?>" /> 
      <input type="hidden" name="hash" value="<?php echo $hash ?>"/> 

      <input name="amount" type="hidden" value="<?php echo $amount; ?>" /> 

      <input name="productinfo" type="hidden" value="<?php echo $pinfo; ?>"> 

      <input type="hidden" name="service_provider" value="payu_paisa" size="64" /> 
      <input name="udf1" type="hidden" value=""> 
      <input name="udf2" type="hidden" value=""> 
      <input name="udf3" type="hidden" value=""> 
      <input name="udf4" type="hidden" value=""> 
      <input name="udf5" type="hidden" value=""> 

      <input name="firstname" id="firstname" type="hidden" value="<?php echo $name; ?>"/> 

      <input name="email" id="email" type="hidden" value='<?php echo $mailid; ?>'> 

      <input name="phone" type="hidden" value="<?php echo $phoneno; ?>"> 

      <input name="surl" type="hidden" value="<?php echo base_url('payu/success'); ?>" size="64" /> 
      <input name="furl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" size="64" /> 
      <input name="curl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" /> 

      <input type="submit" name="submit_form" value="Click Here for Payment" class="btn btn-info btn-block" > 
     </form> 
    </body> 
</html> 

請嘗試上面的代碼,而不添加任何您自己的代碼進行測試,如果下面的註釋也會出現同樣的錯誤

+0

是同樣的問題發生。一些我的代碼運行但最多不能運行。我不明白是什麼問題。 –

+0

其實我在做什麼,我有一個註冊表單和用戶填寫表單,然後表單提交到結帳方法,並首先所有的表單字段被插入到數據庫中,然後所有的職位領域完成像上述。然後重定向到支付網關等等。有時我在$ this-> input-> post('corporate_plan_rate')地方手動輸入控制器中的金額值,它以前爲我工作過1次。但相同的代碼現在不起作用。所以請解決問題。代碼在覈心php代碼中運行良好。 Thanx –

+0

@BirendraSingh所以如果你手動輸入$ amount,$ fname和$ email的值,上面的代碼工作正常嗎?我在測試CodeIgniter項目中使用我的測試鹽和鍵測試上述代碼,它對我來說工作正常。請致電payumoney支持人員,確保您的測試鹽和鑰匙正常工作並正確無誤。 –