Notify.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace app\api\controller;
use addons\epay\library\Service;
use app\common\controller\Api;
/**
* @ApiInternal
* 支付回调接口
*/
class Notify extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 微信支付回调
*/
public function service()
{
$type = $this->request->param('type');
$pay = Service::checkNotify($type);
if (!$pay) {
return '签名错误';
}
$time = time();
$data = $pay->verify();
$data = json_decode($data, true);
//输出返回的参数
$orderModel = new \app\api\model\order\Order();
if ($data['return_code'] == 'SUCCESS') {
if ($data['result_code'] == 'SUCCESS') {
$update_data = [
'transaction_id' => $data['transaction_id'],
'payment_json' => json_encode($data),
'paytime' => $time,
'status' => '1',
// 'pay_price' => $data['total_fee'],
];
//更新订单信息
$orderModel->where('order_sn', $data['out_trade_no'])->update($update_data);
}
}
return $pay->success()->send();
}
}