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

调试支付

@@ -16,8 +16,8 @@ use Exception; @@ -16,8 +16,8 @@ use Exception;
16 */ 16 */
17 class Wxpay extends Api 17 class Wxpay extends Api
18 { 18 {
19 - protected $noNeedLogin = [];  
20 - protected $noNeedRight = '*'; 19 + protected $noNeedLogin = ['notify','wechatReturn'];
  20 + protected $noNeedRight = ['notify','wechatReturn'];
21 protected $user_id = '';//token存贮user_id 21 protected $user_id = '';//token存贮user_id
22 protected $order_status = [];//订单状态 22 protected $order_status = [];//订单状态
23 public function _initialize() 23 public function _initialize()
@@ -35,7 +35,7 @@ class Wxpay extends Api @@ -35,7 +35,7 @@ class Wxpay extends Api
35 * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") 35 * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
36 * @ApiParams (name="openid", type="string", required=true, description="小程序openid") 36 * @ApiParams (name="openid", type="string", required=true, description="小程序openid")
37 * @ApiParams (name="pay_order_sn", type="string", required=true, description="支付订单号") 37 * @ApiParams (name="pay_order_sn", type="string", required=true, description="支付订单号")
38 - * @ApiReturn 38 + * @ApiReturn ({code: 0, msg: "无效的订单", time: "1554176100", data: null})
39 */ 39 */
40 public function pay(){ 40 public function pay(){
41 if($this->request->isPost()){ 41 if($this->request->isPost()){
@@ -71,14 +71,12 @@ class Wxpay extends Api @@ -71,14 +71,12 @@ class Wxpay extends Api
71 $order = [ 71 $order = [
72 'out_trade_no' => $pay_order_sn,//支付订单号 72 'out_trade_no' => $pay_order_sn,//支付订单号
73 'body' => '广西小纸皮再生资源回收有限公司', 73 'body' => '广西小纸皮再生资源回收有限公司',
74 - 'total_fee' => 1,  
75 - //'total_fee' => floatval($total_price)*100,//单位:分 74 +// 'total_fee' => 1,
  75 + 'total_fee' => floatval($total_price)*100,//单位:分
76 'openid' => $openid, 76 'openid' => $openid,
77 'notify_url' => url('api/Wxpay/notify','','',true), 77 'notify_url' => url('api/Wxpay/notify','','',true),
78 'return_url' => url('api/Wxpay/wechatReturn','','',true), 78 'return_url' => url('api/Wxpay/wechatReturn','','',true),
79 ]; 79 ];
80 - Log::info('订单生成');  
81 - Log::info($order);  
82 //跳转或输出 80 //跳转或输出
83 $this->success('成功',$pay->miniapp($order)); 81 $this->success('成功',$pay->miniapp($order));
84 82
@@ -91,19 +89,18 @@ class Wxpay extends Api @@ -91,19 +89,18 @@ class Wxpay extends Api
91 * 支付成功回调 89 * 支付成功回调
92 */ 90 */
93 public function notify(){ 91 public function notify(){
94 - Log::info('支付成功回调');  
95 -  
96 $pay = Service::checkNotify('wechat'); 92 $pay = Service::checkNotify('wechat');
97 if (!$pay) { 93 if (!$pay) {
98 $this->error('签名错误'); 94 $this->error('签名错误');
99 } 95 }
100 //你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能 96 //你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能
101 $data = $pay->verify(); 97 $data = $pay->verify();
  98 + if($data['return_code'] == 'SUCCESS' && $data['result_code'] == 'SUCCESS') {
102 $porderModel = new Porder(); 99 $porderModel = new Porder();
103 - $porderModel->where(['uid' => 26,'p_id'=>6])->update(['status'=>1]);  
104 - 100 + $porderModel->where(['pay_order_sn'=>$data['out_trade_no']])->update(['status'=>$this->order_status[1]]);
105 //下面这句必须要执行,且在此之前不能有任何输出 101 //下面这句必须要执行,且在此之前不能有任何输出
106 echo $pay->success(); 102 echo $pay->success();
  103 + }
107 return; 104 return;
108 } 105 }
109 106
@@ -266,6 +266,8 @@ @@ -266,6 +266,8 @@
266 <a href="#支付接口**" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">支付接口** <i class="fa fa-caret-down"></i></a> 266 <a href="#支付接口**" class="list-group-item" data-toggle="collapse" data-parent="#sidebar">支付接口** <i class="fa fa-caret-down"></i></a>
267 <div class="child collapse" id="支付接口**"> 267 <div class="child collapse" id="支付接口**">
268 <a href="javascript:;" data-id="64" class="list-group-item">支付订单</a> 268 <a href="javascript:;" data-id="64" class="list-group-item">支付订单</a>
  269 + <a href="javascript:;" data-id="65" class="list-group-item">支付成功回调</a>
  270 + <a href="javascript:;" data-id="66" class="list-group-item">微信异步通知</a>
269 </div> 271 </div>
270 </div> 272 </div>
271 </div> 273 </div>
@@ -9394,7 +9396,191 @@ @@ -9394,7 +9396,191 @@
9394 <div class="tab-pane" id="sample64"> 9396 <div class="tab-pane" id="sample64">
9395 <div class="row"> 9397 <div class="row">
9396 <div class="col-md-12"> 9398 <div class="col-md-12">
9397 - <pre id="sample_response64"></pre> 9399 + <pre id="sample_response64">{code: 0, msg: "无效的订单", time: "1554176100", data: null}</pre>
  9400 + </div>
  9401 + </div>
  9402 + </div><!-- #sample -->
  9403 +
  9404 + </div><!-- .tab-content -->
  9405 + </div>
  9406 + </div>
  9407 + </div>
  9408 + <div class="panel panel-default">
  9409 + <div class="panel-heading" id="heading-65">
  9410 + <h4 class="panel-title">
  9411 + <span class="label label-success">GET</span>
  9412 + <a data-toggle="collapse" data-parent="#accordion65" href="#collapseOne65"> 支付成功回调 <span class="text-muted">/api/wxpay/notify</span></a>
  9413 + </h4>
  9414 + </div>
  9415 + <div id="collapseOne65" class="panel-collapse collapse">
  9416 + <div class="panel-body">
  9417 +
  9418 + <!-- Nav tabs -->
  9419 + <ul class="nav nav-tabs" id="doctab65">
  9420 + <li class="active"><a href="#info65" data-toggle="tab">基础信息</a></li>
  9421 + <li><a href="#sandbox65" data-toggle="tab">在线测试</a></li>
  9422 + <li><a href="#sample65" data-toggle="tab">返回示例</a></li>
  9423 + </ul>
  9424 +
  9425 + <!-- Tab panes -->
  9426 + <div class="tab-content">
  9427 +
  9428 + <div class="tab-pane active" id="info65">
  9429 + <div class="well">
  9430 + 支付成功回调 </div>
  9431 + <div class="panel panel-default">
  9432 + <div class="panel-heading"><strong>Headers</strong></div>
  9433 + <div class="panel-body">
  9434 +
  9435 + </div>
  9436 + </div>
  9437 + <div class="panel panel-default">
  9438 + <div class="panel-heading"><strong>参数</strong></div>
  9439 + <div class="panel-body">
  9440 +
  9441 + </div>
  9442 + </div>
  9443 + <div class="panel panel-default">
  9444 + <div class="panel-heading"><strong>正文</strong></div>
  9445 + <div class="panel-body">
  9446 +</div>
  9447 + </div>
  9448 + </div><!-- #info -->
  9449 +
  9450 + <div class="tab-pane" id="sandbox65">
  9451 + <div class="row">
  9452 + <div class="col-md-12">
  9453 + <div class="panel panel-default">
  9454 + <div class="panel-heading"><strong>参数</strong></div>
  9455 + <div class="panel-body">
  9456 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/wxpay/notify" method="get" name="form65" id="form65">
  9457 + <div class="form-group">
  9458 +
  9459 + </div>
  9460 + <div class="form-group">
  9461 + <button type="submit" class="btn btn-success send" rel="65">提交</button>
  9462 + <button type="reset" class="btn btn-info" rel="65">重置</button>
  9463 + </div>
  9464 + </form>
  9465 + </div>
  9466 + </div>
  9467 + <div class="panel panel-default">
  9468 + <div class="panel-heading"><strong>响应输出</strong></div>
  9469 + <div class="panel-body">
  9470 + <div class="row">
  9471 + <div class="col-md-12" style="overflow-x:auto">
  9472 + <pre id="response_headers65"></pre>
  9473 + <pre id="response65"></pre>
  9474 + </div>
  9475 + </div>
  9476 + </div>
  9477 + </div>
  9478 + <div class="panel panel-default">
  9479 + <div class="panel-heading"><strong>返回参数</strong></div>
  9480 + <div class="panel-body">
  9481 +
  9482 + </div>
  9483 + </div>
  9484 + </div>
  9485 + </div>
  9486 + </div><!-- #sandbox -->
  9487 +
  9488 + <div class="tab-pane" id="sample65">
  9489 + <div class="row">
  9490 + <div class="col-md-12">
  9491 + <pre id="sample_response65"></pre>
  9492 + </div>
  9493 + </div>
  9494 + </div><!-- #sample -->
  9495 +
  9496 + </div><!-- .tab-content -->
  9497 + </div>
  9498 + </div>
  9499 + </div>
  9500 + <div class="panel panel-default">
  9501 + <div class="panel-heading" id="heading-66">
  9502 + <h4 class="panel-title">
  9503 + <span class="label label-success">GET</span>
  9504 + <a data-toggle="collapse" data-parent="#accordion66" href="#collapseOne66"> 微信异步通知 <span class="text-muted">/api/wxpay/wechatReturn</span></a>
  9505 + </h4>
  9506 + </div>
  9507 + <div id="collapseOne66" class="panel-collapse collapse">
  9508 + <div class="panel-body">
  9509 +
  9510 + <!-- Nav tabs -->
  9511 + <ul class="nav nav-tabs" id="doctab66">
  9512 + <li class="active"><a href="#info66" data-toggle="tab">基础信息</a></li>
  9513 + <li><a href="#sandbox66" data-toggle="tab">在线测试</a></li>
  9514 + <li><a href="#sample66" data-toggle="tab">返回示例</a></li>
  9515 + </ul>
  9516 +
  9517 + <!-- Tab panes -->
  9518 + <div class="tab-content">
  9519 +
  9520 + <div class="tab-pane active" id="info66">
  9521 + <div class="well">
  9522 + 微信异步通知 </div>
  9523 + <div class="panel panel-default">
  9524 + <div class="panel-heading"><strong>Headers</strong></div>
  9525 + <div class="panel-body">
  9526 +
  9527 + </div>
  9528 + </div>
  9529 + <div class="panel panel-default">
  9530 + <div class="panel-heading"><strong>参数</strong></div>
  9531 + <div class="panel-body">
  9532 +
  9533 + </div>
  9534 + </div>
  9535 + <div class="panel panel-default">
  9536 + <div class="panel-heading"><strong>正文</strong></div>
  9537 + <div class="panel-body">
  9538 +</div>
  9539 + </div>
  9540 + </div><!-- #info -->
  9541 +
  9542 + <div class="tab-pane" id="sandbox66">
  9543 + <div class="row">
  9544 + <div class="col-md-12">
  9545 + <div class="panel panel-default">
  9546 + <div class="panel-heading"><strong>参数</strong></div>
  9547 + <div class="panel-body">
  9548 + <form enctype="application/x-www-form-urlencoded" role="form" action="/api/wxpay/wechatReturn" method="get" name="form66" id="form66">
  9549 + <div class="form-group">
  9550 +
  9551 + </div>
  9552 + <div class="form-group">
  9553 + <button type="submit" class="btn btn-success send" rel="66">提交</button>
  9554 + <button type="reset" class="btn btn-info" rel="66">重置</button>
  9555 + </div>
  9556 + </form>
  9557 + </div>
  9558 + </div>
  9559 + <div class="panel panel-default">
  9560 + <div class="panel-heading"><strong>响应输出</strong></div>
  9561 + <div class="panel-body">
  9562 + <div class="row">
  9563 + <div class="col-md-12" style="overflow-x:auto">
  9564 + <pre id="response_headers66"></pre>
  9565 + <pre id="response66"></pre>
  9566 + </div>
  9567 + </div>
  9568 + </div>
  9569 + </div>
  9570 + <div class="panel panel-default">
  9571 + <div class="panel-heading"><strong>返回参数</strong></div>
  9572 + <div class="panel-body">
  9573 +
  9574 + </div>
  9575 + </div>
  9576 + </div>
  9577 + </div>
  9578 + </div><!-- #sandbox -->
  9579 +
  9580 + <div class="tab-pane" id="sample66">
  9581 + <div class="row">
  9582 + <div class="col-md-12">
  9583 + <pre id="sample_response66"></pre>
9398 </div> 9584 </div>
9399 </div> 9585 </div>
9400 </div><!-- #sample --> 9586 </div><!-- #sample -->
@@ -9409,7 +9595,7 @@ @@ -9409,7 +9595,7 @@
9409 9595
9410 <div class="row mt0 footer"> 9596 <div class="row mt0 footer">
9411 <div class="col-md-6" align="left"> 9597 <div class="col-md-6" align="left">
9412 - Generated on 2019-03-30 14:56:39 </div> 9598 + Generated on 2019-04-02 11:48:31 </div>
9413 <div class="col-md-6" align="right"> 9599 <div class="col-md-6" align="right">
9414 <a href="https://www.fastadmin.net" target="_blank">FastAdmin</a> 9600 <a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
9415 </div> 9601 </div>