查看文件: esafepay.php
大小: 18.29 KB
类型: application/octet-stream
<?php require_once('../Connections/BE2.php'); ?> <? if ((isset($_POST["MM_pay"])) && ($_POST["MM_pay"] == "pay")) { /* Big5:https://ssl.smse.com.tw/ezpos/mtmk.asp UTF-8:https://ssl.smse.com.tw/ezpos/mtmk_utf.asp 測試階段請以下列位置接連結使用 Big5:https://ssl.smse.com.tw/ezpos_test/mtmk.asp UTF-8:https://ssl.smse.com.tw/ezpos_test/mtmk_utf.asp */ $fp = fopen("/www/vm3/guest/alert.txt", "a"); fwrite($fp,"start smilepay pay " .date('Y-m-d H:i:s')."\r\n"); $sha1key1=sha1(date('YmdHis')); $sha1key2 =substr($sha1key1,1,12); //.sprintf("%06d",$_SESSION['login_id']) //insert into temp file mysql_select_db($database_BE2, $BE2); $insert_buymaster = sprintf("insert into smilebuytmp (payid,paymode,payval,paydate,paystate,paykey) VALUES ('%s','%s','%s','%s','%s','%s')",$_SESSION['login_id'],$_POST["Pay_zg"],$_POST["Amount"],date('Y-m-d H:i:s'),0,$sha1key2); // fwrite($fp,"step 1 : insert smilepay pay: " .$insert_buymaster."\r\n"); mysql_query($insert_buymaster, $BE2) or die(mysql_error()); $d= date('Ymd'); mysql_select_db($database_BE2, $BE2); $qrcode = sprintf("select paycode from smilebuytmp WHERE paycode like '%s' order by paycode desc limit 1",$d."%"); // fwrite($fp,"step 2 : found smilepay paycode: " .$qrcode."\r\n"); $Rbm = mysql_query($qrcode, $BE2) or die(mysql_error()); $row_Rbm = mysql_fetch_assoc($Rbm); $totalRows_Rbm = mysql_num_rows($Rbm); // 0建立 1登錄 2失效 if($totalRows_Rbm==0){ $barcode= $d.'00001' ;} else{ $s1=substr($row_Rbm['paycode'],8); $barcode = $d.sprintf('%05d',($s1+1)); } mysql_free_result($Rbm); mysql_select_db($database_BE2, $BE2); $updateSQL = sprintf("update smilebuytmp set paycode ='%s' WHERE payid='%s' AND paykey='%s'",$barcode,$_SESSION['login_id'],$sha1key2); // fwrite($fp,"step 3 : updateSQL smilepay paycode: " .$updateSQL."\r\n"); mysql_query($updateSQL, $BE2) or die(mysql_error()); //執行取號動作 $buyindexcode=$sha1key2.sprintf("%06d",$_SESSION['login_id']) ; // fwrite($fp,"step 4 : 繳費資料已建立等待繳費中: "."\r\n"); $error="繳費資料已建立等待繳費中"; $errcode=1; $SmilePayNO=''; $payNo ="" ; if( $_POST["Pay_zg"]<100){ $_REQUEST['Dcvc']="8808"; // 商家代號 $_REQUEST['Rvg2c']="1"; //參數碼 $_REQUEST['Verify_key']="133A43828AF58CF64AC11033D30BC58F"; // 檢查碼 // $_REQUEST['Pay_gdry']="TW"; // $_REQUEST['Od_sob']="澤宇生技產品"; // 消費項目 if($_POST["Pay_zg"]==1){ $_REQUEST['Roturl']="https://www.zeyubio.com/guest/smileresponsecard.php"; // 交易完成後要回送的位置 }else{ $_REQUEST['Roturl']="https://www.zeyubio.com/guest/smileresponse.php"; // 交易完成後要回送的位 } $_REQUEST['Data_id']=$buyindexcode; // 訂單號碼 orderid $_REQUEST['Pur_name']=$_POST["username2"]; ; // 購買人姓名 $_REQUEST['Mobile_number']=$_POST["htel"]; // 聯絡電話 $_REQUEST['Email']=$_POST["email"]; // 電子信箱 $_REQUEST['Pay_zg']=$_POST["Pay_zg"]; //收費模式 $_REQUEST['Amount']=$_POST["Amount"]; // 應付費金額 $_REQUEST['Remark']=""; $_REQUEST['Deadline_date']=date('Y/m/d',time()+86400*2); $_REQUEST['Deadline_time']=""; $_REQUEST['Address']=""; $_REQUEST['Invoice_name']=""; $_REQUEST['Invoice_num']=""; $_REQUEST['Tel_number']=""; //讀取傳送內容 $postData = "Dcvc=".$_REQUEST['Dcvc']; $postData .= "&Rvg2c=".$_REQUEST['Rvg2c']; $postData .= "&Verify_key=".$_REQUEST['Verify_key']; $postData .= "&Od_sob=".$_REQUEST['Od_sob']; $postData .= "&Pay_zg=".$_REQUEST['Pay_zg']; $postData .= "&Data_id=".$_REQUEST['Data_id']; $postData .= "&Deadline_date=".$_REQUEST['Deadline_date'];//非必填 $postData .= "&Deadline_time=".$_REQUEST['Deadline_time'];//非必填 $postData .= "&Amount=".$_REQUEST['Amount']; $postData .= "&Pur_name=".$_REQUEST['Pur_name']; $postData .= "&Tel_number=".$_REQUEST['Tel_number'];//非必填 $postData .= "&Mobile_number=".$_REQUEST['Mobile_number']; $postData .= "&Address=".$_REQUEST['Address'];//非必填 $postData .= "&Email=".$_REQUEST['Email']; $postData .= "&Remark=".$_REQUEST['Remark']; $postData .= "&Invoice_name=".$_REQUEST['Invoice_name'];//非必填 $postData .= "&Invoice_num=".$_REQUEST['Invoice_num'];//非必填 $postData .= "&Roturl=".$_REQUEST['Roturl']; $ch = curl_init(); if($_POST["Pay_zg"]==1){ // 信用卡 ?> <script>location.href = 'https://ssl.smse.com.tw/pay/pay_a_utf.asp?<?= $postData ?>';</script> <? // curl_setopt($ch, CURLOPT_URL, "https://ssl.smse.com.tw/pay/pay_a_utf.asp"); }else{ // 7-11 curl_setopt($ch, CURLOPT_URL, "https://ssl.smse.com.tw/api/SPPayment.asp"); } // curl_setopt($ch, CURLOPT_URL, "https://www.zeyubio.com/guest/mypay.php"); // curl_setopt($ch, CURLOPT_URL, "https://www.zeyubio.com/guest/smileresponse.php"); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); $string = curl_exec($ch); curl_close($ch); // fwrite($fp,$string ."\r\n"); $xml = simplexml_load_string($string); $errcode=$xml->Status; //fwrite($fp,$updatesql." \r\n"); //14 AtmNo 虛擬帳號 // IbonNo Ibon繳費代碼 // FamiNO 全家繳費代碼 //3 AtmBankNo 銀行代號 //fwrite($fp,"ERR: >".$errcode ."< \r\n"); if( $errcode=="1") { $SmilePayNO=$xml->SmilePayNO; if($_POST["Pay_zg"]==2){ $payNo= $xml->AtmNo; // AtmNo 虛擬帳號 } else if($_POST["Pay_zg"]==4){ $payNo= $xml->IbonNo; // IbonNo Ibon繳費代碼 } else if($_POST["Pay_zg"]==6){ $payNo= $xml->FamiNO; // FamiNO 全家繳費代碼 } } else { switch($errcode){ case "-2001":$error="無參數碼及商家代號錯誤";break; case "-2002":$error="檢查碼錯誤";break; case "-2003":$error="無付款模式";break; case "-2004":$error="日期格式錯誤";break; case "-2005":$error="無交易金額";break; case "-3001":$error="無此商家代號";break; case "-3002":$error="商家使用期限已到期";break; case "-3003":$error="無提供此付款方式";break; case "-3004":$error="超過付款模式設定金額";break; case "-4000":$error="此銀行不提供 ATM 帳號";break; case "-4001":$error="超商代碼取號錯誤";break; case "-4002":$error="簡訊服務忙錄中";break; case "-4003":$error="ibon 服務忙錄中";break; case "-4004":$error="Fami 服務忙錄中";break; case "-4005":$error="簡訊餘額不足";break; case "-5000":$error="Smse 執行錯誤";break; case "-5001":$error="ibon 執行錯誤";break; case "-5002":$error="fami 執行錯誤";break; case "-6001":$error="Payment error";break; default:$error="金流正在維護中,請稍後再試。";break; } } } // ssl.smse.com.tw pay else if( $_POST["Pay_zg"]==201){ $_REQUEST['e_orderno']= $barcode ;// //訂單號碼 orderid $_REQUEST['e_url']="https://www.zeyubio.com/guest/gomypayresponse.php"; //回傳網址 $_REQUEST['e_backend_url']=""; //對帳網址 $_REQUEST['e_no']= "50945566" ; //商店代號 $_REQUEST['e_storename']="澤宇生技"; //商店名稱 $_REQUEST['e_Lang']="BIG5"; //語言 $_REQUEST['e_Cur']="NT" ;//支付幣別 $_REQUEST['e_money']=$_POST["Amount"]; //交易金額 // e_orderno=201209030001 // e_no=0000000101 // e_money=30 // 客戶資料中的驗證密碼=e234567890 $str_check=md5($barcode."50945566".$_POST["Amount"]."50945566a"); $_REQUEST['str_check']=$str_check; $_REQUEST['e_name']=$_POST["username2"]; $_REQUEST['e_telm']=$_POST["htel"]; $_REQUEST['e_email']=$_POST["email"]; $_REQUEST['e_info']="澤宇生技產品"; //讀取傳送內容 $postData = "e_orderno=".$_REQUEST['e_orderno']; $postData .= "&e_url=".$_REQUEST['e_url']; $postData .= "&e_backend_url=".$_REQUEST['e_backend_url']; $postData .= "&e_no=".$_REQUEST['e_no']; $postData .= "&e_storename=".$_REQUEST['e_storename']; $postData .= "&e_Lang=".$_REQUEST['e_Lang']; $postData .= "&e_Cur=".$_REQUEST['e_Cur']; $postData .= "&e_money=".$_REQUEST['e_money']; $postData .= "&str_check=".$_REQUEST['str_check']; $postData .= "&e_name=".$_REQUEST['e_name']; $postData .= "&e_telm=".$_REQUEST['e_telm']; $postData .= "&e_email=".$_REQUEST['e_email']; $postData .= "&e_info=".$_REQUEST['e_info']; $ch = curl_init(); // 信用卡 ?> <script>location.href = 'https://gomypay.asia/Shopping/creditpay.asp?<?= $postData ?>';</script> <? exit; } // Gomypay pay else if( $_POST["Pay_zg"]==301){ /* 商家編號 1604000006 Key zBaw7bzzD8K1THSGoIbev08xEJp5yzyeuv1MWJDR2L0= IV YeQInQjfelvkBcWuyhWDAw== */ $returnURL='https://www.zeyubio.com/guest/yipayresponse.php'; $cancelURL='https://www.zeyubio.com/guest/storedvalue.html'; // 測試串接資料 // $merchantId='1604000006'; // define('KEY', 'zBaw7bzzD8K1THSGoIbev08xEJp5yzyeuv1MWJDR2L0='); // define('IV', 'YeQInQjfelvkBcWuyhWDAw=='); // $posturl='https://gateway-test.yipay.com.tw/payment '; /** * 乙禾網絡金流串接 AES 加密範例 */ define('CIPHER_METHOD', 'AES-256-CBC'); // 真實串接資料 $merchantId='1904000019'; define('KEY', 'uD8F81duOKEt31Ux0hmrqdv7e061No4GHsEEUohF7qA='); define('IV', 'fBHeAnan33nBXNwJ03+WMg=='); $posturl='https://gateway.yipay.com.tw/payment'; // // 請替換為商家加密 Key // 請替換為商家加密 Key // 請替換為商家加密 IV $key = base64_decode(KEY); $iv = base64_decode(IV); $param = array( 'merchantId' => $merchantId, 'amount' => $_POST["Amount"], 'orderNo' => $barcode, 'returnURL' => $returnURL, 'cancelURL' => $cancelURL, 'backgroundURL' => '' ); $data = json_encode($param, JSON_FORCE_OBJECT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); // 加密方式 1 $encryptedString = openssl_encrypt($data, CIPHER_METHOD, $key, 0, $iv); $str_check=sha1($encryptedString); // https://gateway.yipay.com.tw/payment // https://gateway-test.yipay.com.tw/payment ?> <form id="myForm" action="<?= $posturl; ?>" method="post"> <input type="hidden" name="orderNo" value="<?= $barcode; ?>"> <input type="hidden" name="returnURL" value="<?= $returnURL; ?>"> <input type="hidden" name="merchantId" value="<?= $merchantId; ?>"> <input type="hidden" name="amount" value="<?= $_POST["Amount"] ;?>"> <input type="hidden" name="type" value="1"> <input type="hidden" name="orderDescription" value="澤宇生技產品"> <input type="hidden" name="checkCode" value="<?= $str_check ?>"> <input type="hidden" name="cancelURL" value="<?= $cancelURL ?>"> <input type="hidden" name="backgroundURL" value=""> </form> <script type="text/javascript"> document.getElementById('myForm').submit();</script> <? exit; } // Yipay pay fwrite($fp,$errcode ." \r\n"); fclose($fp); mysql_select_db($database_BE2, $BE2); $updatesql=sprintf("UPDATE smilebuytmp set msg='%s', SmilePayNO='%s',PayNO='%s' WHERE payid='%s' AND paykey='%s'",$error,$SmilePayNO,$payNo,$_SESSION['login_id'], $sha1key2); //fwrite($fp,$updatesql." \r\n"); mysql_query($updatesql, $BE2) or die(mysql_error()); //fclose($fp); echo "<script>alert('".$error."');location.href = './storedvalue_list.html';</script>"; } //101,102, //"公司櫃枱現金繳款","直接匯款", //$paymode=array(101,102,4,6,10,1,11,2,21); //$paydoc=array("公司櫃枱現金繳款","直接匯款","7-11 ibon","全家 FamiPort","萊爾富 LifeET","線上刷卡","銀聯卡","虛擬帳號","臺灣銀行線上轉帳"); mysql_select_db($database_BE2, $BE2); $query_Rt1 = sprintf("SELECT * FROM nuser WHERE id ='%s'" ,$_SESSION['login_id']); $Rt1 = mysql_query($query_Rt1, $BE2) or die(mysql_error()); $row_Rt1 = mysql_fetch_assoc($Rt1); $totalRows_Rt1 = mysql_num_rows($Rt1); mysql_select_db($database_BE2, $BE2); $query_Rtf = "SELECT * FROM paymode where pd5='Y' order by pd4"; $Rtf = mysql_query($query_Rtf, $BE2) or die(mysql_error()); $row_Rtf = mysql_fetch_assoc($Rtf); $totalRows_Rtf = mysql_num_rows($Rtf); ?> <!-- start: Content --> <div class="main "> <div class="row"> <div class="col-lg-12"> <h3 class="page-header"><i class="fa fa-usd"></i>財務中心</h3> <ol class="breadcrumb"> <li><i class="fa fa-home"></i><a href="index.html">首頁</a></li> <li><i class="fa fa-usd"></i><a href="#">財務中心</a></li> <li><i class="fa fa-sign-in"></i>申請充值</li> </ol> </div> </div> <form name="form" action="storedvalue.html" method="POST" onSubmit="return checkpayform(this.form);"> <div class="row"> <div class="col-lg-12"> <div class="panel panel-info"> <div class="panel-heading"> <h2><i class="fa fa-sign-in red"></i><strong>申請充值</strong></h2> </div> <div class="panel-body"> <div style="overflow:scroll;"> <table class="table table-striped table-bordered" id="example" style="min-width:1200px;"> <tr class="replace-inputs"> <td width="20%">會員帳號:</td> <td width="80%"><input name="username" type="text" class="form-control" id="username" value="<?= $row_Rt1['username'] ;?>" readonly="readonly" /></td> </tr> <tr> <td>會員姓名:</td> <td><input name="username2" type="text" class="form-control" id="username2" value="<?= $row_Rt1['username2'] ;?>" readonly="readonly" /></td> </tr> <tr> <td height="22">行動電話:</td> <td><input name="htel" type="text" class="form-control" id="htel" value="<?= $row_Rt1['htel']?>" readonly="readonly" /> <input name="addr" type="hidden" class="form-control" id="addr" value="<?= $row_Rt1['addr']?>" readonly="readonly" /> <input name="email" type="hidden" class="form-control" id="email" value="<?= $row_Rt1['email']?>" readonly="readonly" /></td> </tr> <tr> <td>充值金額<font color="red"> *</font></td> <td><input type="text" id="Amount" name="Amount" class="form-control" placeholder=""></td> </tr> <tr> <td height="43">付款方式<font color="red"> *</font></td> <td><label class="control-label">請選擇一種繳費方式:</label> <div class="controls"><span style="clear:both"> <select id="Pay_zg" name="Pay_zg" class="form-control" size="1"> <?php do { ?> <option value="<?= $row_Rtf['pd2'] ?>" <? if($row_Rtf['pd2']==101){ echo 'selected="selected"' ;}?>><?= $row_Rtf['pd3'] ?></option> <? } while ($row_Rtf = mysql_fetch_assoc($Rtf)); ?> </select> </span></div> </td> </tr> <tr> <td>注意事項<font color="red"> *</font></td> <td> <ol> <li>超商代碼繳款每筆【最低1000元、最高NT20,000元】,繳款期限為申請日隔一日23:59:59為止。繳費完成系統自動入帳。</li> <li><p>虛擬帳號繳費/匯款【最低1000元、最高NT450,000元】<br> (使用WebATM或櫃員機<font color="#009933">【轉帳】</font>時最高付費金額不得超過30000元 ) (如超過30000 元時,使用WebATM或櫃員機必須使用機<font color="#009933">【繳費】</font>模式 ) PS:並不是所有銀行之WebATM或櫃員機都有繳費模式。繳費完成系統自動入帳。</p> <p><center><img src="assets/img/ATM.jpg" alt="ATM繳費" width="80%" class="img-thumbnail"></center></p></li> <li>公司銀行帳號轉帳/匯款,繳款完成請於會員後台<font color="red">財務中心→充值記錄</font>上傳繳款單據。 <p><center><img src="assets/img/ATM_1.jpg" alt="ATM繳費" width="80%" class="img-thumbnail"></center></p></li> <li><font color="red">請注意,充值申請繳費完成後即無法申請退款。</font></li> </ol> </td> </tr> </table> </div> <div class="actions"> <button type="submit" class="btn btn-success">送出申請充值</button> <span class="form-actions"> <input name="MM_pay" type="hidden" id="MM_pay" value="pay" /> </span> </div> </div> </div> </div><!--/row--></div> </form> <!-- end: Content --> <br><br><br> </div><!--/container--> <script language="javascript"> function checkpayform(){ var ck=true; var s=''; var pay = $("#Amount").val(); //推薦人編號 if( ival(pay) <50 ) { s = '請確認金額... '; ck =false; alert(s); return ck; } return ck; } function ival(num){ var num=parseFloat(num); if(isNaN(num)) return 0; return num; } </script> <?php mysql_free_result($Rt1); mysql_free_result($Rtf); ?>
保存
取消
返回文件列表