12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Http\Controllers\Controller;
- use App\Services\DgPayService;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Log;
- class DgPayController extends Controller
- {
-
- protected DgPayService $payService;
-
- public function __construct(DgPayService $payService)
- {
- $this->payService = $payService;
- }
-
- public function notify(Request $request)
- {
-
- $data = $request->all();
- Log::info('DgPay notify:', $data);
-
- if (!$this->payService->verifySign($data)) {
- Log::error('DgPay notify sign verify failed');
- return response('sign error');
- }
-
- try {
-
- if ($data['trade_status'] === 'SUCCESS') {
-
-
-
-
-
- return response('success');
- }
-
- return response('success');
- } catch (\Exception $e) {
- Log::error('DgPay notify process error: ' . $e->getMessage());
- return response('fail');
- }
- }
-
- public function return(Request $request)
- {
-
- $data = $request->all();
- Log::info('DgPay return:', $data);
-
- if (!$this->payService->verifySign($data)) {
- Log::error('DgPay return sign verify failed');
- return response('签名验证失败');
- }
-
-
-
-
- return response()->json([
- 'message' => '支付成功'
- ]);
- }
- }
|