What's your question ? Where is the code that generates this error ?
stripe cashier laravel
Stripe\ Exception\ InvalidRequestException PHP 8.1.6 9.35.1 No such customer: 'cus_N8wFxoP3f0Z3MX'
@vincent15000 when I am checkout this error will appear
The exception couldn't be much clearer really. cus_N8wFxoP3f0Z3MX doesn't exist in Stripe. Check that you're not confusing the development mode customer id and a production mode customer id.
@jaseofspades88 Sure, but it's a little borderline just showing the error without any question ;).
@jaseofspades88 when I am checkout this error will appear
@ShamiCanCode As @jaseofspades88 told you, this customer doesn't exist in Stripe. But if you don't give further details (code, ...), it will be difficult to help you.
public function index($id)
{
/** @var User $user */
$user = Auth::user();
$plan = Plan::find($id);
if (!is_null($plan)) {
if ($user->subscribed('gold')) {
return redirect('/home')->with('status', 'You already subscribed to this plan');
} else {
return view('checkout', [
'user' => $user,
'intent' => $user->createSetupIntent(),
'plan' => $plan
]);
}
} else
return redirect('/');
}
public function checkout(Request $request)
{
/** @var User $user */
$user = Auth::user();
$plan = $request->input('plan');
$planType = Plan::where('plan_id', $plan)->pluck('plan_type')->first();
$paymentMethod = $request->input('payment_method');
$user->createOrGetStripeCustomer();
$user->addPaymentMethod($paymentMethod);
$user->newSubscription($planType, $plan)->trialDays($plan->trail_days)
->create($paymentMethod, [
'email' => $user->email
]);
return redirect('/home')->with('status', 'Subscribed successfully! enjoy 😊');
}
index function is when the user clicks a plan checkout function when user fill his debit card information
@ShamiCanCode As the customer doesn't exist, for me there are two possibilities :
-
the user has an existing account on Stripe but you don't retrieve its id correctly
-
the user doesn't have any account on Stripe and
$user->createOrGetStripeCustomer();don't create it on Stripe
Have you checked the datas in the database ?
@vincent15000 when I installed library laravel cashier (stripe) is running ok but sudden it shows me this error
@ShamiCanCode You need to find why you are getting a customer id which doesn't exist in Stripe. Have you tried to create a totally new user ?
$user->createOrGetStripeCustomer(); this assumes the customer id you have stored in the user model is correct. In your case it's either been deleted or the reference has been changed but either way, the customer doesn't exist in stripe. That's the problem here... if you choose to do nothing with that information then it doesn't matter how many times people tell you the same information!
Please or to participate in this conversation.