#xxxxxxxxxxxx_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/1317087788390420522
๐ 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.
- xxxxxxxxxxxx_api, 2 days ago, 22 messages
- xxxxxxxxxxxx_api, 3 days ago, 18 messages
hey sorry didn't see your answer
I am trying to reverting a sub so I generate a 100% off coupon, it works most of the time but when testing for a new user a got this problem : coupon don't exist even if i just created it (as you can see with both request ids)
I think this is a race condition
the two requests are happening at the same time
I would just wait until the coupon is created before creating the subscription
would you mind sharing your code?
would you mind sharing the code for createStripeDiscountCoupon
hmmm, I'm trying to see whether the idempotency is playing a role here
when you said "race condition" it gave me information about maybe a double calling of the reverting update in my code
And that was the case
Thanks for your help ๐
sure let me know if you need any more help
(i am deleting the code for security purpose)
Oh crap, it was not the issue
I misunderstood a part of the code, sorry.
Do you think idempotency can be the key to resolve the issue?
yes I think what's happening is the following
you first created the coupon in this request https://dashboard.stripe.com/test/logs/req_VXZm0uPtkIjIKH
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
then you deleted it
and then you went again and created the same coupon with another request https://dashboard.stripe.com/test/logs/req_Fje3C0VBqQmue4 having the same idempotency key
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
when you do that, Stripe doesn't execute the request
instead it just returns the same response that you got the first time you requested this
Oh yeah, if the update fails, I delete the coupon to not have a 100% off coupon living out there
So... What would be the good way to handle this?
just generate a new idempotency key
everytime I create a coupon?
yes