Answer the question
In order to leave comments, you need to log in
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());
}
}
Route::post('/success', '[email protected]');
Route::post('/fail', '[email protected]');
Route::post('/status', '[email protected]');
VerifyCsrfToken extends Middleware
{
protected $addHttpCookie = true;
protected $except = [
'/success',
'/fail',
'/status'
];
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question