#evan_webhooks
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/1311362251508416522
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there ๐ taking a closer look. Just making sure I'm understanding correctly, the Events you shared are ones you want to be notified of, where times_redeemed is being updated, but you aren't receiving those?
No, those were a couple of events where I modified metadata in the events and received updates
Hm, odd, I don't see metadata in the previous_attributes hash showing that value was updated.
that one was the coupon becoming invalid, my mistake!
In the second event you shared, times_redeemed is the only field in the previous_attributes hash.
oh sorry
For the Promotion Code from the second Event, I see 4 related Events.
- promo code was created: https://dashboard.stripe.com/test/events/evt_1QPnKgQ79oA3rs3ejRtu8ttB
- you updated the
metadata: https://dashboard.stripe.com/test/events/evt_1QPnSfQ79oA3rs3ecOWgPb57 times_redeemedgot updated: https://dashboard.stripe.com/test/events/evt_1QPnepQ79oA3rs3eqSpNfun3times_redeemedgot updated: https://dashboard.stripe.com/test/events/evt_1QPno2Q79oA3rs3edbZaiDs5
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I may be losing my mind, let me retest
Okay, I just completed a checkout session with this promo code: promo_1QPnRIQ79oA3rs3e6V9QyOB2
Checkout session is this event: evt_1QPnwFQ79oA3rs3eAyNipdnc
I don't see any update events on the promo code for times redeemed
Hm, I'm still seeing times_redeemed on the Promo Code is 0, are you seeing the same?
I'm not sure offhand if that is because it takes a bit for us to aggregate the usage and generate events, or if it's because the promo code was provided in the session creation request rather than being input on the checkout UI.
in this connect account: https://dashboard.stripe.com/acct_1Oa0f8Q79oA3rs3e/test/promotion_codes/promo_1QPnRIQ79oA3rs3e6V9QyOB2
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Hm, okay, let me refresh my side again
If you retrieve the Promo Code form the API, what is times_redeemed set to? Trying to sus out whether this could be a difference in dashboard behavior vs API behavior.
Sorry stepped away for a moment, let me check that now
1 in the API as well!
I'm passing the promotion code to the checkout session, do you think it could be different if I pass the coupon to the checkout session instead?
time redeemed event just came through! evt_1QPoFcQ79oA3rs3eXNbv1djQ
did you give something a poke or is it potentially delayed 20 mins??
FYI, I just tested a checkout session passing in a coupon instead of a promo code and the coupon.updated event fired immediately
some more context ๐ the coupon had only 1 max redemption and when I redeemed it the webhook fired immediately. I just tested using a coupon code where the max redemptions was 2, and the first redemption hasn't fired an updated webhook yet (~ 1 min ago)
so, I think the same thing is happening
Can you share the Event that was generated immediately? I'm finding that it's expected for there to be a delay in Events where just times_redeemed is upated, as those are handled asynchronously.
I suspect in the Event that fired immediately, valid also changed since the Coupon hit its max redemption limit.
you're correct it updated the valid field, here's the event: evt_1QPoTcQ79oA3rs3euOvANfC4
Yup, I see the same. So in short, if times_redeemed is the only field being updated, coupon.updated and promotion_code.updated Events may not be generated immediately.
frustrating, but thanks for clarifying
Can you clarify another behavior? When the final promo code is redeemed (which is also the final coupon code) only the coupon sends an updated event
Here's the promo code: promo_1QPohwQ79oA3rs3enDt9R8UD
It only has the created event (so far)
but the API is showing it as active: false
only the coupon got an updated event: evt_1QPoiyQ79oA3rs3eaRYdfWYx
I'm not sure what exaclty is expected to happen there
no problem
one more question
Is there a way to figure out the coupon used in the checkout session completion? I can just pull the latest coupon information in those webhook events, but I don't see the data in the webhook event data
Here's an example where I used a couponId in the discounts: evt_1QPoiuQ79oA3rs3eso0pg3mg
That's exactly what I was looking into as well, but wasn't readily spotting the information.
Since line_items aren't included by default, you'll at least have to make a request to retrieve the Checkout Session's line items:
https://docs.stripe.com/api/checkout/sessions/line_items
or retrieve the session and use expand to expand line_items
https://docs.stripe.com/api/checkout/sessions/object
https://docs.stripe.com/api/expanding_objects
I'm working on running a test to see if discounts is included by default, or if you have to use expand to get those details as well.
Looks like you have to use expand for discounts too. Can you try retrieving that session, and use expand to expand line_items.data.discounts?
got it!
Yess!!
Okay, so I think I'm covered then:
- Monitor coupon updates for "valid" to reflect in my database
- On checkout sessions expand discounts to get the coupon ID, and retrieve the latest to check validity & times_redeemed
I suppose I could just always use the checkout session and skip the webhooks? Feels better to still handle the coupon webhooks though
Yup, if I were in your shoes, I'd ingest all of the Events. If the state of the coupon or promo code on your side already match, or are more recent, than those contained in the promotion_code.updated or coupon.updated Events then I'd just treat them as a no-op.
If by no-op you mean blindly update the database with the latest data every time then we're on the same page
lol
Thanks for all the help!
This has been the first corner of the stripe API that didn't just work as I expected
Haha, I meant no-op = no operation, as in if the data you have in your db seems newer than what's in the Event, you just throw away the Event contents.
do these convos flow into API feedback and is my use case clear?
They don't automatically, and my understanding is that this flow was actually updated from synchronous to asynchronous to close another gap, so I'm not sure we'd see it change back.
yeah I'd guess large volumes of coupon redemptions would create quite a bit of load
but, I also don't seem to be getting promo_code.updated when it's no longer active
and it's not clearly documented
FWIW I do see an event generated for this. It just happened late