Level 2
I checked in the events, in the developer section of Stripe, and SetupIntent is created.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I'm following this tutorial to create subscriptions via cashier / stripe, unfortunately, however, after entering the test credit card credentials, and sending, this error appears:
Could not determine which URL to request: Stripe\PaymentMethod instance has invalid ID:
I searched around for a while, but I haven't solved it.
public function retrievePlans() {
$key = \config('services.stripe.secret');
$stripe = new \Stripe\StripeClient($key);
$plansraw = $stripe->plans->all();
$plans = $plansraw->data;
foreach($plans as $plan) {
$prod = $stripe->products->retrieve(
$plan->product,[]
);
$plan->product = $prod;
}
return $plans;
}
public function showSubscription() {
$plans = $this->retrievePlans();
$user = Auth::user();
return view('subscribe')->with([
'site_name' => Settings::find('site_name')->value,
'site_description' => __(''),
'page_name' => __('Exclusive Content for Subscribers'),
'categories' => $this->categories,
'user' => $user,
'intent' => $user->createSetupIntent(),
'plans' => $plans
]);
}
public function processSubscription(Request $request)
{
$user = Auth::user();
$paymentMethod = $request->input('payment_method');
$user->createOrGetStripeCustomer();
$user->addPaymentMethod($paymentMethod);
$plan = $request->input('plan');
try {
$user->newSubscription('default', $plan)->create($paymentMethod, [
'email' => $user->email
]);
} catch (\Exception $e) {
return back()->withErrors(['message' => 'Error creating subscription. ' . $e->getMessage()]);
}
return redirect('dashboard');
}
Please or to participate in this conversation.