#intelagent_webhooks

1 messages ¡ Page 1 of 1 (latest)

frank urchinBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1254964817274474517

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

tacit basinBOT
#

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.

serene basin
#

I chatted a bit in that thread linked, but the issue mentioned above is not solved by just looking at the timestamps

sacred hornet
serene basin
#

This isn't about a specific request, really. But I can grab a request for you sure

#

Here is the event for example: evt_3PV3UERbUz80Wmly0aV3gDDR

#

Also, it looks like you guys have figured this out: but I don't see a great way currently. But notice how each event links to a specific amount refunded

#

I guess technically that description ("The refund... has been compled...) could actually be coming from the previous attributes, which in this case won't help me uniquely identify the refund

sacred hornet
#

What are you exactly trying to do?

serene basin
#

I am trying to update a refund in my application when I get a charge.refunded event

#

When a user initiates a refund I

  1. create a refund object in my application
  2. initiate the refund with stripe
  3. update the application refund with the stripe id

I want to add resiliency for a scenario when the 3rd call fails and update the refund with the re_id from the event received via webhook

sacred hornet
#

I see, yes each refund object is tired to the uniqur charges you're refunding. On the event, you can attain the charge id/ payment intent id: evt_3PV3UERbUz80Wmly0aV3gDDR and tie that re_ id on your end

serene basin
#

Hmm I'm not sure I understand. I do maintain a mapping of refunds to payment intent on my end. But when I get the charge.refunded how can I understand which of the refunds to update, since there may be any number of refunds?

sacred hornet
#

Are you referring to a charge needing multiple refunds?

serene basin
#

Yes, a charge with multiple refunds might be sent as the payload in the charge.refunded

#

If every charge had max of 1 refund it'd be easy, I'd receive the charge, grab the refund and update in my database.

sacred hornet
#

so this way, you can map these multiple refunds and make the necessary update your on end

serene basin
#

Right, I do I add my refundId in the metadata. But this still doesn't solve the problem of knowing which refund to update when I get a list of refunds on the charge

sacred hornet
#

When you create the refund initially, you can pass any data you want.

#

Then, on the event, you would see the metadata

#

Then, you would know which refund id to update

serene basin
#

No that's not true though really, I would first need to fetch the charge with the refund list expanded. After I do that I might get back 50 refunds

#

Right?

#

Or are you suggesting I update all the refunds that come back after I fetch them

sacred hornet
#

Are you making the refund requests on your end for one charge?

serene basin
#

Yes, one charge, but we might refund several times

#

20%, 30%, then 50% or however it might work out

#

And then when I grab the refunds on the charge I might have N refunds come back and not understand which one generated the event, and thus which refund would need updating

sacred hornet
#

So you only want to update one of the refunds? Why?

serene basin
#

Well that might be a good question. I want to update the ones that changed. If I got 50 back I wouldn't want to update them all

sacred hornet
#

Changed in which way?

serene basin
#

Maybe changed isn't the right word. But I want to ensure I have their stripe re_id linked to my application objects

#

In theory for the charge.updated event there is no change. Should be what I created + a re_id. I guess I could just grab all refunds without a re_id and see if they are in the list of refunds from the charge and update them if not..?

sacred hornet
#

I do not think I fully understand what you want to do maybe. If you want to be update the refund ids on your application, you can pass the metadata when you create the refund. When you get the charge.refunded event, the matadata will be surfaced. So you only pass the metadata on the refunds you want to update on your application.

serene basin
#

I guess what I was trying to avoid was updating all N refunds that might be on a charge. I would have liked to just grab the 1 refund that caused the charge.refunded event and be done with it

sacred hornet
#

That is what I do not understand. On the charge.refunded event, you would see all the objects. If a refund was not issued charge.refunded event would not be sent.

serene basin
#

But back to this:

  1. create a refund object in my application
  2. initiate the refund with stripe
  3. update the application refund with the stripe id

It's possible the application cannot update the refund to include the re_id as soon as it's made (step 3 fails). to cover that case we can populate the re_id on the application refund when we get a webhook event.

#

Appreciate you taking the time to help by the way

sacred hornet
#

So on 3, if the application cannot update the refund with the Stripe id, you would already have the refund id at this moment right?

serene basin
#

Yes correct

sacred hornet
#

So is not that enough? When it fails you still have the refund id

#

can you store that and try again?

serene basin
#

Yeah so the refundId will be on the stripe refund as well

#

I don't know how to word it differently I think I have a solution it just doesn't seem right but it is what it is at this point. I appreciate the time a lot, thank you!