public function payNotifyAction(Request $request, $name) { $this->getLogService()->info('notify', 'create', "paynotify action"); $alipayNotify = new AlipayNotify(MobileAlipayConfig::getAlipayConfig("edusoho")); $verify_result = $alipayNotify->verifyNotify(); if ($verify_result) { //验证成功 $controller = $this; try { $status = $this->doPayNotify($request, $name, function ($success, $order) use(&$controller) { if (!$success) { return; } if ($order['targetType'] != 'course') { throw \RuntimeException('非课程订单,加入课程失败。'); } $info = array('orderId' => $order['id'], 'remark' => empty($order['data']['note']) ? '' : $order['data']['note']); if (!$controller->getCourseService()->isCourseStudent($order['targetId'], $order['userId'])) { $controller->getLogService()->info('notify', 'success', "paynotify action"); $controller->getCourseService()->becomeStudent($order['targetId'], $order['userId'], $info); } return; }); } catch (\Exception $e) { error_log($e->getMessage(), 0); } } else { //验证失败 $result["status"] = "fail"; $this->getLogService()->info('notify', 'check_fail', "paynotify action"); } return new Response("success"); }
public function payNotifyAction(Request $request, $name) { $this->getLogService()->info('notify', 'create', "paynotify action"); $alipayNotify = new AlipayNotify(MobileAlipayConfig::getAlipayConfig("edusoho")); $verify_result = $alipayNotify->verifyNotify(); if ($verify_result) { //验证成功 try { $status = $this->doPayNotify($request, $name); } catch (\Exception $e) { error_log($e->getMessage(), 0); } } else { //验证失败 $result["status"] = "fail"; $this->getLogService()->info('notify', 'check_fail', "paynotify action"); } return new Response("success"); }