#cristian_unexpected

1 messages ยท Page 1 of 1 (latest)

dusk pagodaBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

worn shuttle
#

Coupon ID: zcDKxZWn

#

I have also tested increasing the quantity of the subscription, and the additions are being charged as expected

sturdy ginkgo
worn shuttle
#

but on renewal, the discounts are still applied

worn shuttle
#

My understanding is that if I apply a US$ X amount of an only once coupon, we would only give X amount of discount once, regardless of renewal or future add-ons in the subscription

sturdy ginkgo
worn shuttle
#

The coupon was created in the dashboard, the ID is zcDKxZWn

#

The request that created the subscription is:

#

req_z77xPOeYrAOZdi

#

This is the event that finalized the invoice: evt_1RGn5qABXG7iwsUNRcUbGF9Z

#

The request used to pay the invoice: req_SnwCS7kmFJuvgw

sturdy ginkgo
#

Do you have another example where you advance the time and it created an invoice with the coupon applied again?

worn shuttle
#

yes, one second

dusk pagodaBOT
worn shuttle
#

sub_1RGnjUABXG7iwsUNf3eevsnU

#

This is the renewal invoice that had the discount applied: in_1RGnjwABXG7iwsUNapcY91jv

#

no request ids as this was all done in Stripe

sterile night
#

Hi, jumping in for my colleague here. There will still be Request IDs in the logs. I'm looking at things now.

worn shuttle
#

Cant find anything in the logs

#

I have the event ID:
evt_1RGnk7ABXG7iwsUNmntUaFCt

sterile night
#

The renewal invoice will have the discount applied

Where are you seeing this?

#

And have you moved the clock forward enough for it to actually create the Invoice and see if it includes the coupon?

worn shuttle
sterile night
#

wat

worn shuttle
#

Now I will advance the clock one more year

sterile night
#

Can you share those IDs first please?

#

Or second, doesn't matter. ๐Ÿ™‚

worn shuttle
#

Next renewal the discount is not applied :S

#

First invoice: in_1RGnjUABXG7iwsUNMHOYvfxe
Second invoice: in_1RGnjwABXG7iwsUNapcY91jv
Third invoice: in_1RGntxABXG7iwsUNiFFwmehz

#

third invoice

sterile night
#

It looks like you booped the test clock forward like 1 second after the first invoice went through; is that right?

worn shuttle
#

?

#

What do you mean?

sterile night
#

First invoice was paid at 2025-04-22 20:47:59 UTC.
Second invoice was paid at 2025-04-22 20:48:24 UTC

The only way the second would have happened ~25 seconds after the first is if you immediately turned the test clock forward by a year.

Is my assumption correct?

worn shuttle
#

I advanced the clock manually via the dashboard, not via API

#

So after I created the subscription on our platform I navigated to Stripe, clicked in the subscription and advanced the clock

#

I can repeat the test and wait a couple of minutes if that can help

sterile night
#

If you can try that that'd be awesome. My tummy tells me this might be a timing issue.

worn shuttle
#

on it

#

Alright, subscription created:

sub_1RGo44ABXG7iwsUNsulQNx5X

Invoice:

in_1RGo44ABXG7iwsUN291LeFWF

#

Let me know when you want me to advance the clock

sterile night
#

Go ahead. ๐Ÿ‘

worn shuttle
#

Advancing the clock...

#

Same result:

in_1RGo7pABXG7iwsUNGFPE5TYi

#

One thing to note, this subscription did not have the clock advanced:
sub_1RGn5lABXG7iwsUNVP4UzwDi

and the upcoming invoice already has the discount applied

sterile night
#

Very weird.

worn shuttle
#

I did the same test with another type of coupon (ie. valid for 12 months) and the renewal invoice did not have a discount

#

But that doesnt work for us as adding products to a subscription would have the discount in the span of those 12 months

sterile night
#

Ok I'm digging at the moment again. ๐Ÿ™‚

worn shuttle
#

Thank you!

sterile night
#

So in_1RGo7pABXG7iwsUNGFPE5TYi was created by advancing the clock past the 'renewal date', ya?

#

Just want to confirm.

worn shuttle
#

Yes, I advanced the clock one year + one day

#

Just to make sure there was time to compute everything

sterile night
#

My thought/worry there was "if the coupon is updated asynchronously on our end, maybe it didn't update" but I think we've likely disproved that at this point.

worn shuttle
#

After we created the subscription on our platform, we dont do any API calls from our end

#

Everything is sourced from your end (advancing the clock in the dashboard, invoice created by Stripe on renewal)

worn shuttle
#

as the estimated upcoming invoice already has the coupon applied

sterile night
#

"proves" is a strong word but ... ya. Can you try this with a new, fresh coupon too?

worn shuttle
#

Another interesting scenario I have tested:

  1. Create subscription
  2. Add quantity to the subscription
  3. Check invoices
    3.a Initial invoice is $0
    3.b update invoice is $500
  4. Advance the clock one year until the new cycle
    5.a Renewal invoice is $500 (but should be $1000)
worn shuttle
#

Sure thing, new coupon: EtVFggTW

sterile night
#

What does 'update invoice' mean? Upcoming invoice, or did you change it?

worn shuttle
#

I mean the invoice from the subscription update (changed quantity from 1 to 2)

#

New subscription with new coupon: sub_1RGocTABXG7iwsUNPGvEOZ3x

#

Same outcome

sterile night
#

Ok, I have the answer.

#

The Customer you're using has that Coupon too. So once on the Customer, once on the Subscription, equals twice - which is the behaviour we're observing.

#

If you start from scratch with a fresh Customer, that should solve this.

worn shuttle
#

Yes, we apply the coupon to the customer, and when we create the subscription via API we know which coupon the customer has assigned, so we include it in the subscription creation

sterile night
#

Right, so now there are two usages available for that Subscription, so the first two get $500 off.

#

Which is a) exactly what's happening, and b) not what you want. So you need to only put the coupon on one of those places - either the Customer (which could then apply to any Subscription), or the Subscription (which is unsurprisingly Subscription-specific).

worn shuttle
#

Interesting

#

Let me run a test, I will comment the part where we add the coupon to the subscription

#

You nailed it!

#

Great find ๐Ÿ™‚

sterile night
#

Awesome! \o/

#

Does the issue make sense? Do you understand what caused it?

worn shuttle
#

It does, it kind of duplicated the coupon

sterile night
#

"Doubled up" is slightly better than "duplicated" maybe, but yes.

worn shuttle
#

The first invoice applied the coupon that was given to the subscription, the renewal used the coupon at the customer level

sterile night
#

Actually I think the other way around, but exactly.

worn shuttle
#

So if I were to create 10 subscriptions, each one with a only once coupon, it makes sense to have it applied multiple times

#

that would lead to a race condition to determine which subscription would use the only once coupon

sterile night
#

No, in that case, they'd each get to use it once.

#

(Assuming you weren't using idempotency keys at least)

worn shuttle
#

our understanding was that this coupon could only be used once at the customer level

sterile night
#

If the Coupon was on the Customer, the first Subscription of those 10 to grab it would be the only one that's getting it.

#

Yes, if that's the behaviour you want, then you want it on the Customer, not the Coupon.

#

Also you might want to consider doing 100% off (assuming you just want the first period free) vs. a fixed amount, just in case you have other plans at different prices and the Customer signs up for that.

#

...Unless you limited the products on which the discount can be used:

worn shuttle
#

we had an issue with percentage coupons a while ago and resorted to use amount based coupons, but we are planning to work with percentage coupons again

#

we have some complex subscription requirements

sterile night
#

Sounds like fun. ๐Ÿ™‚ We're here if you run into further blockers.

worn shuttle
#

Thank you timebox! I really appreciate your help and your time ๐Ÿ™‚

sterile night
#

Of course, you're very welcome! If you want to chat about your subscriptions requirements and get my (or anyone's) high level recommendations, we'd be more than happy to have that conversation. ๐Ÿ™‚

worn shuttle
#

Thanks! I had a chat with synthrider last time

#

it was about invoice line items, I believe he forwarded it to the product team, but havent heard anything since then

#

Right now our solution is using the invoice description, but it is limited to 500 characters, so we lose the data after that since we trim it and end with a ...

sterile night
#

I can't access that thread for some reason. You must've used a different Discord login too, ya? If you reuse the same one, previous threads will show up in a list at the bottom of a new thread's "welcome" header.

worn shuttle
#

same discord login

#

cristian_subscription-invoice-items-breakdown

sterile night
#

Weird. I can find that, but I can't see it where I would expect to see it. ยฏ_(ใƒ„)_/ยฏ

worn shuttle
#

Its all good

#

Thank you again timebox! ๐Ÿ™‚ have a lovely rest of your day

sterile night
#

You too!

A closing thought from me: as a former accountant, I'm going to suggest that you provide the details separately - ideally in a CSV so your customers can more easily automate the accounting side of things - rather than trying to fit it in a PDF.

worn shuttle
#

Oh yeah, we have done that

#

we have a CSV with all details of all invoices, but it would be nice too to have the PDF include all details for that specific invoice

sterile night
#

Ok cool. Another option would be to generate your own PDFs exactly how you want them.

#

(Based on the Invoice object data, plus whatever other data/details you want to add)

worn shuttle
#

All we really needed was below each invoice product line, listing what each quantity of a product mean

#

Like the example I gave in the thread:

iPhone N __________ 20 x US$750
    Serial: AAAAAAAAAA
    Serial: BBBBBBBBBB
    Serial: CCCCCCCCCC
sterile night
#

Right, but that could be in the 100s, ya?

worn shuttle
#

yea

sterile night
#

I mean, you could do what synthrider suggested and have one Price per serial #, and then use the templates to group them - that's certainly not impossible. And they could be created on the fly for a given serial #.

worn shuttle
#

That didnt work, there is a limit for 20 entries

sterile night
#

Then you can't do that, so don't do that. ๐Ÿคช

worn shuttle
#

๐Ÿ˜›

#

Hopefuly one day you guys support something like that