
我正在从事CodeIgniter payUmoney集成的工作。我有一个注册表,从那里注册,并获得与payUmoney支付网关付款,表单也包含多个选择字段。我需要使用payUmoney支付网关。所以请告诉我,在CodeIgniter交易成功后,如何将记录插入到数据库中?
实际上,这是我的表格。现在,我想提交的表单,但成功付款后。对于我来说,一个小问题,我将在哪里存储数据,直到付款成功。意味着我想在一次成功的交易后存储数据。还有一件事,也有多个选择下拉,所以请告诉我如何将数据存储到数据库后,使用payUmoney的交易。
发布于 2017-02-05 20:13:25
你最新评论的答案。校验和错误是由于散列不匹配造成的。在你将表单提交到payu/checkout.php之后,checkout.php会向https://test.payu.in/_payment (测试网址)提交一份表单。
在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之外的所有字段。散列字段也是这种形式。
<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功能中,你需要插入这个状态为initiated的表格。成功的交易后,更新此交易的状态字段为成功后,检查返回散列,如果你关心黑客攻击(我检查返回散列,因为我黑客支付网站进行测试,并发现如果我没有检查返回散列,我的假交易将成功。)
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
}https://stackoverflow.com/questions/41912322
复制相似问题