#kaylee_best-practices
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1427228977520574619
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
await stripeClient.subscriptions.update(subscription.stripeSubscriptionId, {
items: [
...stripeSubscription.items.data.map((item) => ({
id: item.id,
deleted: true,
})),
...lineItems.map((item) => ({
price: item.price,
quantity: item.quantity,
})),
],
proration_behavior: 'always_invoice',
billing_cycle_anchor: 'now',
});```
I think i made it clear but let me know if i can elaborate- jsut want to make sure i do this right :D
๐
If you want to forgive/discard usage, when changing from one meter price to another, the usage recorded are lost when setting proration_behavior: 'none'
When i've tested it I seemed to get billed immediatly so my bill would look like $75 instead of the expected $35
Then you probably should set proration_behavior: 'none'
This was with none applied
Can you share the invoice Id ?
in_1SHiJBQl5o0oC79AsbXN8zbR
I went to hobby tier then added usage events manually then ran the upgrade code snippet above with proration_behavior: 'none' to pro tier
Thanks for sharing, checking...
๐ Hey, taking over here, just taking a look
So I think the best approach in this situation would be clear the usage on the meter before you do the upgrade (https://docs.stripe.com/billing/subscriptions/usage-based/meters/configure#fix-incorrect-usage) - setting proration_behaviour to none wouldn't be sufficient for these kinds of charges
It looks like the meter adjustment api only handles 24 hour events? so not sure if this will work
as yesterdays events will still be on the meter
What Aggregation formula are you using with your meter?
sum & sending events currently every hour
Does meters accept negative values? haven't experimented with it, could i send a -10000000 value to it or something to whipe it? although that doesn't sound like a great practice lol
Yes, exactly, that should work
I think that would be the best approach in this situation
Cool I need to pop out but will check if this works when im back in a few hours!
thank you for the help
Shouldn't be any problem with race conditions i assume? between meter update and updating the sub
so close to one another
It should be fine, the change should take effect immediately before the subscription update