我想在成功付款后将表单数据保存到数据库中。我在支付网关代码之间插入了insert查询,它存储了支付失败时的数据。我正在使用payumoney网关。这是我的代码,请建议我解决这个问题。
<?php
$MERCHANT_KEY = "";
$SALT = "";
// Merchant Key and Salt as provided by Payu.
//$PAYU_BASE_URL = "https://sandboxsecure.payu.in"; // For Sandbox Mode
$PAYU_BASE_URL = "https://secure.payu.in"; // For Production Mode
$action = '';
$posted = array();
if(!empty($_POST)) {
//print_r($_POST);
foreach($_POST as $key => $value) {
$posted[$key] = $value;
}
}
$formError = 0;
if(empty($posted['txnid'])) {
// Generate random transaction id
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
} else {
$txnid = $posted['txnid'];
}
$hash = '';
// Hash Sequence
$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'])
|| empty($posted['surl'])
|| empty($posted['furl'])
|| empty($posted['service_provider'])
) {
$formError = 1;
} else {
//$posted['productinfo'] = json_encode(json_decode('[{"name":"tutionfee","description":"","value":"500","isRequired":"false"},{"name":"developmentfee","description":"monthly tution fee","value":"1500","isRequired":"false"}]'));
$hashVarsSeq = explode('|', $hashSequence);
$hash_string = '';
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';
date_default_timezone_set('Asia/Kolkata');
$timestamp = date("Y-m-d h:i:s");
$conn = mysqli_connect("localhost","root","","hoysalat_temple");
$result= mysqli_query($conn,"INSERT INTO temp_donor_list(`donor_name`, `email`, `donor_no`, `amount`, `date_time`,`cuid`,`web_user_id`) VALUES ('".$posted['firstname']."', '".$posted['email']."', '".$posted['phone']."', '".$posted['amount']."','".$timestamp."','".$uniqeid."','".$uniqeid."')");
}
} elseif(!empty($posted['hash'])) {
$hash = $posted['hash'];
$action = $PAYU_BASE_URL . '/_payment';
}
?>
1条答案
按热度按时间kx1ctssn1#
您应该在下面提到成功或失败的url名称文件:
创建sucess.php文件并在success.php文件中编写查询。创建failure.php文件并根据需要编写消息。