Stripe is integrated into Laravel. When I created a new subscription in Stripe. I faced the issue like
Stripe \ Exception \ InvalidRequestException
No such price: 'false'
My code is
$plan = Plan::find($request->plan);
$amount = $request->amount;
$amount = $amount * 100;
$paymentMethod = $request->payment_method;
$user = auth()->user();
$user->createOrGetStripeCustomer();
if ($paymentMethod != null) {
$paymentMethod = $user->addPaymentMethod($paymentMethod);
}
$paymentId = $paymentMethod->id;
$stripe = $user->newSubscription(
'default', $plan
)->create( $paymentId);`enter code here`
sometimes I faced this type of error
The payment attempt failed because additional action is required before it can be completed.
$stripe = new \Stripe\StripeClient('sk_test_51NFuj0SHUnJwHMxFEUsvAR28qEzpJPeMepvnSFkUoMXexwa1hZHJRwqXVwCnW4L4qxcqdZ0L9HyCWKj4QVTYW0Av00xy4OFdR2');
$subscription = $stripe->subscriptions->create([
'customer' => $paymentMethod->customer,
'items' => [[
'price' => $plan->stripe_plan,
]],
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
]);