'require|url', * 'state|携带参数' => 'require|length:1,255', * 'scope|应用授权作用域' => 'require|in:snsapi_base,snsapi_userinfo' * ]); * * if (!$val->check(['callback' => $callback, 'state' => $state, 'scope' => $scope])) throw new ValidateException($val->getError()); * * $oauth = &load_wechat('Oauth'); * * $rs = $oauth->getOauthRedirect($callback, $state, $scope); * * halt('调用成功', $rs); * * } * * * //通过code换取网页授权access_token(和openId) * public static function getOauthAccessToken() * { * * $oauth = &load_wechat('Oauth'); * * $rs = $oauth->getOauthAccessToken(); * * halt('最终结果:', $rs); * } * * * //获取预支付信息 * public static function getPrepayId(string $openid = '', string $body = '', string $out_trade_no = '', float $total_fee = 0, string $notify_url = '', string $trade_type = "JSAPI") * { * * if ($notify_url == '') $notify_url = env('notify_url'); * * $pay = &load_wechat('Pay'); * * $rs = $pay->getPrepayId($openid, $body, $out_trade_no, bcmul($total_fee, '100'), $notify_url, $trade_type); * * halt('预支付结果:', $rs); * } * * * //支付通知回调 * public static function Notify() * { * * //实例化支付接口 * $pay = &load_wechat('Pay'); * * //获取支付通知 * $notifyInfo = $pay->getNotify(); * * if ($notifyInfo === false) throw new Exception('获取微信支付通知数据失败,' . $pay->errMsg); * elseif ($notifyInfo['result_code'] == 'SUCCESS' && $notifyInfo['return_code'] == 'SUCCESS') return $notifyInfo;// 支付状态完全成功,可以更新订单的支付状态了 * else throw new Exception('获取微信支付通知数据失败,' . json_encode($notifyInfo, JSON_UNESCAPED_UNICODE)); * * } * * * //@todo 校验订单状态,确认支付结果 * public static function checkPayResult(string $out_trade_no = '') * { * $pay = &load_wechat('Pay'); * * $rs = $pay->queryOrder($out_trade_no); * * halt('订单详情:', $rs); * * } **/ }