微信回调日志
parent
d542fbf3d4
commit
bad2e3a4f1
|
|
@ -11,6 +11,7 @@ use App\Services\WeChatPayService;
|
|||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
class WeChatPayController extends Controller
|
||||
|
|
@ -24,6 +25,8 @@ class WeChatPayController extends Controller
|
|||
public function orderPaidNotify(WeChatPayService $weChatPayService)
|
||||
{
|
||||
return $weChatPayService->handlePaidNotify(function ($message, $fail) {
|
||||
$this->log('order paid notify', $message);
|
||||
|
||||
// 通信失败
|
||||
if (data_get($message, 'return_code') !== 'SUCCESS') {
|
||||
return $fail('通信失败');
|
||||
|
|
@ -62,6 +65,8 @@ class WeChatPayController extends Controller
|
|||
public function orderRefundedNotify(WeChatPayService $weChatPayService)
|
||||
{
|
||||
return $weChatPayService->handleRefundedNotify(function ($message, $reqInfo, $fail) {
|
||||
$this->log('order refunded notify', $reqInfo);
|
||||
|
||||
// 通信失败
|
||||
if (data_get($message, 'return_code') !== 'SUCCESS') {
|
||||
return $fail('通信失败');
|
||||
|
|
@ -80,4 +85,19 @@ class WeChatPayController extends Controller
|
|||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信回调日志
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $context
|
||||
* @return void
|
||||
*/
|
||||
protected function log(string $message, array $context = [])
|
||||
{
|
||||
return Log::build([
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/wxpay.log'),
|
||||
])->info($message, $context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ class WeChatPayService
|
|||
public static $allowTradeTypes = [
|
||||
self::TRADE_TYPE_JSAPI,
|
||||
self::TRADE_TYPE_APP,
|
||||
self::TRADE_TYPE_H5,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue