#manuel_api

1 messages ยท Page 1 of 1 (latest)

dark currentBOT
#

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

unreal crow
#

sub_xxx

heady silo
#

yes

#

it is sub_1RACUODtLlgoCDIrC9UaeyMl

unreal crow
#

Ah looks like there's a coupon that applies $276 amount off discount

heady silo
#

yes

#

but after the modification and after the coupon was applied the customer upgraded to add an item

#

14.000 contacts its the product

unreal crow
#

Are you talking about this invoice?
in_1RX4EjDtLlgoCDIr8GyAgoj0

#

or this one? in_1RX4TEDtLlgoCDIrIarsEjlJ

heady silo
#

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?

unreal crow
#

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

heady silo
#

oh ok

#

and the other invoice that says -0.01?

unreal crow
#

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

heady silo
#

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

unreal crow
heady silo
unreal crow
#

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

heady silo
#

oh ok i understand

dark currentBOT
unreal crow
#

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

heady silo
#

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?

slate merlin
#

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?

heady silo
#

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?

slate merlin
heady silo
#

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.

slate merlin
#

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

heady silo
#

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.

slate merlin
#

Ok, give me one sec to think about this

heady silo
#

ok thank you so much ๐Ÿ™๐Ÿป

slate merlin
#

So, do I understand you right:

  1. you want to update the subscription without prorations
  2. apply a coupon to the subscription to reduce the amount to the amount it was before the migration

Is that what I am hearing?

heady silo
#

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=[...]
)

slate merlin
#

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.

heady silo
#

the subscription has a coupon applied after the migration

slate merlin
#

I have a colleague joining us

tidal lily
#

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?

heady silo
#

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.

tidal lily
#

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.

#

Actually, let me triple check that

#

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:

  1. first checks if the Subscription is using your Coupon
  2. remove the Discount if so: https://docs.stripe.com/api/discounts/subscription_delete?api-version=2025-05-28.preview
  3. perform the update
  4. reapply the Coupon after the update so it will be used moving forward
#

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.