Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

canadianlover's avatar

Using stripe to process Bitcoin - TokenMismatchException in VerifyCsrfToken.php line 67:

I have just installed the Stripe package for my e-commerce app, and I get this error every time I try to checkout of the site, including test mode. I have the following routes file

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::post('/item/create', ['as' => 'item.store', 'uses' => 'ItemController@store']);
Route::resource('item', 'ItemController');

Route::get('/', function() {
    return view('welcome');
});
Route::auth();


Route::get('/home', 'HomeController@index');
Route::post('/item', 'ItemController@store');
Route::get('/item', 'ItemController@index');
Route::get('/item/{id}', 'ItemController@show');


Route::group(['middleware' => ['web']], function(){
    Route::get('/addItem/{productID}', 'CartController@addItem');
    Route::get('/removeItem/{productID}', 'CartController@removeItem');
    Route::get('/checkout', function() {
        return view('cart.checkout');
    });
    Route::post('/create_payment', function() {
        // Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account/apikeys
        require_once(Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2"));
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account/apikeys
        \Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");

// Get the credit card details submitted by the form
        $token = $_POST['stripeToken'];

// Create the charge on Stripe's servers - this will charge the user's card
        try {
            $charge = \Stripe\Charge::create(array(
                "amount" => 1000, // amount in cents, again
                "currency" => "usd",
                "source" => $token,
                "description" => "Example charge"
            ));
        } catch(\Stripe\Error\Card $e) {
            // The card has been declined
        }
    });

Route::get('/logout', 'Auth\AuthController@getLogout');

// Registration routes...
Route::get('/register', 'Auth\AuthController@getRegister');
Route::post('/register', 'Auth\AuthController@postRegister');

});


//Route


Any ideas?

0 likes
3 replies
zachleigh's avatar

Are you sending the csrf token in the post request?

zachleigh's avatar

This has nothing to do with stripe. This is in your laravel app. Are you sending the data to your app from a view? Api call? Which route is causing this?

Please or to participate in this conversation.