Payumoney Codeigniter集成
我正在从事CodeIgniter payUmoney集成.我有一个注册表格,从那里可以注册并通过payUmoney付款网关获得付款,并且表格还包含多个选择字段.我需要使用payUmoney付款网关. 因此,请帮助我,如何在CodeIgniter中成功完成交易后将记录插入数据库中??
I am working on CodeIgniter payUmoney integration. I have a registration form from where one registers and get paid with payUmoney payment gateway and form contains multiple select fields also. I need to use the payUmoney payment gateway. So please help me that how can I insert the records into the database after the successful transaction in CodeIgniter.?
实际上这是我的表格.现在,我要提交的表格但是付款成功后.对我来说,有一个小问题,直到付款成功,我将在哪里存储数据.表示我要在成功交易后存储数据.一件事也有多个选择下拉列表,所以请帮助我如何在使用payUmoney进行交易后将数据存储到数据库中.
Actually here is my form. Now, what I want to submit the form but After successful payment. For me a little problem that where will I store the data till payment succeeded. Means I want to store the data after a successful transaction. One thing also there is multiple select drops down also, So please help me how to store the data into the database after a transaction using payUmoney.
最新评论的答案.校验和错误是由于哈希不匹配而发生的.将表单提交到payu/checkout.php后,checkout.php会将表单提交给 https://test. payu.in/_payment (测试网址).
The answer for your latest comment. The checksum error happens due to hash mismatch. after you submit the form to payu/checkout.php, checkout.php will submit a form to https://test.payu.in/_payment (Test url).
在您的payu/checkout.php内部
Inside your payu/checkout.php
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='';
$hashstring = $MERCHANT_KEY . '|' . $txnid . '|' . $grandtotal . '|' . $productinfo . '|'. $fname . '|' . $email .'|'.$udf1.'|' .$udf2.'|' .$udf3.'|'.$udf4.'|'.$udf5.'||||||'. $SALT;
$hash = strtolower(hash('sha512', $hashstring));
$data['hash'] = $hash;
//Loading checkout view
$this->load->view('checkout.php');
}
在checkout.php中,您必须向 https://test.payu.in/_payment ,以及除salt之外我在哈希生成中使用的所有字段.哈希字段也是这种形式.
In the checkout.php you must submit a form to https://test.payu.in/_payment with all the fields I used in the hash generation except salt. The hash field is also in that form.
<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 $grandtotal; ?>" />
<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/fail'); ?>" size="64" />
<input name="curl" type="hidden" value="<?php echo base_url('payu/cancel'); ?>" />
<?php
}
?>
<input type="submit" name="submit_form" value="Click Here for Payment" class="btn btn-info btn-block" >
</form>
有关其他信息,请记住创建一个包含交易ID,金额,时间戳,状态和所有用户信息字段之类的交易表.在交易开始之前,即在payu/checkout功能中,您需要插入此表并启动状态.如果您关心黑客行为,则在检查返回哈希值后,此事务成功更新交易状态字段为成功之后(我检查返回哈希值是因为我入侵了Payumoney网站进行测试,并发现如果不检查返回哈希值,我的假交易将取得成功.)
For extra information remember to create a transaction table with fields like transaction id, amount, timestamp, status and all user's info fields. Before the transaction begins ie in payu/checkout function you need to insert this table with status initiated. After a successful transaction update status field of this transaction to success after checking return hash if you care about hacking( I check return hash because I hacked the payumoney site for testing and find out that if I don't check return hash my fake transaction will be successful. )
public function success()
{
//print_r($_REQUEST);
$status= $this->input->post('status');
if($status =='success')
{
$txnid = $this->input->post('txnid');
$amount = $this->input->post('amount');
$productinfo = $this->input->post('productinfo');
$firstname = $this->input->post('firstname');
$hash = $this->input->post('hash');
$email = $this->input->post('email');
$udf1 = $this->input->post('udf1');
$udf2 = $this->input->post('udf2');
$udf3 = $this->input->post('udf3');
$udf4 = $this->input->post('udf4');
$udf5 = $this->input->post('udf5');
$key = $this->input->post('key');
$SALT ="Your salt";
If (isset($_POST["additionalCharges"]))
{
$additionalCharges=$_POST["additionalCharges"];
$retHashSeq = $additionalCharges.'|'.$SALT . '|' . $status . '|||||||||||' . $email . '|' . $firstname . '|' . $productinfo . '|' . $amount . '|' . $txnid . '|' . $key;
}else{
$retHashSeq = $SALT . '|' . $status . '|||||||||||' .$udf5.'|'.$udf4.'|'.$udf3.'|'.$udf2.'|'.$udf1.'|'. $email . '|' . $firstname . '|' . $productinfo . '|' . $amount . '|' . $txnid . '|' . $key;
}
$rethash = hash("sha512", $retHashSeq);
if ($rethash != $hash)
{
$data['errmsg'] = " Invalid Transaction . Error Occured";
//echo "Return Hash failed";
redirect('payu/err',$data);
}
// now begin your custome code if a transaction is success
}