//作者主页:?https://www.bz80.com namespace Index\Controller;
class PayController extends BaseController {
//发起支付 查询订单 public function index() {
switch ($_REQUEST['fxaction']) { case 'orderquery': $buffer = SL('Pay/payQuery', $_REQUEST); if ($buffer[0] == 1) { $reback = $buffer[1]; } else { $reback = array( 'fxstatus' => 0, 'error' => $buffer[1]); } break; default:
$buffer = SL('Pay/payApi', $_REQUEST);
$reback = array(); if ($buffer[0] == 1) { $reback = array( 'status' => 1, 'payurl' => $buffer[1]); if($_REQUEST['fxnoback']==1){ header('location:'.$buffer[1]); exit(); } } else { $reback = array( 'status' => 0, 'error' => $buffer[1]); if($_REQUEST['fxnoback']==1){ $this->reBack($buffer,1); exit(); } } break; }
$this->ajaxBack($reback); }
//异步返回 public function notify() {
$_REQUEST= array_merge($_REQUEST,$_POST); $xml = $GLOBALS['HTTP_RAW_POST_DATA']; file_put_contents('./test.txt',$xml."\r\n".serialize($_GET)."\r\n".serialize($_POST)."\r\n",FILE_APPEND); foreach ($_REQUEST as $i => $iBuffer) { if (strstr(strtolower($i), '/pay/notify')) { $action = str_replace('/pay/notify/', '', strtolower($i));
} } if (empty($action)) { $i = strtolower($_SERVER['REQUEST_URI']); $i = explode('?', $i); $action = str_replace('/pay/notify/', '', $i[0]); }
$tmp=explode('/',$action);
$action=$tmp[0]; if(empty($action)){ //exit('action error'); $action = 'Usdt'; } $buffer = SA(ucfirst($action) . '/notify', $_REQUEST); var_dump($buffer); exit($buffer[1]); //success }
//同步返回 public function backurl() { foreach ($_REQUEST as $i => $iBuffer) { if (strstr(strtolower($i), '/pay/backurl')) { $action = str_replace('/pay/backurl/', '', strtolower($i)); } } if (empty($action)) { $i = strtolower($_SERVER['REQUEST_URI']); $i = explode('?', $i); $action = str_replace('/pay/backurl/', '', $i[0]); }
$tmp=explode('/',$action); $action=$tmp[0]; if(empty($action)){ exit('action error'); }
$buffer = SA(ucfirst($action) . '/backurl', $_REQUEST); if($buffer[0]==1){ header('Location:' . $buffer[1]); //跳转 }else{ $this->reback($buffer); } exit(); }
/** * 公众号类H5支付 */ public function jsapi() { $buffer = SA(ucfirst($_REQUEST['style']))->jsapi($_REQUEST); $this->reback($buffer, 1); }
/** * 跳转 */ public function go() { $http = $_GET['u']; if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) { header("Content-type: text/html; charset=utf-8"); exit('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>请使用浏览器打开。'); }else{ exit('<script>location.href="' . $http . '";</script>'); } }
/** * 提交 */ public function formpost() { $http = $_GET; $tjurl = $http['wg']; unset($http['wg']); header("Content-type: text/html; charset=utf-8"); $str = '<form id="Form1" name="Form1" method="post" action="' . $tjurl . '">'; foreach ($http as $key => $val) { if ($val==='') continue; $str = $str . '<input type="hidden" name="' . $key . '" value=\'' . stripslashes($val) . '\'/>'; } //$str = $str . '<input type="submit" style="width:20%;height:40px;" value="确认支付"/>'; $str = $str . '</form>'; $str = $str . '<script>'; $str = $str . 'document.Form1.submit();'; $str = $str . '</script>'; exit($str); }
//商户二维码 public function qrcode() { $userid = $_GET['uid']; $userkey = $_GET['key']; $en = $_GET['en']; $arr = unserialize(S('userinfo' . $userkey)); if (empty($arr['str'])) $str = '快捷支付'; else $str = $arr['str']; //过滤接口 //判断是否有可用的接口 $list = SL('Api')->getOpenApi();
$leave = 'wap'; $display='none'; if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) { $leave = 'gzh'; } else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Alipay') !== false) { $leave = 'zfbwap'; }else{ $display='block'; }
foreach ($list as $i => $iList) { if($iList['jkstyle']=='usdt'){ $iList['jkstyle']='usdtwap'; } if (!strstr($iList['jkstyle'], $leave)) unset($list[$i]); }
$this->assign('list', $list); $this->assign('display', $display); $this->assign('userid', $userid); $this->assign('userkey', $userkey); $this->assign('pageName', $str); if($en){ $this->display('qrcode_en'); }else{ $this->display(); } }
//收银台 public function gateway() { $http = $_GET; $tjurl=$http['wg']; unset($http['wg']); header("Content-type: text/html; charset=utf-8"); foreach ($http as $key => $val) { if(empty($val)) continue; $str = $str . '<input type="hidden" name="' . $key . '" value="' . $val . '"/>'; }
//获取银行数据 $buffer=SM('Bank')->selectData('*','status=0','orderid asc,id asc');
$this->assign('list',$buffer); $this->assign('wg',$tjurl); $this->assign('hidden',$str); $this->assign('data',$http); $this->display(); }
//二维码 public function ewm() { $ddh = $_GET['ddh']; $qr = $_GET['qr']; $md = $_GET['md'];
//验证数据完整性 $sign=md5($ddh.$qr.C('FX_QRCODE_KEY')); if($sign!=$md){ $this->reback([0,'二维码信息有误,请重新获取支付链接。'], 1); exit(); }
$buffer=SM('Dingdan')->findData('*','ordernum="'.$ddh.'"'); $pzBuffer=SM('Jiekoupeizhi')->findData('*','pzid="'.$buffer['pzid'].'"'); $jkBuffer=SM('Jiekou')->findData('*','jkstyle="'.$buffer['jkstyle'].'"'); $buffer['pzstyle']=$pzBuffer['style']; $buffer['shutname']=$jkBuffer['jkname']; $buffer['addtime'] = stringChange('formatDateTime', $buffer['addtime']); $buffer['statusname'] = '等待支付';
//加密数据供获取订单状态使用 $buffer['md']=md5($ddh.$buffer['userid'].C('FX_QRCODE_KEY'));
//已经支付 转入支付成功界面 if($buffer['status']>0){ $params=array('ddh'=>$ddh); $buffer = SA(ucfirst($pzBuffer['style']) . '/backurl', $params); if($buffer[0]==1){ header('Location:' . $buffer[1]); //跳转 }else{ $this->reback($buffer); } }
$this->assign('data',$buffer); $this->assign('qr',$qr); $this->display(); }
//获取订单号状态 public function getddhstatus() { $ddh=$_REQUEST['ddh']; $md=$_REQUEST['md']; $buffer=SM('Dingdan')->findData('userid,status','ordernum="'.$ddh.'"');
$mymd=md5($ddh.$buffer['userid'].C('FX_QRCODE_KEY')); if($mymd!=$md){ $buffer=[0,'数据异常']; }else{ $buffer=[1,$buffer]; } $this->reback($buffer,!IS_AJAX); } }
|