'Creating Subscription using cashier in stripe return No such price: 'prod_L1SZUHkXQUDIKY'
I am creating a stripe subscription with Laravel cashier but unable to create the subscription, it's throwing the error no such price found, my product is created in the stripe and I am getting it from blade and passing to newScription method.
My Controller Code
Customer is creating but subscription is not creating
$stripeCustomer = null;
if (is_null($user->stripe_id))
{
$stripeCustomer = $user->createAsStripeCustomer();
}
$user->newSubscription('test', $request->plan)
->create($paymentMethod, ['email' => $user->email]);
// $request->plan = it's returning this product prod_L1SZUHkXQUDIKY
Solution 1:[1]
When creating a Subscription object with Stripe, you need to pass a Price object (price_xxx). In the example you've shared, you're passing a Product object.
Products can have multiple prices. For example, you might have a single recurring service you offer but have both a monthly and an annual price. You can learn more about this on Stripe's documentation.
Solution 2:[2]
My payment method is returning null, that's why it's throwing this error. when I passed the payment object then it worked
$user = Auth::user();
$paymentMethod = $request->payment_method;
$user->addPaymentMethod($paymentMethod);
$plan = $request->plan;
$plan = json_decode($plan);
$user->newSubscription($plan->name, $plan->plan_id)->create($paymentMethod, [
'email' => $user->email,
]);
user email is optional stuff
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jonathan Steele |
| Solution 2 | HadiNiazi |
