我正在开发codeigniter并整合payumoney支付网关。在这里,我有一个注册表格,表格中有各种字段现在我正在做什么我想添加payumoney支付网关,但问题是当我添加写自己的fname或金额,它工作正常,但我使用$ this-> input-> post('first_name')它显示如下错误 click to view the image (Here is the error in the image)
这是数据变量 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>
请帮我找出问题并解决.. Thanx
答案 0 :(得分: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>
请尝试上面的代码而不添加任何自己的代码进行测试,如果发生同样的错误,请在下面注释。