#manuel_api
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/1380627601453879458
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
We have a doc that talks about how proration works on Stripe - https://docs.stripe.com/billing/subscriptions/prorations#how-prorations-work
Can you share the Subscription ID you're working with?
sub_xxx
Ah looks like there's a coupon that applies $276 amount off discount
yes
but after the modification and after the coupon was applied the customer upgraded to add an item
14.000 contacts its the product
Are you talking about this invoice?
in_1RX4EjDtLlgoCDIr8GyAgoj0
or this one? in_1RX4TEDtLlgoCDIrIarsEjlJ
in_1RX4EjDtLlgoCDIr8GyAgoj0 is the modification of the subscription
and in_1RX4TEDtLlgoCDIrIarsEjlJ is the upgrade when the customer buyed additional contacts
if the customer made an upgrade shouldn't be 0.00 because he bought additional items, right?
No, the coupon applies to each Invoice.
So if the total of the invoice amount is less than the coupon amount then the invoice will be $0.
For in_1RX4TEDtLlgoCDIrIarsEjlJ you have two invoice items
ii_1RX4TEDtLlgoCDIrimSrM61n - Tiempo sin uso de 9000 ร .. => $45
ii_1RX4TEDtLlgoCDIrI8m53bt7 - Tiempo restante de 14000 ร ... => $70
The total amount is less than the coupon ($276) amount
that's why invoice amount is $0
that's the remaining amount from the previous invoice in_1RX4EjDtLlgoCDIr8GyAgoj0
That invoice had multiple invoice items but the offset there was the proration you received from the invoice before that (in_1RWJYzDtLlgoCDIrtk4iOGqG)
Like there's a $ -165.68 proration item that is more than the total of the other prorated invoice items
oh ok, i'm starting to understand
but it seems strange to me that when the upgrade is done the coupon is placed, should that happen, is it normal?
i'm not adding the cupon via API when the suscription is upgrading
The coupon was applied to the subscription here - https://dashboard.stripe.com/logs/req_CP1lT5tqzi4BLU
So it'll apply to all subsequent invoices unless you unset it explicitly.
You can use this API endpoint to delete the currently applied discount - https://docs.stripe.com/api/discounts/subscription_delete
yes, in this step it is ok to be applied for the subscription as I have it but I mean when the customer buy the additional 14,000 contacts?
When you apply the coupon to the subscription, it applies to all of it's subsequent invoices unless you unset it.
We don't remove it after just one invoice
oh ok i understand
This is also because the duration of your coupon is set to "forever"
If you want to only apply once then the coupon duration needs to be set to once instead
ok ok
ugh its complicated then for me haha
but the idea is to leave the coupon in place forever even if the customers upgrade.
so i will always have this problem?
Hi there,
I am taking over from my colleague who had to step away.
When you say "leave the coupon in place" what exactly do you mean by that?
apply the coupon in the subscription forever
and if i set the coupon with a duration of "once" it will disappear after the first payment, right?
can i have more information about this parameter and their options?
The discount will disappear after the following payment. If that coupon is applied when the subscription is created the discount is applied to the first payment. If you apply the discount after the subscription already got created, it applies to the next following payment.
ok i understand thank you
that makes sense obv but then I need the coupon to stay active in the subscription and when purchases are made related to the items in that subscription it does not apply to them. Is there a way to do that?
so as not to receive invoices with a 0.00 balance.
I am a bit confused about what you are trying to accomplish. Can you describe with a few words, what your actual goal is and want the subscription and the coupon to behave?
I just want to be on the same page with you so I can beter support
ok no problem
Well what happens is that in our project we are doing a migration where we are moving the old subscriptions to the new business model, so that the customers upgrade the subscription they will have more items but they will have to pay more than before the migration. The solution? apply a coupon so that they continue paying what they did before, everything OK but the problem is that after having migrated and users want to add more products to their subscription the coupon is applied to other invoices and the idea is that this does not happen in the following purchases to add items to the subscription only when they have to pay their annual or monthly recurrence renewal.
Ok, give me one sec to think about this
ok thank you so much ๐๐ป
So, do I understand you right:
- you want to update the subscription without prorations
- apply a coupon to the subscription to reduce the amount to the amount it was before the migration
Is that what I am hearing?
the second point its correct but the first one idk how to manage the situation ๐
what would happen if the proration is eliminated when the customers buy additional items after the migration?
like:
stripe.Subscription.modify(
subscription_id,
proration_behavior="none",
items=[...]
)
What do you mean by buying additional items after migration? The proration behavior for the subscription update and adding additional items to the subscription are not related.
but i dont understand this then if you say that
the subscription has a coupon applied after the migration
I have a colleague joining us
Hi there ๐ jumping in as I've been following along and helping.
I want to understand what it is that you actually want to do, rather than what you have tried to do already.
I'm getting the impression that the approach you used to attempt to solve this problem, isn't the best approach for what you're trying to do. I would like to try to see if we can find the best approach for doing the migration (but I also see the Subscription you're referring to here is from livemode, so if you've already done your migration for all your livemode Subscriptions, that may be moot).
So I guess, let's start with clarifying, are you trying to figure out how to structure your migration script, or are you trying to figure out how to do something else for your already migrated Subscriptions?
I am trying to understand why invoices are generated in 0.00 and how can I avoid them since we don't want that in my project. The idea is that if they buy more items to add to the subscription after a coupon has been applied to the subscription as such it does not apply to the rest of the invoices as a consequence.
Let me take another pass through the two Invoices you referenced, and see if I can clearly articulate why each one charged the amount it did.
For in_1RX4EjDtLlgoCDIr8GyAgoj0
This Invoice charged an amount of -0.01, and since that is below our 0.50 minimum for payments, the 1 cent credit is simply applied to the customer's balance.
That Invoice did not use the Coupon you applied. Since this Invoice is only charging the customer for the prorations of the upgrade, it does not use Coupons currently on the Subscription. Instead it would use the same Coupons that were applied to the Invoice it is calculating proration amounts based on (the previous Invoice: in_1RWJYzDtLlgoCDIrtk4iOGqG)
The request that led to that Invoice being created, had proration_behavior set to always_invoice
https://dashboard.stripe.com/logs/req_CP1lT5tqzi4BLU
That tells our system to calculate the prorated amount the customer should be charged for the update (by calculating how much they should be credited for what they paid in the previous invoice, and how much they should be charged for the remaining time in the new billing period for the new Prices). The difference in those amounts for this Invoice was -1 cent.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Actually, let me triple check that
Okay, sorry, I'm pretty sure I'm wrong there, and that Invoice did use the Discount. It's easy to overlook because the discount amount isn't shown as a separate discount amount when it's used to discount prorations:
https://docs.stripe.com/billing/subscriptions/prorations#prorations-and-discounts
This is really tricky, because it sounds like you want to apply a Coupon that consistently discounts the amount that the Customer is charged for the Subscription, but that you also don't want that to consistently apply to all Invoices. Which isn't something we support easily.
You could build that logic, by consistently applying single-use Coupons (duration = once) shortly before the Subscription's cycle to their new billing period, but that approach may be pretty brittle.
The other thing coming to mind, is to change your Subscription logic so that it:
- first checks if the Subscription is using your Coupon
- remove the Discount if so: https://docs.stripe.com/api/discounts/subscription_delete?api-version=2025-05-28.preview
- perform the update
- reapply the Coupon after the update so it will be used moving forward
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
We need to be finish closing this server for the week shortly. If you have immediate questions/concerns about those options, I'm happy to chat through them for another couple minutes.