#beastboy_code
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/1328467532696256557
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- beastboy_code, 1 hour ago, 53 messages
- beastboy_subscription-updates-manual-prorations, 4 days ago, 113 messages
await stripe.subscriptions.update(subscription.id, {
add_invoice_items: [
{
price_data: {
currency: 'USD',
product: product_id,
unit_amount: -newPrice.unit_amount,
},
},
],
...(shouldCreateJobAfterPaid && {
metadata: {
process_next_zero_invoice_paid: 'true',
},
}),
trial_end: 'now',
});
await stripe.subscriptions.update(
stripe_subscription_id,
{
items: [
{
id: subscription.items.data[0].id,
price: new_price_id,
},
],
proration_behavior: 'none',
},
);
I have this code that I run when going from product A ($445, on trial) to product B ($289). Ideally this piece of code should immediately update the product subscription's product to B and charge nothing (we have seperate code that will issue a refund).
I realize these 2 requests can be combined, but when I try to run this here
req_1aTLZkdmc95LjF
and req_lza48wWQjZdJB8
the user instead gets billed the difference
How do I get it so that the user is not billed anything?
req_mPqDoyzbBvbw2N
Or it looks like combining them gets it to work..?
Hello, thanks for the example, looking in to this
I am still trying to look in to this. I am not going to lie a downside of this integration is going to be that it is very complicated and hard to look in to from our side on any question like this. There are so many updates and trials it is hard to keep track of what actually got set to what and when
Sorry that was put fairly unprofessionally on my part. I do think that complication is something to keep in mind though. While I'm looking, can you tell me a bit about why you are managing the subscription like this with trials and credit notes that ultimately mean $0 invoices?
I feel like my use case is very simple:
I'm just trying to implement a function that will update a customer from product A -> B and either charge them or credit the difference between the absolute costs of each product.
It should be able handle subscriptions on different cadencies and on trials too.
No problem at all, i understand this is complicated - I'm pulling my hair out too! To answer your question, we use free trials when we want to push back a customer's subscription renewal date by X amount of days - is this the correct way to do it?
That's how we were advi
advised
And the reason that our standard proration behavior won't work here is because of the trials if I understand this correctly?
No its because we're selling physical products, so we're not dealing w time based prorations at all
The use case is:
Patient pays for product A, realizes they dont want product A (we havent shipped it to them yet) and then wants to swap to product B. So we want to call this function to charge / credit them the difference and put them on this new product
For charging the difference, one thing that may help is the proration_date parameter, if you pass it, we prorate as if the proration happened at that timestamp. I think that can help here because if you pass the time when the subscription started, it will prorate full price against full price https://docs.stripe.com/api/subscriptions/update#update_subscription-proration_date
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I am not fully sure how that comes in to play with the trials. To make sure I understand, this is a separrate thing from switching these prices correct? And will you always be pushing it back or will it sometimes move up too? Trials are a good way to do that, but I'll try to think of if there is anything that can simplify this.
Okay lmk if you do
I think my current code setup works
There are 16 diff test cases to test... (combinations of cadencies and on/off trial)
And so far it's working correctly so I may have just brute forced this correctly haha
But it's so scary cause who knows what other edge cases may appaer
Yeah not finding anything else for pushing back the anchor. Looking back in to that initial example to see how you could have prevented that charge
Oh you already figured that out 🤦
@knotty perch I'm stepping in for my teammate