do you have in your form hidden input field with token value?
<input type="hidden" name="_token" value="{ { csrf_token() } }">
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am making an ecommerce web application using Laravel 5.
Now I am stuck at the payment integration. I am using CCAvenue as my payment integration, but there is no support provided from the ccavenue itself for laravel framework.
So, after a bit of research, I got this package called Indipay. This package works completely fine. However, I get TokenMismatchException. Though the transaction is successful and I do get the notification of the payment being received.
routes.php
Route::post('/store/proceed-to-checkout', 'CheckoutController@proceedToCheckout');
Route::get('/store/thank-you', 'PagesController@getThankYou');
CheckoutController.php
public function proceedToCheckout(Request $request)
{
$orderCode = Order::latest()->limit(1)->first();
$newOrderCode = ($orderCode) ? ++$orderCode->order_code : 'ORD-000000001';
$parameters = [
'merchant_id' => $request->get('merchant_id'),
'currency' => $request->get('currency'),
'redirect_url' => $request->get('redirect_url'),
'cancel_url' => $request->get('cancel_url'),
'language' => 'EN',
'order_id' => $newOrderCode,
'actionId' => $request->get('actionID'),
'TxnType' => $request->get('TxnType'),
'amount' => $request->get('amount'),
'tid' => time().rand(111,999)
];
return Indipay::purchase($parameters);
}
PagesController.php
public function getThankYou(Request $request)
{
$ordCode = Session::get('ordCode');
$response = Indipay::response($request);
dd($response);
//return view('version-seven.pages.thank_you', compact('ordCode'));
}
Kernel.php
<?php namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel {
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession',
//'App\Http\Middleware\VerifyCsrfToken',
'App\Http\Middleware\VerifyCsrfMiddleware',
];
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
'admin' => 'App\Http\Middleware\AdminAuthentication',
];
}
Yeah.. It was the configuration of the package that I didn't care to configure correctly. In that, they had asked to change the value of remove_csrf_check, and I had kept it as default only. Changing that to store/thank-you did the work.
I appreciate the help you did to me. I was not knowing that we can also remove specific routes from hitting the middleware. Thank you for that..
Please or to participate in this conversation.