#kaylee_best-practices

1 messages ยท Page 1 of 1 (latest)

inland perchBOT
#

๐Ÿ‘‹ 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.

wheat orchid
#
        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

merry merlin
#

๐Ÿ‘‹
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'

wheat orchid
#

When i've tested it I seemed to get billed immediatly so my bill would look like $75 instead of the expected $35

merry merlin
#

Then you probably should set proration_behavior: 'none'

wheat orchid
#

This was with none applied

merry merlin
wheat orchid
#

I went to hobby tier then added usage events manually then ran the upgrade code snippet above with proration_behavior: 'none' to pro tier

merry merlin
#

Thanks for sharing, checking...

inland perchBOT
inner veldt
#

๐Ÿ‘‹ Hey, taking over here, just taking a look

wheat orchid
#

as yesterdays events will still be on the meter

inner veldt
#

What Aggregation formula are you using with your meter?

wheat orchid
#

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

inner veldt
#

Yes, exactly, that should work

#

I think that would be the best approach in this situation

wheat orchid
#

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

inner veldt
#

It should be fine, the change should take effect immediately before the subscription update