always helpful to say which line throws the error
You can use the stack trace to see the calling line of your action
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an action class to create a subscription and my User model has the Billable trait. in my database I can see stripe_id, pm_type and pm_last_four values and on stripe dashboard user is there but when I try to create a subscription I get call to member function stripe() on null. Below is my snippet, did I miss something?
try {
Stripe::setApiKey(config('cashier.secret'));
$user = $request->user();
if (! $user->hasStripeId()) {
$user->createAsStripeCustomer();
}
$setupIntent = SetupIntent::retrieve($request->setup_intent);
$user->updateDefaultPaymentMethod($setupIntent->payment_method);
$user->save();
License::create([
'unit_price' => $request->unit_price,
'quantity' => $request->quantity,
'total_price' => $request->unit_price * $request->quantity,
'status' => 'active',
'payment_method' => $setupIntent->payment_method,
'user_id' => $user->id,
]);
$user->newSubscription('default', 'price_1R7ZzjLCIwOX44eiG2msya0I')
->quantity($request->quantity)
->create($setupIntent->payment_method);
return 'success';
} catch (Exception $e) {
Log::error('Error occurred while processing purchase: '.$e->getMessage());
return 'error';
}
Please or to participate in this conversation.