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.
May 27, 2016
4
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');
}
}
}
Please or to participate in this conversation.