作者 景龙
1 个管道 的构建 失败 耗费 0 秒

调试支付

... ... @@ -16,8 +16,8 @@ use Exception;
*/
class Wxpay extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $noNeedLogin = ['notify','wechatReturn'];
protected $noNeedRight = ['notify','wechatReturn'];
protected $user_id = '';//token存贮user_id
protected $order_status = [];//订单状态
public function _initialize()
... ... @@ -35,7 +35,7 @@ class Wxpay extends Api
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="openid", type="string", required=true, description="小程序openid")
* @ApiParams (name="pay_order_sn", type="string", required=true, description="支付订单号")
* @ApiReturn
* @ApiReturn ({code: 0, msg: "无效的订单", time: "1554176100", data: null})
*/
public function pay(){
if($this->request->isPost()){
... ... @@ -71,14 +71,12 @@ class Wxpay extends Api
$order = [
'out_trade_no' => $pay_order_sn,//支付订单号
'body' => '广西小纸皮再生资源回收有限公司',
'total_fee' => 1,
//'total_fee' => floatval($total_price)*100,//单位:分
// 'total_fee' => 1,
'total_fee' => floatval($total_price)*100,//单位:分
'openid' => $openid,
'notify_url' => url('api/Wxpay/notify','','',true),
'return_url' => url('api/Wxpay/wechatReturn','','',true),
];
Log::info('订单生成');
Log::info($order);
//跳转或输出
$this->success('成功',$pay->miniapp($order));
... ... @@ -91,19 +89,18 @@ class Wxpay extends Api
* 支付成功回调
*/
public function notify(){
Log::info('支付成功回调');
$pay = Service::checkNotify('wechat');
if (!$pay) {
$this->error('签名错误');
}
//你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能
$data = $pay->verify();
$porderModel = new Porder();
$porderModel->where(['uid' => 26,'p_id'=>6])->update(['status'=>1]);
//下面这句必须要执行,且在此之前不能有任何输出
echo $pay->success();
if($data['return_code'] == 'SUCCESS' && $data['result_code'] == 'SUCCESS') {
$porderModel = new Porder();
$porderModel->where(['pay_order_sn'=>$data['out_trade_no']])->update(['status'=>$this->order_status[1]]);
//下面这句必须要执行,且在此之前不能有任何输出
echo $pay->success();
}
return;
}
... ...
... ... @@ -266,6 +266,8 @@
<a href="#支付接口**" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">支付接口** <i class="fa fa-caret-down"></i></a>
<div class="child collapse" id="支付接口**">
<a href="javascript:;" data-id="64" class="list-group-item">支付订单</a>
<a href="javascript:;" data-id="65" class="list-group-item">支付成功回调</a>
<a href="javascript:;" data-id="66" class="list-group-item">微信异步通知</a>
</div>
</div>
</div>
... ... @@ -9394,7 +9396,191 @@
<div class="tab-pane" id="sample64">
<div class="row">
<div class="col-md-12">
<pre id="sample_response64"></pre>
<pre id="sample_response64">{code: 0, msg: "无效的订单", time: "1554176100", data: null}</pre>
</div>
</div>
</div><!-- #sample -->
</div><!-- .tab-content -->
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" id="heading-65">
<h4 class="panel-title">
<span class="label label-success">GET</span>
<a data-toggle="collapse" data-parent="#accordion65" href="#collapseOne65"> 支付成功回调 <span class="text-muted">/api/wxpay/notify</span></a>
</h4>
</div>
<div id="collapseOne65" class="panel-collapse collapse">
<div class="panel-body">
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="doctab65">
<li class="active"><a href="#info65" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox65" data-toggle="tab">在线测试</a></li>
<li><a href="#sample65" data-toggle="tab">返回示例</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info65">
<div class="well">
支付成功回调 </div>
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>正文</strong></div>
<div class="panel-body">
</div>
</div>
</div><!-- #info -->
<div class="tab-pane" id="sandbox65">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/wxpay/notify" method="get" name="form65" id="form65">
<div class="form-group">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="65">提交</button>
<button type="reset" class="btn btn-info" rel="65">重置</button>
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>响应输出</strong></div>
<div class="panel-body">
<div class="row">
<div class="col-md-12" style="overflow-x:auto">
<pre id="response_headers65"></pre>
<pre id="response65"></pre>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>返回参数</strong></div>
<div class="panel-body">
</div>
</div>
</div>
</div>
</div><!-- #sandbox -->
<div class="tab-pane" id="sample65">
<div class="row">
<div class="col-md-12">
<pre id="sample_response65"></pre>
</div>
</div>
</div><!-- #sample -->
</div><!-- .tab-content -->
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" id="heading-66">
<h4 class="panel-title">
<span class="label label-success">GET</span>
<a data-toggle="collapse" data-parent="#accordion66" href="#collapseOne66"> 微信异步通知 <span class="text-muted">/api/wxpay/wechatReturn</span></a>
</h4>
</div>
<div id="collapseOne66" class="panel-collapse collapse">
<div class="panel-body">
<!-- Nav tabs -->
<ul class="nav nav-tabs" id="doctab66">
<li class="active"><a href="#info66" data-toggle="tab">基础信息</a></li>
<li><a href="#sandbox66" data-toggle="tab">在线测试</a></li>
<li><a href="#sample66" data-toggle="tab">返回示例</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info66">
<div class="well">
微信异步通知 </div>
<div class="panel panel-default">
<div class="panel-heading"><strong>Headers</strong></div>
<div class="panel-body">
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>正文</strong></div>
<div class="panel-body">
</div>
</div>
</div><!-- #info -->
<div class="tab-pane" id="sandbox66">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><strong>参数</strong></div>
<div class="panel-body">
<form enctype="application/x-www-form-urlencoded" role="form" action="/api/wxpay/wechatReturn" method="get" name="form66" id="form66">
<div class="form-group">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success send" rel="66">提交</button>
<button type="reset" class="btn btn-info" rel="66">重置</button>
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>响应输出</strong></div>
<div class="panel-body">
<div class="row">
<div class="col-md-12" style="overflow-x:auto">
<pre id="response_headers66"></pre>
<pre id="response66"></pre>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><strong>返回参数</strong></div>
<div class="panel-body">
</div>
</div>
</div>
</div>
</div><!-- #sandbox -->
<div class="tab-pane" id="sample66">
<div class="row">
<div class="col-md-12">
<pre id="sample_response66"></pre>
</div>
</div>
</div><!-- #sample -->
... ... @@ -9409,7 +9595,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2019-03-30 14:56:39 </div>
Generated on 2019-04-02 11:48:31 </div>
<div class="col-md-6" align="right">
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
... ...