$str = "update o_auth set remsg='{$remsg_in}',recode='{$ResponseCode}',eci='{$ECI}',dt='{$rehohsn}',trace_no='{$trace_no}',auth='{$ApproveCode}',stast='{$FirstAmt}',staed='{$EachAmt}',rootmemo='{$rootmemo}',red_dan='{$RedeemUsed}',red_yet='{$RedeemBalance}' where sr='{$OrderID}' and amount='{$amount}' and auth='' limit 1 "; mysql_query($str, $plink); //馬上發動要關帳的要求 if ($succ && $OneTm == 'isNOW') { $isdt = date("Ymd"); //取出交易日 $str = "insert into o_close "; //寫入 $str .= "(sr,client,bank,authsr,dt,amount,cardno,auth,trace_no,stat,eci,sps,mid,tid,pesn,glFrom,glTo,glCity,isGuolu,isdt,citylog,dtymd,allsn,cdmk,escrow,nort,bank_stat)"; $str .= " values (0,'{$client}','{$form['bank']}','{$OrderID}','{$hohsn}','{$amount}','','{$ApproveCode}','{$trace_no}','要關帳','{$ECI}','{$OKspsIN}','{$form['mid']}','{$form['tid']}','{$pesn}','{$glFrom}','{$glTo}','{$glCity}','{$isGuolu}','{$isdt}','{$bsb}','{$hohsnYMD}','{$allsn}','{$cdmk}','{$escrow}','{$nort}','要關帳')"; mysql_query($str, $plink); $o_close_sr = mysql_insert_id(); $str = "insert into o_close_bank "; //寫入 $str .= "(sr,client,bank,authsr,dt,amount,cardno,auth,trace_no,stat,eci,sps,mid,tid,pesn,glFrom,glTo,glCity,isGuolu,isdt,citylog,dtymd,allsn,cdmk,escrow,nort,bank_stat,uip)"; $str .= " values ('{$o_close_sr}','{$client}','{$form['bank']}','{$OrderID}','{$hohsn}','{$amount}','','{$ApproveCode}','{$trace_no}','要關帳','{$ECI}','{$OKspsIN}','{$form['mid']}','{$form['tid']}','{$pesn}','{$glFrom}','{$glTo}','{$glCity}','{$isGuolu}','{$isdt}','{$bsb}','{$hohsnYMD}','{$allsn}','{$cdmk}','{$escrow}','{$nort}','立即關帳','{$uip}')"; mysql_query($str, $plink); $strCOS = "update o_auth set trans_date='{$hohsn}' where sr='{$OrderID}' limit 1 "; mysql_query($strCOS, $plink); } //回應 成交1/失敗0*授權單號*金額*訂單編號*授權時間*授權碼*回應碼 $ReTURnTXT = "{$succ}*{$aa}*{$amount}*{$sob}*{$rehohsn}*{$ApproveCode}*{$ResponseCode}"; //寫入o_respones_log 的記錄 include 'g_ssl_echo_log.php'; @setlog($set_type, $client, "萬泰 " . $OrderID . " " . $remsg_in, $uip, $t1); //追縱授權-Step5 授權結束 update $running = number_format(microtime(true) - $t4, 3); @exec_sr_tracer($aa, "step5", $running, "g_ssl_wantai.php", "final", $ResponseCode, $remsg_in); echo $ReTURnTXT; exit; }
$remsg = '資料有誤'; } if ($Cxc[1] == '008' && $Cxc[2] == '14') { $remsg = '無效卡號'; } $str = "update o_auth set remsg='{$remsg}',recode='xx9',rootmemo='{$MeMolog}' where sr='{$Cxc['3']}' and UserPayNub='{$UserPayNub}' limit 1 "; mysql_query($str, $plink); //授權失敗 $payOK = 0; } } } //回應 成交1/失敗0*授權單號*金額*授權碼*回應碼 $ReTURnTXT = "{$payOK}*{$aa}*{$amount}*{$sob}*{$rehohsn}*{$Cxc['2']}*{$Cxc['1']}"; //寫入o_respones_log 的記錄 include 'g_ssl_echo_log.php'; include 'g_mag.inc'; @setlog($set_type, $client, $BankTitel[$form[bank]] . " " . $aa . " " . $response_msg, $uip, $t1); //追縱授權-Step5 授權結束 update $running = number_format(microtime(true) - $t4, 3); if ($Cxc[1] == '') { $Cxc[1] = "---"; } @exec_sr_tracer($aa, "step5", $running, "g_ssl.php", "final", $Cxc[1], $remsg); echo $ReTURnTXT; exit; function setlog($set_type, $client, $msg, $uip, $t1, $step = "end") { $ret = array("File" => "g_ssl.php", "Time" => date("Y-m-d H:i:s"), "Client" => $client, "Echo" => $msg, "UserIP" => $uip, "RunTime" => number_format(microtime(true) - $t1, 3)); @write_log("g_ssl", "Type " . $set_type . " 幕後授權追縱 LOG (" . $step . ")", $ret); }
} echo 'OK'; //寄出郵件管理者 $san_mail = str_replace(' ', '', $form['email']); $kind_nail = split(',', $san_mail); $aacount = count($kind_nail); for ($_e = 0; $_e < $aacount; $_e++) { $vCHOO = substr_count($kind_nail[$_e], '@'); if ($kind_nail[$_e] && $vCHOO > 0) { $RootSOB = '線上刷卡管理者通知函--' . $iswhy; $uitemed_mail = $RootSOB . '<hr>銀聯卡交易回傳通知:<p>'; $uitemed_mail .= "單號: {$OrderID}<p>"; $uitemed_mail .= "金額: {$amount}<p>"; $uitemed_mail .= "時間: {$rehohsn}<p>"; if (!$form['send_root']) { //不是1才寄 //mail($kind_nail[$_e], mb_convert_encoding($RootSOB,"Big5","UTF-8"), mb_convert_encoding($uitemed_mail,"Big5","UTF-8"), "From: gomos2@sunup.net\nMIME-Version: 1.0\nContent-Type: text/html; charset=big5\nContent-Transfer-Encoding: 8bit"); exec_mail(0, $RootSOB, $uitemed_mail, 'form_ssl_Nccc_cup', $kind_nail[$_e]); } } } //exec_mail(2, $RootSOB, $uitemed_mail, 'form_ssl_Nccc_cup'); $ret = array("client" => $Mpisr[client], "Bank" => $Mpisr[bank], "SR" => $OrderID, "Amount" => $amount, "Allsn" => $allsn, "UserIP" => $uip, "RunTime" => number_format(microtime(true) - $t1, 3), "Recode" => $ResponseCode, "Remsg" => $remsg_in); @write_log("form_ssl", "授權追縱 LOG (5) 銀聯-授權結果 form_ssl_Nccc_cup.php", $ret); //追縱授權-Step5 授權結束 update $running = number_format(microtime(true) - $t2, 3); if (!$ResponseCode) { $ResponseCode = "---"; } @exec_sr_tracer($OrderID, "step5", $running, "form_ssl_Nccc_cup.php", "final", $RespCode, $remsg);
<script language="JavaScript"> <!--'; $OU_Page .= "\n\t\t\tdocument.forms['acsForm'].submit();\n\t\t\t// -->\n\t\t\t</script>\n\t\t\t</center>\n\t\t\t</body></head></html>"; $sr = $Cxc[3]; $_SESSION['O_Doit'] = 'A03'; $_SESSION['O_OU_Page'] = $OU_Page; // 寫入轉頁暫存檔 include 'tmp_endPage.php'; $ret = array("client" => $arOrigionAuth[client], "Bank" => $arOrigionAuth[bank], "SR" => $szMerchantTradeNo, "Amount" => $amount, "Allsn" => $szAllsn, "UserIP" => $uip, "RunTime" => number_format(microtime(true) - $t1, 3), "Recode" => $szResponseCode, "Remsg" => $remsg_in, "ROTurlOK" => $szRouteURL); @write_log("form_ssl", "授權追縱 LOG (5) 授權結果(有回傳網址) form_ssl_result.php", $ret); //追縱授權-Step5 授權結束 update $running = number_format(microtime(true) - $t2, 3); if (!$szResponseCode) { $szResponseCode = "---"; } @exec_sr_tracer($szMerchantTradeNo, "step5", $running, "form_ssl_result.php", "final", $szResponseCode, $remsg_in); //若授權流程超過 6 秒, 則發警告信 //2014.12.02 將改檢查 sr_tracer, 不再寄警告信 /* $running_time = number_format(microtime(true)-$t1, 3); if( $running_time > 6){ $title = "銀行".$arOrigionAuth[bank]."授權回傳後的處理時間花費 ".$running_time." 秒"; $msg = "授權單號: $szMerchantTradeNo 授權回傳後的處理時間花費 $running_time 秒<br>"; $msg .= "<hr size=1>於 pay-web 執行的 from_ssl_result.php 執行時間 ".number_format(microtime(true)-$t1, 3)." 秒<br>".date("Y/m/d H:i:s"); exec_mail(2, $title, $msg, 'form_ssl_result'); } */ // 將控制權轉給下支程式 Header("Location:form_ssl_out_N.php?gwsr={$szMerchantTradeNo}&sr={$s_time}&Do=A03&LG={$LG}"); exit; }
@exec_sr_tracer($aa, "step5", $running, "form_ssl_Nccc_auth.php", "final", "---", "發卡行不符"); //將控制權轉給下支程式 Header("Location:form_ssl_out_N.php?sr={$s_time}&Do=A01&LG={$LG}"); exit; } else { if ($Enn == 'e') { $OutPPtextaPPa = 'Bank information is wrong.'; } else { $OutPPtextaPPa = '發卡行不符,請使用符合資格之銀行卡片!'; } $response_msg = $OutPPtextaPPa; $ret = array("client" => $client, "Bank" => $form[bank], "SR" => $aa, "Amount" => $amount, "Allsn" => $allsn, "UserIP" => $uip, "RunTime" => number_format(microtime(true) - $t1, 3)); @write_log("form_ssl", "授權追縱 LOG (END) 聯信分期-發卡行不符 (無回傳網址) form_ssl_Nccc_auth.php", $ret); include 'form_ssl_noan_out.inc'; $running = number_format(microtime(true) - $t3, 3); @exec_sr_tracer($aa, "step5", $running, "form_ssl_Nccc_auth.php", "final", "---", "發卡行不符"); session_destroy(); exit; } } } //9新聯信 10新聯信分期 35萬泰 36萬泰分期的授權通道 if ($form['bank'] == 9 || $form['bank'] == 10 || $form['bank'] == 35 || $form['bank'] == 36) { //銀聯交易的回應接收是 https://credit.allpay.com.tw/form_ssl_Nccc_cup.php //3D交易的回應接收是 https://credit.allpay.com.tw/form_ssl_Nccc.php //一般交易的回應接收是 https://credit.allpay.com.tw/Api/ApiRespone.jsp //TransMode: 0一般,1分期,2紅利 //TransCode: 00授權,01取消 //Install: 分期期數 //PAN: 卡號 //EXPIREDATE: 有效日期
$szSQL .= "(sr,client,bank,authsr,dt,amount,cardno,auth,trace_no,stat,eci,sps,mid,tid,pesn,glFrom,glTo,glCity,isGuolu,isdt,citylog,dtymd,allsn,cdmk,escrow,nort,bank_stat)"; $szSQL .= " VALUES (0,'{$arOrigionAuth['client']}','{$arOrigionAuth['bank']}','{$szMerchantTradeNo}','{$hohsn}','{$arOrigionAuth['amount']}','','{$szApproveCode}','{$szTraceNo}','要關帳','{$szECI}','{$arOrigionAuth['sps']}','{$arUser['mid']}','{$arUser['tid']}','{$arOrigionAuth['pesn']}','{$arOrigionAuth['glFrom']}','{$arOrigionAuth['glTo']}','{$arOrigionAuth['glCity']}','{$arOrigionAuth['isGuolu']}','{$dtmYmd}','{$bsb}','{$hohsnYMD}','{$arOrigionAuth['allsn']}','{$arOrigionAuth['cdmk']}','{$arOrigionAuth['escrow']}','{$nort}','要關帳')"; $rsResult = mysql_query($szSQL, $databaseLink); $o_close_sr = mysql_insert_id(); if (!$rsResult) { $title = "Credit自動關帳執行失敗-g_ssldotNet.php"; $msg = "SQL執行失敗! " . mysql_error() . "<hr size=1>" . $szSQL . "<br>"; $msg .= "<hr size=1>於 pay_web 執行的 g_ssl_dotNet.php 執行時間 " . number_format(microtime(true) - $t1, 3) . " 秒<br>" . date("Y/m/d H:i:s"); exec_mail(2, $title, $msg, 'g_ssl_dotNet.php'); } else { $szSQL = "INSERT INTO o_close_bank "; // 寫入 $szSQL .= "(sr,client,bank,authsr,dt,amount,cardno,auth,trace_no,stat,eci,sps,mid,tid,pesn,glFrom,glTo,glCity,isGuolu,isdt,citylog,dtymd,allsn,cdmk,escrow,nort,bank_stat,uip)"; $szSQL .= " VALUES ('{$o_close_sr}','{$arOrigionAuth['client']}','{$arOrigionAuth['bank']}','{$szMerchantTradeNo}','{$hohsn}','{$arOrigionAuth['amount']}','','{$szApproveCode}','{$szTraceNo}','要關帳','{$szECI}','{$arOrigionAuth['sps']}','{$arUser['mid']}','{$arUser['tid']}','{$arOrigionAuth['pesn']}','{$arOrigionAuth['glFrom']}','{$arOrigionAuth['glTo']}','{$arOrigionAuth['glCity']}','{$arOrigionAuth['isGuolu']}','{$dtmYmd}','{$bsb}','{$hohsnYMD}','{$arOrigionAuth['allsn']}','{$arOrigionAuth['cdmk']}','{$arOrigionAuth['escrow']}','{$nort}','立即關帳','{$uip}')"; mysql_query($szSQL, $databaseLink); } $szSQL = "UPDATE o_auth SET trans_date='{$hohsn}' WHERE sr='{$szMerchantTradeNo}' LIMIT 1 "; mysql_query($szSQL, $databaseLink); } //回應 成交1失敗0*授權單號*金額*訂單編號*授權時間*授權碼*回應碼 $ReTURnTXT = "{$szReturnCode}*{$szMerchantTradeNo}*{$nTradeAmount}*{$sob}*{$szTradeDateTime}*{$szApproveCode}*{$szResponseCode}"; // 寫入o_respones_log 的記錄 include 'g_ssl_echo_log.php'; include 'g_mag.inc'; @setlog($set_type, $client, $BankTitel[$form[bank]] . " " . $aa . " " . $szResponseMessage, $uip, $t1); //追縱授權-Step5 授權結束 update $running = number_format(microtime(true) - $t4, 3); @exec_sr_tracer($aa, "step5", $running, "g_ssl_dotNet.php", "final", $szResponseCode, $szResponseMessage); echo $ReTURnTXT; exit; }
<input type="submit" value="send" style="display:none"> </form> <script language="JavaScript"> <!--'; $OU_Page .= "\n\t\t\tdocument.forms['acsForm'].submit();\n\t\t\t// -->\n\t\t\t</script>\n\t\t\t</center>\n\t\t\t</body></head></html>"; $sr = $OrderID; //可能用不到 $_SESSION['O_Doit'] = 'A03'; $_SESSION['O_OU_Page'] = $OU_Page; //寫入轉頁暫存檔 include 'tmp_endPage.php'; $ret = array("client" => $Mpisr[client], "Bank" => $Mpisr[bank], "SR" => $OrderID, "Amount" => $amount, "Allsn" => $allsn, "UserIP" => $uip, "RunTime" => number_format(microtime(true) - $t1, 3), "Recode" => $ResponseCode, "Remsg" => $remsg_in, "ROTurlOK" => $ROTurlOK, "s_time" => $s_time); @write_log("form_ssl", "授權追縱 LOG (5) 授權結果(有回傳網址) form_ssl_Nccc.php", $ret); //追縱授權-Step5 授權結束 update $running = number_format(microtime(true) - $t3, 3); if (!$ResponseCode) { $ResponseCode = "---"; } @exec_sr_tracer($OrderID, "step5", $running, "form_ssl_Nccc.php", "final", $ResponseCode, $remsg_in); //若授權流程超過 6 秒, 則發警告信 $running_time = number_format(microtime(true) - $t1, 3); if ($running_time > 6) { $title = "銀行" . $Mpisr[bank] . "授權回傳後的處理時間花費 " . $running_time . " 秒"; $msg = "授權單號: {$OrderID} 授權回傳後的處理時間花費 {$running_time} 秒<br>"; $msg .= "<hr size=1>於 pay-web 執行的 from_ssl_Nccc.php 執行時間 " . number_format(microtime(true) - $t1, 3) . " 秒<br>" . date("Y/m/d H:i:s"); exec_mail(2, $title, $msg, 'form_ssl_Nccc'); } //將控制權轉給下支程式 Header("Location:form_ssl_out_N.php?gwsr={$OrderID}&sr={$s_time}&Do=A03&LG={$LG}"); exit; }
if ($card_no != '') { //取年度加密key (記卡號 不記到期日, 末3碼) $strYearABC = "SELECT abcd FROM o_year WHERE year='" . date("Y") . "' limit 1 "; $qqYabc = mysql_query($strYearABC, $plink); $f_Yabc = @mysql_fetch_array($qqYabc); $f6no = substr($card_no, 0, 6); $c5no = substr($card_no, 6, 5); $lsno = substr($card_no, 11, 5); $str = "insert into o_cdno "; //寫入 $str .= "(aa,sr,f6no,c5no,lsno,year_abc)"; $str .= "values(0,'{$aa}',AES_ENCRYPT('{$f6no}','{$key_str_ch}'),AES_ENCRYPT('{$c5no}','{$key_str_ch}'),AES_ENCRYPT('{$lsno}','{$key_str_ch}'),'{$f_Yabc['abcd']}')"; $result = mysql_query($str, $plink); if (!$result) { $title = "Credit建立單號o_cdno-SQL執行失敗(allpay_rt_otp.php)"; $msg = "SQL執行失敗! " . mysql_error() . "<hr size=1>" . $str . "<br>"; $msg .= "<hr size=1>於 pay-web 執行的 allpay_rt_otp.php 執行時間 " . number_format(microtime(true) - $t1, 3) . " 秒<br>" . date("Y/m/d H:i:s"); exec_mail(2, $title, $msg, 'allpay_rt_otp'); echo "ERROR_" . mysql_error(); } } //寫 sr_tracer //追縱授權-Step1 建立單號 insert $t2 = microtime(true); $running = number_format($t2 - $t1, 3); @exec_sr_tracer($aa, "step1", $running, "allpay_rt_otp.php", "insert", $start_time, $form[bank], $allsn); //追縱授權-Step5 授權結束 update $running = number_format(microtime(true) - $t2, 3); @exec_sr_tracer($aa, "step5", $running, "allpay_rt_otp.php", "final", $r_code, $r_msg); echo 'OK'; exit;
$sr = $Cxc[3]; $_SESSION['O_Doit'] = 'A03'; $_SESSION['O_OU_Page'] = $OU_Page; //寫入轉頁暫存檔 include 'tmp_endPage.php'; $ret = array("client" => $client, "Bank" => $form[bank], "SR" => $aa, "Amount" => $amount, "Allsn" => $allsn, "UserIP" => $uip, "RunTime" => number_format(microtime(true) - $t1, 3), "Recode" => $Cxc[1], "Remsg" => $response_msg, "Auth" => $Cxc[2], "ROTurlOK" => $ROTurlOK, "s_time" => $s_time); @write_log("form_ssl", "授權追縱 LOG (5) 授權結果(有回傳網址) form_ssl.php", $ret); //追縱授權-Step5 授權結束 update $running = number_format(microtime(true) - $t4, 3); if ($IS_TEST) { @exec_sr_tracer($Cxc[3], "step5", $running, "form_ssl.php", "final", "xxx", "測試交易"); } else { if (!$Cxc[1]) { $Cxc[1] = "---"; } @exec_sr_tracer($Cxc[3], "step5", $running, "form_ssl.php", "final", $Cxc[1], $remsg); } //若授權流程超過 6 秒, 則發警告信 $running_time = number_format(microtime(true) - $t1, 3); if ($running_time > 6) { $title = "銀行" . $form[bank] . "授權時間花費 " . $running_time . " 秒"; if ($ECI != '') { $title .= " (ECI=" . $ECI . ")"; } $msg = "授權單號: {$aa} 授權完成時間花費 {$running_time} 秒<br>"; $msg .= "<hr size=1>於 pay-web 執行的 from_ssl.php 執行時間 " . number_format(microtime(true) - $t1, 3) . " 秒<br>" . date("Y/m/d H:i:s"); exec_mail(2, $title, $msg, 'form_ssl'); } //超過 30 秒發Line /* if( $running_time > 30 ){
$t2 = microtime(true); $running = number_format($t2 - $t1, 3); @exec_sr_tracer($aa, "step3", $running, "form_ssl_3D.php", "after3d", $ECI); $running = number_format(microtime(true) - $t2, 3); @exec_sr_tracer($aa, "step5", $running, "form_ssl_3D.php", "final", "xxx", "防盜刷保護"); $response_msg = $OutPPtext; include 'form_ssl_noan_out.inc'; exit; } } $ret = array("File" => "授權追縱 LOG (3-2) form_ssl_3D.php", "Time" => date("Y-m-d H:i:s"), "SR" => $aa, "NO3dOnlyOK" => $NO3dOnlyOK, "ch3DxxCityl" => $ch3DxxCity, "City_host_id" => $City_host_id, "Port" => 16688, "UserIP" => $uip, "RunTime" => number_format(microtime(true) - $t1, 3)); @write_log("form_ssl", "STEP 3-2 : 中信3D驗證後送授權前", $ret); //追縱授權-Step3 3D驗證後送授權前 update $t2 = microtime(true); $running = number_format($t2 - $t1, 3); @exec_sr_tracer($aa, "step3", $running, "form_ssl_3D.php", "after3d", $ECI); if (!$NO3dOnlyOK) { //3D only沒有通過的不送授權 if ($form['bank'] == 33 || $form['bank'] == 34) { $CiAPIurl = $XID; } else { $CiAPIurl = $APIbankurl[$form[bank]]; } //if (($Mpisr[red_em] == 'Y') && ($form['bank'] == 7)) { //中信小店,要使用紅利扣點 // $Nch_ProCode = $form[p_co]; //} else { $Nch_ProCode = ''; //} //轉向進入授權 $fp = fsockopen("{$City_host_id}", "16688", $errno, $errstr, 50); //正式上線的,網址IP,PORT,回應代碼,回應訊息,等待時間
<?php //玉山 玉山分期 的授權通道 //2014.09.19 加入sr_tracer記錄 by raleigh /* https://stestcredit.allpay.com.tw/g_ssl.php?*838666*3560684444000225*1603*917*10******over123456*overover** */ if ($form['bank'] == 27 || $form['bank'] == 28) { $expiry_date = $exp; $od_sob = $sob; //玉山 玉山分期 的授權通道 include "form_ssl_esunbank.php"; //追縱授權-Step4 授權結束 update $t4 = microtime(true); $running = number_format($t4 - $t3, 3); @exec_sr_tracer($aa, "step4", $running, "g_ssl_esunbank.php"); //回應 成交1失敗0*授權單號*金額*訂單編號*授權時間*授權碼*回應碼 $ReTURnTXT = "{$succ}*{$aa}*{$amount}*{$sob}*{$rehohsn}*{$Cxc['2']}*{$Cxc['1']}"; //寫入o_respones_log 的記錄 include 'g_ssl_echo_log.php'; @setlog($set_type, $client, "玉山 " . $aa . " " . $response_msg, $uip, $t1); //追縱授權-Step5 授權結束 update $running = number_format(microtime(true) - $t4, 3); @exec_sr_tracer($aa, "step5", $running, "g_ssl_esunbank.php", "final", $Cxc[1], $response_msg); echo $ReTURnTXT; exit; }