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

Xron's avatar
Level 1

Stripe - Stripe' not found

I'm trying to setup a one-time payment using the stripe payment gateway, I've handled the ajax request to stripe and I get back my token to say everything checks out (using sandbox). I'm trying to charge the card in my controller but I'm getting the following error;

Class 'App\Http\Controllers\Stripe' not found

This is my code so far -

<?php
namespace App\Http\Controllers;

use Laravel\Cashier\Billable;
use Auth;
use App\User;
use Illuminate\Support\Facades\Request;
use Stripe;

class pricingController extends Controller {

    public function getIndex() {
        return view('pricing.index');
    }

    public function postPayment(Request $request) {

        $token = Request::input('stripeToken');

        Stripe::setApiKey(Config::get('stripe.secret_key'));

        try {
            return Stripe_Charge::create([
                'amount' => 1000,
                'currenct' => 'gbp',
                'description' => Auth::user()->email,
                'card' => $token,
            ]);
        } catch(Stripe_CardError $e) {
            dd('card declined');
        }
    }
}
0 likes
4 replies
willvincent's avatar

add use Stripe to the top of the file, by the other use statements. It's looking for the Stripe class within the Controllers namespace, but Stripe is a facade that lives in the root namespace. So either include the use statement, or prefix it with a backslash within your postPayment method/etc.

Xron's avatar
Level 1

Hi thanks for the reply, adding use Stripe; throws Class 'Stripe' not found

has the stripe classes changed? because I'm including the Laravel cashier should I include stripe instead?

Please or to participate in this conversation.