public function Queryorder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); // Log::DEBUG("query:" . json_encode($result)); ilog(iLOG_INFO, 'Queryorder:' . json_encode($result), __LINE__); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { $user_trade_no = $result['out_trade_no']; $transaction_id = $result['transaction_id']; $info1 = 'wxapp/interface/appnotify.php,operator success,session == trade_no,ordernum:' . $user_trade_no . ',wxno:' . $transaction_id; ilog(iLOG_INFO, $info1, __LINE__); $body_arr['order_no'] = $user_trade_no; $body_arr['pay_result'] = 2; //支付成功 $body_arr['alipay_no'] = $transaction_id; //微信流水号 $body_arr['channel'] = 'wxapp'; // $ret = exec_procedure($body_arr, 'p_order_pay_result'); if ($ret['status'] == 0 || $ret['status'] == 1040) { //成功,返回success return true; } else { //返回错误码,非success $info = 'wxapp/interface/appnotify.php,p_order_pay_result failed'; ilog(iLOG_INFO, $info, __LINE__); return false; } } $info = 'wxapp/interface/appnotify.php,operator failed'; ilog(iLOG_INFO, $info, __LINE__); //验证失败 return false; }
/** * * 查询订单情况 * @param string $out_trade_no 商户订单号 * @param int $succCode 查询订单结果 * @return 0 订单不成功,1表示订单成功,2表示继续等待 */ public function query($out_trade_no, &$succCode) { $queryOrderInput = new WxPayOrderQuery(); $queryOrderInput->SetOut_trade_no($out_trade_no); $result = WxPayApi::orderQuery($queryOrderInput); if ($result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { //支付成功 if ($result["trade_state"] == "SUCCESS") { $succCode = 1; return $result; } else { if ($result["trade_state"] == "USERPAYING") { $succCode = 2; return false; } } } //如果返回错误码为“此交易订单号不存在”则直接认定失败 if ($result["err_code"] == "ORDERNOTEXIST") { $succCode = 0; } else { //如果是系统错误,则后续继续 $succCode = 2; } return false; }
public function Queryorder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); \Log::info("query:" . json_encode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { // 处理订单 $pay = \App\Pay::find($result['out_trade_no']); $pay->pay($result['transaction_id']); if ($pay->state < 2) { $pay->state = '2'; $pay->bak_id = '0'; $pay->other_id = $result['transaction_id']; $pay->save(); } else { if ($pay->state == 2) { $pay->bak_id++; $pay->save(); } } return true; } return false; }
public function Queryorder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { return true; } return false; }
public function Queryorder($mpid, $transaction_id) { //\TMS_APP::M('log')->log('debug', 'pay-Queryorder', '0'); $input = new \WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = \WxPayApi::orderQuery($mpid, $input); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { return true; } //\TMS_APP::M('log')->log('debug', 'pay-Queryorder', 'ok'); return false; }
public function Queryorder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { return true; } $log = Log::factory(NT_LOGS_PATH . 'wxpay_saoma/'); $log->write('wxpay_saoma_notify_orderQuery', "订单查询失败\n" . json_encode($result) . "\n"); return false; }
public function Queryorder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); Log::DEBUG("query:" . json_encode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { return true; // echo "OK"; } return false; // echo "Fail"; }
public function Queryorder($data) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($data['transaction_id']); $input->SetTradeType($data['trade_type']); $result = WxPayApi::orderQuery($input, Config::API_TIMEOUT); $this->query_data = $result; Log::DEBUG("query:" . json_encode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { return true; } return false; }
private function queryOrder($out_trade_no, $inStatus = '') { if (isset($out_trade_no) && $out_trade_no != "") { $input = new WxPayOrderQuery(); $input->SetOut_trade_no($out_trade_no); $info = WxPayApi::orderQuery($input); if ($inStatus == 'code') { return $info['trade_state']; } $status = orderState($info['trade_state']); } return $status; }
public function queryOrder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); Log::DEBUG("query:" . Tools::jsonEncode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { if (!$this->changeOrderStatus($result['out_trade_no'])) { Log::DEBUG("change:5.更改定单状态失败"); } return true; } return false; }
public function Queryorder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); Log::DEBUG("query:" . json_encode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { //支付成功后 开通相关的操作方法 require_once dirname(__FILE__) . '/../common.inc.php'; $url = $_CFG['site_domain'] . $_CFG['site_dir'] . "include/payment/respond_weixinpay.php"; $return_oid = $this->curl_file_get_contents($url, $result); @unlink(QISHI_ROOT_PATH . 'data/wxpay/' . $return_oid . '.tmp'); return true; } return false; }
public function queryOrder($out_trade_no) { $input = new \WxPayOrderQuery(); $input->setWxPayApi($this->wxPayApi); $input->SetOut_trade_no($out_trade_no); $result = \WxPayApi::orderQuery($input); /* if(array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { return true; } */ return $result; }
public function Queryorder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); Log::DEBUG("query:" . json_encode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { $url = "http://" . $_SERVER['SERVER_NAME'] . "/index.php?g=weixin&m=scan&a=notify"; $post_params = $result; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params); $output = curl_exec($ch); curl_close($ch); return true; } return false; }
function wxqueryorderdata($body) { // $data['pay_no'] = isset($body['out_data']['pay_no'])?$body['out_data']['pay_no']:''; // if(!$data['pay_no']){ // $ret1['status'] = 1041; // $ret1['desc'] = '等待支付'; // return $ret1; // } $queryOrderInput = new WxPayOrderQuery(); $queryOrderInput->SetOut_trade_no($body['order_no']); $ret = WxPayApi::orderQuery($queryOrderInput); //数据已经解析为了数组格式 $retexec = array(); if ($ret['return_code'] == 'SUCCESS') { //查询成功 $resp['wx_app_id'] = $ret['appid']; $resp['wx_partner_id'] = $ret['mch_id']; if ($ret['result_code'] == 'SUCCESS') { // switch ($ret['trade_state']) { case 'SUCCESS': //支付成功 $body['pay_result'] = 2; $body['pay_time'] = $ret['time_end']; $retexec = exec_procedure($body, 'p_order_update_result'); $retexec['order_state'] = 2; break; case 'REFUND': //转入退款 //转入退款 case 'NOTPAY': //未支付 //未支付 case 'CLOSED': //已关闭 //已关闭 case 'REVOKED': //已撤销 //已撤销 case 'USERPAYING': //用户支付中 //用户支付中 case 'PAYERROR': //支付失败 $retexec = exec_procedure($body, 'p_order_query_result'); $retexec['out_state'] = isset($retexec['out_data']['out_state']) ? $retexec['out_data']['out_state'] : 0; break; } } return $retexec; } else { $ret['status'] = 1045; return $ret; } }
foreach ($data as $key => $value) { echo "<font color='#f00;'>{$key}</font> : {$value} <br/>"; } } if (isset($_REQUEST["transaction_id"]) && $_REQUEST["transaction_id"] != "") { $transaction_id = $_REQUEST["transaction_id"]; $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); printf_info(WxPayApi::orderQuery($input)); exit; } if (isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != "") { $out_trade_no = $_REQUEST["out_trade_no"]; $input = new WxPayOrderQuery(); $input->SetOut_trade_no($out_trade_no); printf_info(WxPayApi::orderQuery($input)); exit; } ?> <body> <form action="#" method="post"> <div style="margin-left:2%;color:#f00">微信订单号和商户订单号选少填一个,微信订单号优先:</div><br/> <div style="margin-left:2%;">微信订单号:</div><br/> <input type="text" style="width:96%;height:35px;margin-left:2%;" name="transaction_id" /><br /><br /> <div style="margin-left:2%;">商户订单号:</div><br/> <input type="text" style="width:96%;height:35px;margin-left:2%;" name="out_trade_no" /><br /><br /> <div align="center"> <input type="submit" value="查询" style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer; color:white; font-size:16px;" type="button" onclick="callpay()" /> </div> </form> </body>
public function Queryorder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); Log::DEBUG("query:" . json_encode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { f_log(http_build_query($result), dirname(__FILE__) . '/mylog.log'); $result['addtime'] = time(); $id = M('pay_log')->add($result); // 更改order 状态 // 更改 hongbao状态 $order_sn = $result['out_trade_no']; if (substr($order_sn, 0, 2) == 'HB') { $this->bao($result, $id); return true; } if (substr($order_sn, 0, 2) == 'ZP') { $this->zhaopian($result, $id); return true; } $order = M('hongbao_order')->where("order_sn='{$result['out_trade_no']}'")->find(); if ($order) { // 重复操作 if ($order['state'] > 1) { return true; } $order_data = array('pay_id' => $id, 'pay_time' => time(), 'transaction_id' => $result['transaction_id'], 'state' => 2); M('hongbao_order')->where("id='{$order['id']}'")->save($order_data); $hongbao = M('hongbao')->where("id='{$order['hongbao_id']}'")->find(); if ($hongbao) { $data = array('update_time' => time(), 'total_num' => $hongbao['total_num'] + $order['part_num'], 'total_pay_amount' => $hongbao['total_pay_amount'] + $order['total_amount'], 'total_user' => $hongbao['total_user'] + 1); if ($data['total_num'] >= $hongbao['total_part'] || $data['total_pay_amount'] >= $hongbao['total_amount']) { $data['state'] = 2; $data['success_time'] = time(); } M('hongbao')->where("id='{$order['hongbao_id']}'")->save($data); if ($hongbao['state'] > 1) { return true; } // 设置幸运星 if ($data['state'] == 2) { $list = M('hongbao_order')->where("hongbao_id='{$order['hongbao_id']}' AND state=2")->select(); if ($list) { $ids = array(); foreach ($list as $r) { $ids[] = $r['id']; } shuffle($ids); $k = array_rand($ids); $id = $ids[$k]; if ($id) { $order_info = M('hongbao_order')->find($id); $user_info = M('user')->find($order_info['user_id']); M('hongbao_order')->where("id='{$id}'")->save(array('is_star' => 1)); } } } // 自动发送红包 if ($data['state'] == 2) { $bao = array('mch_billno' => get_order_sn(), 'send_name' => '凑红包', 're_openid' => $hongbao['openid'], 'total_amount' => floor($hongbao['total_amount'] * 0.98 * 100), 'wishing' => '恭喜您!您在凑红包发起的凑红包已经完成。', 'act_name' => '凑红包', 'remark' => '凑红包'); $send = $bao; $send['user_id'] = $hongbao['user_id']; $send['addtime'] = time(); $hongbao_id = M('hongbao_send')->add($send); if ($hongbao_id) { M('hongbao')->where(array("id='{$hongbao['id']}'"))->save(array('hongbao_id' => $hongbao_id, 'hongbao_sn' => $bao['mch_billno'], 'hongbao_time' => time())); $data = sendHongBao($bao); if ($data['result_code'] == 'SUCCESS' && $data['return_code'] == 'SUCCESS') { M('hongbao')->where(array("id='{$hongbao['id']}'"))->save(array('is_send_hongbao' => 1)); M('hongbao_send')->where(array("id='{$hongbao_id}'"))->save(array('state' => 2, 'send_listid' => $data['send_listid'])); $user_amount = number_format($hongbao['total_amount'] * 0.98, 2); $msg = "你发起的凑红包成功啦!\n\n众筹标题:{$hongbao['remark']}\n\n众筹进度:¥{$hongbao['total_amount']}已成功!\n\n幸运星:{$user_info['name']}\n\n红包已经通过微信红包打给你,其中已扣除2%微信支付手续费,扣除后金额为{$user_amount}元"; \Wechat\Wxapi::send_wxmsg($hongbao['openid'], '众筹状态提醒', U('/cou/hongbao/detail', array('id' => $hongbao['number_no']), true, true), $msg); $msg = "幸运星就是你!没想到吧\n\n众筹标题:{$hongbao['remark']}\n\n众筹进度:¥{$hongbao['total_amount']}已成功!\n\n快找发起人要福利吧 :D"; \Wechat\Wxapi::send_wxmsg($user_info['openid'], '众筹状态提醒', U('/cou/hongbao/detail', array('id' => $hongbao['number_no']), true, true), $msg); } else { M('hongbao_send')->where(array("id='{$hongbao_id}'"))->save(array('state' => 3)); $user_amount = number_format($hongbao['total_amount'] * 0.98, 2); $msg = "你发起的凑红包成功啦!\n\n众筹标题:{$hongbao['remark']}\n\n众筹进度:¥{$hongbao['total_amount']}已成功!\n\n幸运星:{$user_info['name']}\n\n红包将会在1~3个工作内,通过微信红包打给你,\n其中已扣除2%的微信支付手续费,扣除后金额为{$user_amount}元。\n因为微信支付到我们的账户需要1~3个工作日,我们\n的账户预存垫付的现金不足,暂时不能实时转账,希望\n理解。资金安全请你放心,如果有疑问请联系客服。"; \Wechat\Wxapi::send_wxmsg($hongbao['openid'], '众筹状态提醒', U('/cou/hongbao/detail', array('id' => $hongbao['number_no']), true, true), $msg); $sys_openid = "oV3oMxP5wdTR8BpptzNq2tDdGtLk"; $msg = "重要提示! 红包发送异常!!!"; \Wechat\Wxapi::send_wxmsg($sys_openid, '众筹状态提醒', "http://{$_SERVER['HTTP_HOST']}", $msg); } } } } } return true; } return false; }
public function Queryorder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); Log::DEBUG("query:" . json_encode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { f_log(http_build_query($result), dirname(__FILE__) . '/wzlog.log'); $result['addtime'] = time(); $id = M('pay_log')->add($result); // 更改order 状态 // 更改 hongbao状态 $result['out_trade_no']; $order = M('zhaopian_order')->where("order_sn='{$result['out_trade_no']}'")->find(); $user = M('user')->find($order['user_id']); if ($order) { // 重复操作 if ($order['state'] > 1) { return true; } $order_data = array('pay_id' => $id, 'pay_time' => time(), 'transaction_id' => $result['transaction_id'], 'state' => 2); M('zhaopian_order')->where("id='{$order['id']}'")->save($order_data); $zhaopian = M('zhaopian')->where("id='{$order['hongbao_id']}'")->find(); if ($zhaopian) { $data = array('update_time' => time(), 'total_num' => $zhaopian['total_num'] + 1, 'total_amount' => $zhaopian['total_amount'] + $order['amount']); // 自动发送红包 if (true) { $bao = array('mch_billno' => get_order_sn('wz'), 'send_name' => '红包照片', 're_openid' => $zhaopian['openid'], 'total_amount' => floor($order['amount'] * 0.98 * 100), 'wishing' => '恭喜您!您在照片刚刚"' . $user['name'] . '"购买了', 'act_name' => '红包照片', 'remark' => '红包照片'); $send = $bao; $send['user_id'] = $zhaopian['user_id']; $send['addtime'] = time(); $hongbao_id = M('zhaopian_send')->add($send); if ($hongbao_id) { M('zhaopian_order')->where(array("id='{$order['id']}'"))->save(array('send_id' => $hongbao_id, 'send_sn' => $bao['mch_billno'], 'send_time' => time())); $data = sendHongBao($bao); if ($data['result_code'] == 'SUCCESS' && $data['return_code'] == 'SUCCESS') { M('zhaopian_order')->where(array("id='{$order['id']}'"))->save(array('is_send_zhaopian' => 1)); M('zhaopian_send')->where(array("id='{$hongbao_id}'"))->save(array('state' => 2, 'send_listid' => $data['send_listid'])); $user_amount = number_format($order['amount'] * 0.98, 2); $msg = "你发布的照片有朋友购买了!\n\n照片标题:{$zhaopian['remark']}\n\n支付金额:¥{$order['amount']}元\n\n好友购买照片钱已经通过微信红包打给你,其中已扣除2%微信支付手续费,扣除后金额为{$user_amount}元"; \Wechat\Wxapi::send_wxmsg($zhaopian['openid'], '红包照片状态提醒', U('/zhao/zhaopian/detail', array('id' => $zhaopian['number_no']), true, true), $msg); } else { M('hongbao_send')->where(array("id='{$hongbao_id}'"))->save(array('state' => 3)); $user_amount = number_format($order['amount'] * 0.98, 2); $msg = "你发布的照片有朋友购买了!\n\n照片标题:{$zhaopian['remark']}\n\n支付金额:¥{$order['amount']}元\n\n红包将会在1~3个工作内,通过微信红包打给你,\n其中已扣除2%的微信支付手续费,扣除后金额为{$user_amount}元。\n因为微信支付到我们的账户需要1~3个工作日,我们\n的账户预存垫付的现金不足,暂时不能实时转账,希望\n理解。资金安全请你放心,如果有疑问请联系客服。"; \Wechat\Wxapi::send_wxmsg($zhaopian['openid'], '红包照片状态提醒', U('/zhao/zhaopian/detail', array('id' => $zhaopian['number_no']), true, true), $msg); $sys_openid = "obb1AuA79tIJ-BGY7HA38FXAJwoc"; $msg = "重要提示! 红包发送异常!!! 可能余额不足,或支付金额异常,支付金额:{$user_amount},请及时处理."; \Wechat\Wxapi::send_wxmsg($sys_openid, '红包照片状态提醒', "http://{$_SERVER['HTTP_HOST']}", $msg); } } } } } return true; } return false; }
private function queryOrder($out_trade_no = '', $inStatus = 0) { if ($inStatus == 4) { return $status = '已经申请退款'; } if (isset($out_trade_no) && $out_trade_no != "") { $input = new WxPayOrderQuery(); $input->SetOut_trade_no($out_trade_no); $info = WxPayApi::orderQuery($input); if (isset($info['err_code']) && $info['err_code'] == 'ORDERNOTEXIST') { $trade_state = 'NOTPAY'; } else { $trade_state = $info['trade_state']; } // $status = orderState($trade_state); } return $trade_state; }
public function actionOrderQuery() { if (isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != "") { $out_trade_no = $_REQUEST["out_trade_no"]; $input = new \WxPayOrderQuery(); $input->SetOut_trade_no($out_trade_no); $result = \WxPayApi::orderQuery($input); $this->renderAjax($result); } else { $this->renderAjax('没有订单号你叫我怎么查?'); } }
function Queryorder($transaction_id) { $WxCfg = $this->getWXCfg(); $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input, $WxCfg); Log::DEBUG(" WxPayApi::orderQuery:" . json_encode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { return true; } return false; }