Did you import Cashier class?
use Laravel\Cashier\Cashier;
Docs: https://laravel.com/docs/8.x/billing#retrieving-customers
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
When I create new user with Laravel 8 and Jetstream, I want to create a Stripe customer. So this is my code :
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'company' => ['required', 'string', 'max:40', 'unique:users'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => $this->passwordRules(),
])->validate();
$user = Cashier::findBillable(config('secret_key'));
$stripeCustomer = $user->createAsStripeCustomer(
array(
'description' => $input['company'] . '.pieja.fr',
'email' => $input['email'],
)
);
return User::create([
'name' => $input['name'],
'email' => $input['email'],
'company' => $input['company'],
'stripe_id' => $stripeCustomer['id'],
'password' => Hash::make($input['password']),
]);
But I have this error Class 'App\Actions\Fortify\Cashier' not found
How to solve this ?
Thank you
Here you have to pass $stripeId and not secret key
$user = Cashier::findBillable($stripeId);
But you you haven't created a user yet.
It should be
$user = User::create([
'name' => $input['name'],
'email' => $input['email'],
'company' => $input['company'],
'password' => Hash::make($input['password'])
]);
$user->createAsStripeCustomer([
'description' => $input['company'] . '.pieja.fr',
'email' => $input['email']
]);
return $user;
And stripe_id has to be nullable in the users table.
Here you can see https://github.com/laravel/cashier-stripe/blob/12.x/src/Concerns/ManagesCustomer.php#L73 that stripe_id is setted automatically to the user.
Btw I've never used a cashier.
Please or to participate in this conversation.