I'm having some trouble trying to implement Cashier (Stripe) into my Laravel application.
What I'm trying to do is create a new subscription on an already existing customer (company). But when I do so I get the following error:
You cannot set the quantity for metered plans.
This is what I tried to do:
$company = Company::find(1);
$company->newSubscription('prod_GTnWPCpstGje6M', 'plan_GTnaYrAIhB6jBV')->create();
In the laravel documentation I found this
$user->newSubscription('main', 'premium')->create($paymentMethod);
but as far as I understand, if the customer already exists I don't need to pass a paymentMethod in the create() method, since it pairs with the stripe_id in the database.
In case the paymentmethod was required I also tried like this:
$company = Company::find(1);
$paymentMethod = $company->defaultPaymentMethod()->id;
$company->newSubscription('prod_GTnWPCpstGje6M', 'plan_GTnaYrAIhB6jBV')->create($paymentMethod);
But I get the same error message.
In the Stripe dashboard I found this request body in the error log:
{
"expand": {
"0": "latest_invoice.payment_intent"
},
"plan": "plan_GTnaYrAIhB6jBV",
"quantity": "1",
"off_session": "true"
}
So the newSubscription() apparently passes a quantity of 1 by default.
So back to my question: How do I create a new metered subscription on an existing customer without passing a quantity?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire