#cristian_unexpected
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/1364334027213111327
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Coupon ID: zcDKxZWn
I have also tested increasing the quantity of the subscription, and the additions are being charged as expected
Hi, that is not how it works. If you're looking for offer the discount on the first month only, you can you would need to update the subscription, https://docs.stripe.com/api/subscriptions/update#update_subscription-discounts to removed the discount.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
but on renewal, the discounts are still applied
What does Only Once mean in the context of the coupon then?
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
Ah, you did say you specified it to use only once, https://docs.stripe.com/api/coupons/create#create_coupon-duration
Can you share the request id for creating the coupon please?
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
Do you have another example where you advance the time and it created an invoice with the coupon applied again?
yes, one second
sub_1RGnjUABXG7iwsUNf3eevsnU
This is the renewal invoice that had the discount applied: in_1RGnjwABXG7iwsUNapcY91jv
no request ids as this was all done in Stripe
Hi, jumping in for my colleague here. There will still be Request IDs in the logs. I'm looking at things now.
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?
wat
Next renewal the discount is not applied :S
First invoice: in_1RGnjUABXG7iwsUNMHOYvfxe
Second invoice: in_1RGnjwABXG7iwsUNapcY91jv
Third invoice: in_1RGntxABXG7iwsUNiFFwmehz
third invoice
It looks like you booped the test clock forward like 1 second after the first invoice went through; is that right?
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?
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
If you can try that that'd be awesome. My tummy tells me this might be a timing issue.
on it
Alright, subscription created:
sub_1RGo44ABXG7iwsUNsulQNx5X
Invoice:
in_1RGo44ABXG7iwsUN291LeFWF
Let me know when you want me to advance the clock
Go ahead. ๐
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
Very weird.
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
Ok I'm digging at the moment again. ๐
Thank you!
So in_1RGo7pABXG7iwsUNGFPE5TYi was created by advancing the clock past the 'renewal date', ya?
Just want to confirm.
Yes, I advanced the clock one year + one day
Just to make sure there was time to compute everything
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.
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)
This kind of proves that the issue is not with the test clock
as the estimated upcoming invoice already has the coupon applied
"proves" is a strong word but ... ya. Can you try this with a new, fresh coupon too?
Another interesting scenario I have tested:
- Create subscription
- Add quantity to the subscription
- Check invoices
3.a Initial invoice is $0
3.b update invoice is $500 - Advance the clock one year until the new cycle
5.a Renewal invoice is $500 (but should be $1000)
fair enough, suggests*
Sure thing, new coupon: EtVFggTW
What does 'update invoice' mean? Upcoming invoice, or did you change it?
I mean the invoice from the subscription update (changed quantity from 1 to 2)
New subscription with new coupon: sub_1RGocTABXG7iwsUNPGvEOZ3x
Same outcome
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.
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
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).
Interesting
Let me run a test, I will comment the part where we add the coupon to the subscription
You nailed it!
Great find ๐
It does, it kind of duplicated the coupon
"Doubled up" is slightly better than "duplicated" maybe, but yes.
The first invoice applied the coupon that was given to the subscription, the renewal used the coupon at the customer level
Actually I think the other way around, but exactly.
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
No, in that case, they'd each get to use it once.
(Assuming you weren't using idempotency keys at least)
our understanding was that this coupon could only be used once at the customer level
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:
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
Sounds like fun. ๐ We're here if you run into further blockers.
Thank you timebox! I really appreciate your help and your time ๐
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. ๐
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 ...
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.
Weird. I can find that, but I can't see it where I would expect to see it. ยฏ_(ใ)_/ยฏ
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.
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
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)
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
Right, but that could be in the 100s, ya?
yea
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 #.
That didnt work, there is a limit for 20 entries
Then you can't do that, so don't do that. ๐คช