#l.o.c.

1 messages ยท Page 1 of 1 (latest)

tame iceBOT
lone otter
solid dune
#

Yeah, but how do you retrieve the payment intent id so that you can update/set the metadata to the payment intent? Atm when the checkout session is created, it returns payment_intent: null

#

and when the payment_intent is created, nothing in the event data can help associate it with the checkout session

lone otter
solid dune
#

Ah....so I guess I would need to listen to another webhook event payment_intent.created T_T

lone otter
#

Can you tell me what you want to achieve here?

solid dune
#

And then retrieve the checkout session, using the payment_intent's id, and copy the metadata that was initially attached to checkout session over

#

Is it okie if I DM you instead?

lone otter
#

Hmm, why do you need to copy the metadata if you can set it directly on the payment_intent through the param that I shared earlier.

#

Let's keep the discussion in the thread so other Stripe engineers can also help you when needed.

solid dune
#

Currently, I am using stripe hosted checkout to let my users pay.
And when they click on the button to check out, it also include in the metadata some info like a UID of their account (on another platform, let's say like Discord/Facebook/Twitter). In this case, let's say it's something like this: metadata: {id: 1234}
My server would then create the checkout session and respond back to the front-end with the URL of the checkout.

Now with the new API version (since August 2022), the payment intent won't be created unless there's a request to complete the checkout session.
I want to use Stripe Radar to count how many "bad" payment attempts made by the users, and thus block them from "obtaining" my product. So I am listening to the charge.failed webhook event, and when I look at the metadata, it's an empty object {} instead of what was set on the checkout session.

lone otter
#

So you want to set a metadata data on the charge object?

solid dune
#

on the payment_intent object

lone otter
#

Hmm, have you tried what I told you earlier, that param would set a metadata on the resulting payment_intent object when a checkout session completes

solid dune
#

Yes I have, and it works great when users' payments go through (aka not blocked by stripe radar).
But when a user's payment doesn't go through because Stripe Radar block them, I want to be able to capture their UID from the metadata, and by listening to webhook event charge.failed.
So from what you sent me above, it looks like I'd have to use the payment_intent from the event data from charge.failed, to retrieve the checkout session to get that UID from metadata.

lone otter
#

Can you share with me the ID of one of the charge.failed event?

solid dune
#

this is from my test mode ch_3O3OkgHFXzBK8JDh0azHDOfM

lone otter
#

https://dashboard.stripe.com/test/logs/req_6Ph2wa2l9mTENv I also checked the checkout session creation request, you set the metadata on the checkout session object. You should set it on the payment_intent through https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata

solid dune
#

it is only created after, and therefore i cannot set the metadata on payment_intent yet unless that event happen

lone otter
#

I don't think you understand me. The best way to better understand it is trying it out by yourself.

I'd suggest you use the param that I share to set metadata, and get the payment_intent from the charge object and check its metadata.

solid dune
#

Ohhh I see now payment_intent_data.metadata

#

that's the one right?

lone otter
#

Yes you are right

solid dune
#

Thank you so much, I didn't realize the difference hehe. I will test it out and come back! Really appreciate it

lone otter
#

Happy to help.

solid dune
#

@lone otter you rock!!!!!!!!!

#

It works ๐Ÿ˜„ ๐Ÿ˜„ ๐Ÿ˜„

#

Really appreciate your help!!!