在数据库中提交数据后将数据发送到卷曲时出错

时间:2017-11-11 08:10:25

标签: php mysql curl

我希望在将数据提交到数据库之后将数据发布到支付网关api,但是收到错误而不是重定向到api url ...如果任何一个帮助它将会被欣赏。任何人指导我在代码中的错误...数据提交数据库,但当我尝试将此数据发布到网址时,我收到错误,而不是重定向到付款gatway api ..

包括'db-config.php';

$encdata="647569415339326A5A715930594B6530396D4C506B396E434561504D67334678316F514C36556A6F6278303869734F3173316F6C45725775374C357936684A6C6D6C5756752B566C674F46724A534A73686E464953773D3D";
//processPaymentResponse($encdata);
function encodedStringUCOGateWay($data){
    $key = '32423423';
    $realKey = substr($key, 0, 16);
    $padding = pkcs5_pad($data, 16);
    $data .= str_repeat(chr($padding), $padding);
    return strtoupper(bin2hex(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $realKey, $padding, MCRYPT_MODE_ECB))));
}

function pkcs5_pad ($text, $blocksize){
    $pad = $blocksize - (strlen($text) % $blocksize);
    return $text . str_repeat(chr($pad), $pad);
}

function processPaymentResponse($msg){
    $val = $msg;
    $key = 'dfsffsd34234'; 
    $realKey = substr($key, 0, 16);
    $data = base64_decode(hex2bin($val));
    $data = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $realKey, $data, MCRYPT_MODE_ECB);
    $padding = ord($data[strlen($data) - 1]);
    $decodedString = substr($data, 0, -$padding);  
    echo $decodedString;      
    /*  MERCHANT REF NO^UCO PAYMENT SOLUTION REF NO^AMOUNT^TXN STATUS@SELECTED PG REF NO|SELECTED CHANNEL|BANK REF NO|TXN STATUS AT PG
        123456^PG2220000000011^2500.00^SUCCESS@PG123456|EBNK|CBS1234|SUCCESS*/        
    $txnStatus = explode("@",$decodedString);
    $appPayStatus = explode("^",$txnStatus[0]);
    $payGateWayStatus = explode("|",$txnStatus[1]);
    $ausPayRef = $appPayStatus[0];
    $ausUCOPayRefNo = $appPayStatus[1];
    $paiedAmount = $appPayStatus[2];
    $payTxnStatus = $appPayStatus[3];
    $pgRefNo = $payGateWayStatus[0];
    $selectedChennel = $payGateWayStatus[1];
    $bankRefNo = $payGateWayStatus[2];
    $pgTxnStatus = $payGateWayStatus[3];
    $appNo = $_SESSION['app_no'];
    $candidateId = $_SESSION['app_id'];  
}


if(isset($_POST['submit'])){
$name = $_POST['SNAME'];
    $email = $_POST['SEMAILID'];
    $father_name = $_POST['father_name'];
    $admission_number = $_POST['admission_number'];
    $roll_number = $_POST['SRN'];
    $mobile = $_POST['SMOBNO'];
    $mprn = $_POST['MPRN'];
    $mtamt = $_POST['MTAMT'];


    /*$sql = "INSERT INTO `tansaction`(`id`, `student_name`, `father_name`, `roll_number`, `admission_number`, `email`, `phone`, `mprn`, `mtamt`, `status`) VALUES (NULL , '$name', '$father_name' , '$roll_number' , '$admission_number' , '$email' , '$mobile' , '$mprn' , '$mtamt')";*/


    $sql = "INSERT INTO `tansaction`(`student_name`, `father_name`, `roll_number`, `admission_number`, `email`, `phone`, `mprn`, `mtamt`) VALUES ( '$name', '$father_name' , '$roll_number' , '$admission_number' , '$email' , '$mobile' , '$mprn' , '$mtamt')";

     if($result = mysqli_query($conn , "$sql"))
     {

        $url = 'http://uatucoebanking.co.in/LocalBankAwayRetail/sgonHttpHandler.aspx?Action.FCIGATEWAY.ShoppingMall.Login=Y';
$fields = array(
    'SNAME' => urlencode($_POST['SNAME']),
    'SEMAILID' => urlencode($_POST['SEMAILID']),
    'father_name' => urlencode($_POST['father_name']),
    'company' => urlencode($_POST['admission_number']),
    'SRN' => urlencode($_POST['SRN']),
    'SMOBNO' => urlencode($_POST['SMOBNO']),
    'MPRN' => encodedStringUCOGateWay(urlencode($_POST['MPRN'])),
    'MTAMT' => encodedStringUCOGateWay(urlencode($_POST['MTAMT']))
);





//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&'); 
//$query_string = http_build_query($_POST);
//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
//curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $query_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

     }

     else 
     {
     echo "error in query ";
     }

}

编辑:在curl-call上收到错误:
(S(hi03ut553axfeiucxuusckev))/FileNotFound.htm?aspxerrorpath‌​=/LocalBankAwayRetai‌​l/sgonHttpHandler.as‌​px在域名后获取此网址错误...当我尝试发布到api直接形成行动时它的工作但我想通过其他方法发布,因为发布数据需要加密

0 个答案:

没有答案