You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Laravel Easypay包创建MB参考时无法接收通知回调

Troubleshooting Easypay MB Reference Callback Issues in Laravel

Hey there, let's dig into why you're not receiving the Easypay callback after generating an MB reference. I've debugged quite a few payment integration callback problems, so here are the key areas to check step by step:


1. Verify Callback URL Configuration

First things first:

  • Ensure your callback URL is publicly accessible: Local development environments (like localhost) can't receive external callbacks from Easypay. Use a tool like ngrok to expose your local server to the internet while testing.
  • Whitelist the URL from Laravel's CSRF protection: Since Easypay's callback is an external POST request, Laravel's default CSRF middleware will block it. Add your callback route to the $except array in app/Http/Middleware/VerifyCsrfToken.php:
    protected $except = [
        '/easypay/callback', // Replace with your actual callback route
    ];
    
  • Confirm the URL is set correctly in Easypay's dashboard: Log into your Easypay account and double-check that the callback URL matches exactly what you're using in your app (including HTTP/HTTPS).

2. Check Your Callback Route & Controller Setup

  • Define the route as a POST request: Easypay sends callback data via POST, so your route should reflect that:
    // routes/web.php or routes/api.php
    Route::post('/easypay/callback', [PaymentController::class, 'handleEasypayCallback']);
    
  • Ensure your controller method can process the request: Make sure you're accepting the request and returning a valid response (Easypay often expects a simple 200 OK to confirm receipt). Here's a basic example:
    public function handleEasypayCallback(Request $request)
    {
        // First, validate the callback authenticity (critical for security)
        $easypay = new EasyPay();
        // Check the package docs for the correct verification method (e.g., verifyCallback)
        $isValid = $easypay->verifyCallback($request->all());
    
        if (!$isValid) {
            Log::warning('Invalid Easypay callback received', $request->all());
            return response('Invalid', 403);
        }
    
        // Extract relevant data from the callback
        $reference = $request->input('ep_reference');
        $status = $request->input('ep_status');
        $amount = $request->input('t_value');
    
        // Update your order/payment record here
        // Example: Payment::where('reference', $reference)->update(['status' => $status]);
    
        // Return a success response to let Easypay know you received the callback
        return response('OK', 200);
    }
    

3. Check if You're Specifying the Callback During Reference Creation

Some payment integrations require you to pass the callback URL when creating the reference. Double-check if the Easypay package expects a url_callback (or similar) parameter in your $payment_info array:

$payment_info = [
    't_value' => $amount,
    'o_obs' => '',
    't_key' => 1,
    'url_callback' => route('easypay.callback') // Add this if required
];

4. Debug with Logs

  • Check Laravel's logs: Look in storage/logs/laravel.log for any errors related to the callback request (e.g., 419 CSRF errors, 404 route not found, or exceptions in your controller).
  • Check Easypay's notification history: Log into your Easypay dashboard and look for failed callback attempts. It will often show details like connection errors, invalid response codes, or timeout issues.

5. Test the Callback Manually

Use a tool like Postman or curl to simulate an Easypay callback request. Send a POST to your callback URL with sample parameters matching what Easypay would send (check their docs for the exact parameter names). This will help you isolate whether the issue is with Easypay sending the request or your app not handling it.


内容的提问来源于stack exchange,提问作者user9659025

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:45:46