#jrq_webhooks

1 messages · Page 1 of 1 (latest)

ancient phoenixBOT
#

👋 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/1240137806500593724

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

haughty basin
#

charge.refunded

bitter hearth
#

hello! I'm afraid I don't quite understand the question? What do you want to do with the charge.refunded event? Without knowing that, I think it's going to be difficult to know what next steps you should be taking

haughty basin
#

After calling the partial refund API , what events should I listen to for refund completion and what parameters should I associate with my business

#

After calling the partial refund API, what events should I listen to for refund completion and what parameters should I associate with my business

bitter hearth
#

are you only accepting cards or are you accepting other kinds of payment methods as well?

haughty basin
#

only accepting cards

#

For example, if there are three items in my order and the user returns one of them, how can I associate the event with which item was returned

bitter hearth
#

You can add metadata when creating a refund. However, what you should really be doing is to save the refund id and status to your own DB and perform your own internal mapping to identify what items were returned.

You'll want to note that from 2022-11-15, for charge.refunded event, Charge no longer auto-expands refunds by default : https://docs.stripe.com/upgrades#2022-11-15, so upon receipt of this event, you'll actually need to make a subsequent request to retrieve the list of refunds associated with the Charge or PaymentIntent : https://docs.stripe.com/api/refunds/list and process them accordingly

Keep track of changes and upgrades to the Stripe API.

haughty basin
#

I have already passed metaData when calling the refund API

bitter hearth
#

ok, do you have a question?

haughty basin
#

The problem is that when I listen to the charge. refunded event, the Charge object I obtained does not have an associated field similar to refundId, so I don't know which partial refund should be processed

bitter hearth
#

from API version 2022-11-15, for charge.refunded event, Charge no longer auto-expands refunds by default (https://docs.stripe.com/upgrades#2022-11-15), so upon receipt of this event, you'll actually need to make a subsequent request to retrieve the list of refunds associated with the Charge or PaymentIntent : https://docs.stripe.com/api/refunds/list and process them accordingly

Keep track of changes and upgrades to the Stripe API.

haughty basin
#

When I listen to the charge. refunded event, I call https://docs.stripe.com/api/refunds/list How can I associate multiple partial refund data in my database when obtaining multiple partial refund data?

bitter hearth
#

I don't understand the question - what data are you trying to associate with each other? Can you illustrate this with an example?

haughty basin
#

For example, if a user buys A and B in an order and initiates a refund for A and a refund for B, there will be two partial refund data in my database

bitter hearth
#

okay, so what specific data are you having trouble with associating?

haughty basin
#

So it will trigger two charge. refunded events. The first time it is triggered, should I handle the A refund or B refund in the database?

bitter hearth
#

what do you mean by handle? You should be logging both refunds to your database

haughty basin
#

So it will trigger two charge. refunded events. When it is triggered for the first time, what data association should I use to process A refunds or B refunds in the database?

bitter hearth
#

i'm sorry but i truly don't understand the question. When you say data association should you use to process the refunds - what is this data association you're referring to?

#

assuming you only have one refund, what would be this data association then?

haughty basin
#

There are multiple refunds in one payment

sand shaleBOT
fiery mantle
#

Hi, sorry I am not following the question here. Could you give a clear example, with PaymentIntent Id and Refund Id, and describe what do you want to do given those information?

haughty basin
#

hello

#

Multiple refunds for one order

#

First refund:

#

refundId: re_3PGZZ6C50No9ASOW1hMplkkQ
chargeId: ch_3PGZZ6C50No9ASOW1bDodLAq
paymentId: pi_3PGZZ6C50No9ASOW1jxi10xD

#

Listening for parameters received by charge. refunded events

#

second refund:

#

refundId: re_3PGZZ6C50No9ASOW1x958ONF
chargeId: ch_3PGZZ6C50No9ASOW1bDodLAq
paymentId: pi_3PGZZ6C50No9ASOW1jxi10xD

#

Listening for parameters received by charge. refunded events

#

There are also two pending refund data in my database

#

Which refund data in the database should I modify to complete status during the first event callback?

fiery mantle
#

By "first event call back" do you mean the charge.refunded webhook event for re_3PGZZ6C50No9ASOW1hMplkkQ?

#

And what do you mean by complete status?

haughty basin
#

How do I obtain the RefundId during the first event callback, such as re3PGZZ6C50No9ASOW1hMplkkQ

fiery mantle
haughty basin
#

When initiating a refund, the status of the data in the database is Refund in Progress. When the event charge.refended callback occurs, the status of the database data is changed to refunded

fiery mantle
#

Passing ch_3PGZZ6C50No9ASOW1bDodLAq to the API

#

You will need to distinguish whether the incoming Refund is full refund or partial refund

#

Then save to your database accordingly

#

You can't use a status "refund" to represent both case

haughty basin
#

0: Refund in progress 1: Refunded

#

By comparing the refund list API with the data in the database, and then modifying the data in the database to a refunded status?

fiery mantle
#

Sorry we are talking past each other. Would you mind consider my suggestion above?

#

When the first charge.refunded event came, you need to detect it's just a partial Refund, and save something to your database to indicate that this is a partial refund and succeeded

#

Not just "mark this transaction as refunded"