【类 型】:feat
【主 题】:支付回调设置 【描 述】: [原因]: [过程]:获取腾讯的回调给的参数 验证订餐参数 更改订单状态 [影响]: 【结 束】 # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
c1e516e0d5
commit
a57ca86e34
@ -84,15 +84,27 @@ class PayController extends PublicController
|
||||
*/
|
||||
public function notifyCallback()
|
||||
{
|
||||
$this->publish('demo', 'start');
|
||||
// 实例化 Yansongda Pay
|
||||
$pay = Pay::wechat($this->config);
|
||||
|
||||
try {
|
||||
$data = $pay->callback(); // 是的,验签就这么简单!
|
||||
// 获取并验证回调数据
|
||||
$callBackData = $pay->callback();
|
||||
// 验证成功,处理业务逻辑
|
||||
if ($callBackData['trade_state'] == 'SUCCESS') {
|
||||
$where['order_sn'] = $callBackData['out_trade_no']; // 获取订单号
|
||||
$orderDb = D('order'); // 实例化订单模型
|
||||
$data['status'] = 'pending'; //付款状态
|
||||
$data['pay_sn'] = $callBackData['transaction_id'];
|
||||
//注意先简单测试一下还需要验证openid 金额等
|
||||
$orderDb->where($where)->data($data)->save(); //更改订单
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// $e->getMessage();
|
||||
// 捕获并处理可能的异常
|
||||
// 可以记录错误日志以便排查问题
|
||||
// error_log('支付回调错误:' . $e->getMessage());
|
||||
}
|
||||
|
||||
$this->publish('demo', $data);
|
||||
// 返回成功响应给腾讯服务器,告知通知已处理
|
||||
return $pay->success();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user