D
D
D3V1L2019-12-01 01:45:58
API
D3V1L, 2019-12-01 01:45:58

Laravel IPN notifications not coming?

I have a question. About two years ago, I tried to put Payeer on Laravel, but to no avail. I ran into a problem on my configured routes, IPN notification simply does not come. I got out of the situation by creating a separate php file in the public directory, but these are crutches.
Now I'm already working with another system, PrimePayeer, I have more experience, but the situation is similar, I'm trying to figure it out and I can't find a solution anywhere. Notification immediately comes to a separate file in the /public directory. And for the function according to the following settings - no
Functions:

public function success() {
    Storage::put('success.txt', 'no ip check');
    return view('payment.success');
}

public function fail() {
    return view('payment.fail');
}

public function status(Request $request) {
    Storage::put('notok.txt', 'no ip check');
    try {
        $secret = env('PRIMEPAYER_SECRET');

        Storage::put('ok.txt', 'no ip check');

        if (!in_array(request()->ip(), ['109.120.152.109', '145.239.84.249', true])) {
            exit();
        }

        Storage::put('user.txt', 'user_id: '.$request->uv_user);

        $sign = $request->sign;
        unset($request->sign);

        $data = $request->all();

        ksort($data,SORT_STRING);
        $signi = hash('sha256', implode(':', $data).':'.$secret);

        if($signi !== $sign) {
            Storage::put('log.txt', $signi.'\n\n'.$sign.'\n'.'Incorrect Sign');
        }

        $user = User::findOrFail($request->uv_user);
        $user->balance += $request->amount;
        $user->save();

        return response()->setStatusCode(200);
    } catch (\Exception $e) {
        Storage::put('errors.txt', $e->getMessage());
    }
}

web.php:
Route::post('/success', '[email protected]');
Route::post('/fail', '[email protected]');
Route::post('/status', '[email protected]');

VerifyCSRF Middleware:
VerifyCsrfToken extends Middleware
{
    protected $addHttpCookie = true;

    protected $except = [
        '/success',
        '/fail',
        '/status'
    ];
}

Regarding the files in the status function. None have ever been created. Which means that either the notification received code 500, or some other status code that does not even allow elementary functions to be executed.
I really want to finally sort out IPN, because payments are a sore subject. Who faced, please tell me how to solve :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D3V1L, 2021-01-22
@D3V1L

After a long time, I quite accidentally realized what the problem was)
The fact is that all status check URLs must be entered in the $except variable, in the VerifyCSRFToken.php middleware, which will simply issue 419 | Page Expired on external post requests.
Hope it helps someone)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question