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

zoey7907's avatar

Stripe Laravel create new customer error

I have a program with many authenticated users already. I want add an option for the users to pay for services online using Stripe. I installed Cashier using composer. I want to now go through and create Stripe customers for each of my users. I have these at the beginning of my controller:

use Laravel\Cashier\Cashier; use Laravel\Cashier\Billable;

And here is the function in the controller:

public function ProcessNewStripe(Request $request){
	$Incoming_fields = $request->validate([
		'user_id' =>'required', 'parent' =>'required',
		'starting_balance'=>'required'
	]);
	
	$parent = DB::table('parent_profiles')->where('id', $Incoming_fields['parent'])->first();
	$user = DB::table('users')->where('id', $Incoming_fields['user_id'])->first();
	
	$options=[
		'name' => $parent->first_name." ".$parent->last_name,
		'email' => $parent->email,
		'phone' => $parent->cell_phone,
		'balance' => $Incoming_fields['starting_balance']
	];
	
	$stripeCustomer = $user->createAsStripeCustomer($options);
	
	if ($stripeCustomer) {
		return redirect("/payment-center-admin/$parent->family_profile_id")
			->with('success', "Stripe account created for the $user->family_name Family.");
	}
	else{
		return redirect("/payment-center-admin/$parent->family_profile_id")
			->with('failure', "No Strip account was Created. Contact Robin for details.");
	}
}

But I am getting this error: Call to undefined method stdClass::createAsStripeCustomer()

It would seem that somehow Cashier is not installed properly? I am at a loss. Any help would be greatly appreciated. Thank you!

0 likes
0 replies

Please or to participate in this conversation.