#james-subscription-preview
1 messages · Page 1 of 1 (latest)
im getting this error: Currency and interval fields must match across all plans on this subscription. Found mismatch in interval field.
james-subscription-preview
The API for this is a little bit... convoluted if you ask me 😅
What you do basically is simulate a change to the underlying Subscription. So you have to explicitly replace price A by price B in the call
Yes thats annoying
So when you pass https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_items you need to handle existing Prices too
So if your Subscription has one Price A you have a SubscriptionItem si_123 for it. And when you preview a change you need to say "hey imagine si_123 wasn't on Price A anymore but on Price B"
The logic is that if you have 5 Prices, so 5 SubscriptionItems and you want to add a sixth Price all you have to do is pass that 6th Price. So it makes that flow easy but then your flow a bit more confusing
Does that make sense?
so an existing SI can only be edited to another price that has the same interval?
no I didn't say that and it just works
atm i have existing SI's and they have monthly price ids
Stripe::Invoice.upcoming({
customer: 'cus_123',
subscription_items: [
{
id: 'si_123',
price: 'price_Yearly',
},
]
})
something like this should work assuming you have just one Price
i should be able to edit the SI to be an annual price id without deleting the SI ?
correct
thats not working
it is
but if you give detailed information: exact code, exact request id, exact error, I can help.
i found this which suggests you must delete the SI and add the price id again https://stackoverflow.com/questions/54107841/stripe-preview-upcoming-invoice-for-updating-subscription
is the answer in this correct?
I mean yes and no. IT's correct, it answers the question. The question explicitly added a yearly Price, it didn't replace. It's missing the id parameter I explicitly put in my own code
in my example the existing subscription items are like this
subscription_items: [
{
id: 'si_123',
price: 'price_Monthly',
}, {
id: 'si_456',
price: 'price_Monthly',
},
i am trying to do this:
Stripe::Invoice.upcoming({
customer: 'cus_123',
subscription_items: [
{
id: 'si_123',
price: 'price_Yearly',
}, {
id: 'si_456',
price: 'price_Yearly',
},
]
})
That should work. If you give me exact code + exact request id I can help
and getting the error:Currency and interval fields must match across all plans on this subscription. Found mismatch in interval field.
i will double check and come back
i have checked and it definitely doesn't work
this is my code
$invoice = $stripe->invoices->upcoming([
'customer' => $customers_id,
'subscription' => $active_subscription_id,
'subscription_items' => $revised_subscription_items,
'subscription_proration_behavior' => $proration_behaviour
]);