Cashier: newSubscription doesn't create Stripe user
It's not clear from the documentation but, from what I've gleaned anecdotally from others' comments and examples, the newSubscription function is supposed to:
a. take the token as created in createToken()
b. create customer in Stripe
c. associate a new subscription with that new customer
d. update Laravel databases accordingly
Is this correct? In my testing, I always get the same message:
"message": "No such customer: tok_********************", "exception": "Stripe\Error\InvalidRequest",
because Cashier has not in fact created a Stripe user using my token.
Apologies if I'm missing something obvious. Are we supposed to use the Stripe PHP to create Customer and THEN use Cashier to associate a subscription to that customer?
with that token, but no Stripe Customer has been created, so it always fails: there's no Stripe Customer to associate the subscription with. That's why I'm assuming there must be another step, either with Cashier, or via the Stripe PHP, that creates the Stripe Customer?
Sorry, I should have explained, $request in my code above represents the Stripe token, I don't need to specify $request->token
I guess I'm not really asking for coding help, my question is more conceptual: is the newSubscription function actually supposed to create a Stripe Customer?
The documentation suggests that as long as I have a User record in my database with the stripe_id (tok_****) defined for it, the newSubscription function will somehow both create the Stripe user with that token associated, and then add a Subscription for that User, both in Stripe and in the database. That doesn't happen for me: calling newSubscription doesn't create a Stripe Customer, so the subscription part always fails.
Turns out that the term "stripe_id" in the documentation, Laravel means the Stripe Customer ID (cus_1234), although I don't see that that's explicitly defined anywhere. So I was mistakenly saving the Stripe token as stripe_id (tok_1234), and then trying to add the subscription to the user later, which doesn't work. Maybe this is intuitive to people who've used Laravel extensively.