Reputation:
I'm trying to subscribe an authenticated user to a plan with Laravel Cashier. The post request to the Stripe dashboard is marked as a '200 success'.
However, Laravel will throw this exception: Laravel Cashier: Stripe\Exception\InvalidRequestException No such customer: cus_H0zcimyzC93Bay
I'm not entirely sure what this means. The user I'm trying to subscribe has this stripe_id: cus_H0zcimyzC93Bay. So why am I being told there's no such customer with that ID?
I've had a look at this post here: Laravel Cashier + Stripe: No Such Customer and it didn't help me. Although I get the same exception I don't think our solutions are the same.
The solution in that post is to make the relevant database case-insensitive. I think my database is already case-insensitive as I've queried my database for the stripe_id with Tinker and it returns the stripe_id as is: cus_H0zcimyzC93Bay.
I also don't know how to make my database case-insensitive. Besides, I don't think that's the issue.
Here's my code that causes the error:
public function subscribe(Request $request)
{
$user = Auth::user();
$paymentMethod = $request->paymentMethod;
$plan = $request->planId;
// 'create' method will automatically store customers payment method
$user->newSubscription('subscription', $request->plan)->create($paymentMethod, [
'email' => $user->email
]);
redirect()
->route('confirmation')
->with('subscriptionSuccessMessage', 'You have successfully subscribed. See you around!');
}
Upvotes: 1
Views: 997
Reputation: 8747
Almost certainly the Customer is in a different Stripe Account than the Account that this code is currently trying to make use of, either as a result of testing in a different account, or as a result of Connect.
Upvotes: 0