|
|
@@ -22,32 +22,61 @@ class Pay extends Controller
|
|
|
public function notifyHandle(Request $request)
|
|
|
{
|
|
|
$data = $request->all();
|
|
|
- // 记录到专用支付日志
|
|
|
- Log::channel('payment')->info('支付回调', $data);
|
|
|
-
|
|
|
- $res = PaymentOrderService::receiveOrder($data);
|
|
|
- // var_dump($res);
|
|
|
- if (NoPayService::getWithdrawMerchantId() !== '' && ($data['appId'] ?? '') === NoPayService::getWithdrawMerchantId()) {
|
|
|
- echo $res ? 'SUCCESS' : 'fail';
|
|
|
- return;
|
|
|
+ $context = $this->callbackContext($request, $data);
|
|
|
+ Log::error('支付提现回调收到', $context);
|
|
|
+
|
|
|
+ try {
|
|
|
+ $res = PaymentOrderService::receiveOrder($data);
|
|
|
+ Log::error('支付提现回调处理结果', $context + ['success' => (bool)$res]);
|
|
|
+ if (NoPayService::getWithdrawMerchantId() !== '' && ($data['appId'] ?? '') === NoPayService::getWithdrawMerchantId()) {
|
|
|
+ return response($res ? 'SUCCESS' : 'fail');
|
|
|
+ }
|
|
|
+ return response('success');
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ Log::error('支付提现回调处理异常', $context + [
|
|
|
+ 'error' => $e->getMessage(),
|
|
|
+ 'exception' => get_class($e),
|
|
|
+ ]);
|
|
|
+ return response('fail', 500);
|
|
|
}
|
|
|
- echo 'success';
|
|
|
}
|
|
|
|
|
|
// 用户支付异步通知
|
|
|
public function harvestHandle(Request $request)
|
|
|
{
|
|
|
$data = $request->all();
|
|
|
- // 记录到专用支付日志
|
|
|
- Log::channel('payment')->info('三斤支付回调', $data);
|
|
|
-
|
|
|
- $res = PaymentOrderService::receivePay($data);
|
|
|
- // var_dump($res);
|
|
|
- if (NoPayService::getDepositMerchantId() !== '' && ($data['appId'] ?? '') === NoPayService::getDepositMerchantId()) {
|
|
|
- echo $res ? 'SUCCESS' : 'fail';
|
|
|
- return;
|
|
|
+ $context = $this->callbackContext($request, $data);
|
|
|
+ Log::error('支付充值回调收到', $context);
|
|
|
+
|
|
|
+ try {
|
|
|
+ $res = PaymentOrderService::receivePay($data);
|
|
|
+ Log::error('支付充值回调处理结果', $context + ['success' => (bool)$res]);
|
|
|
+ if (NoPayService::getDepositMerchantId() !== '' && ($data['appId'] ?? '') === NoPayService::getDepositMerchantId()) {
|
|
|
+ return response($res ? 'SUCCESS' : 'fail');
|
|
|
+ }
|
|
|
+ return response('success');
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ Log::error('支付充值回调处理异常', $context + [
|
|
|
+ 'error' => $e->getMessage(),
|
|
|
+ 'exception' => get_class($e),
|
|
|
+ ]);
|
|
|
+ return response('fail', 500);
|
|
|
}
|
|
|
- echo 'success';
|
|
|
}
|
|
|
|
|
|
+ private function callbackContext(Request $request, array $data): array
|
|
|
+ {
|
|
|
+ if (isset($data['sign'])) {
|
|
|
+ $data['sign'] = substr((string)$data['sign'], 0, 8) . '***';
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'ip' => $request->ip(),
|
|
|
+ 'url' => $request->fullUrl(),
|
|
|
+ 'content_type' => $request->header('Content-Type'),
|
|
|
+ 'user_agent' => $request->userAgent(),
|
|
|
+ 'data' => $data,
|
|
|
+ 'raw_body' => $request->getContent(),
|
|
|
+ ];
|
|
|
+ }
|
|
|
}
|