#l.o.c.
1 messages ยท Page 1 of 1 (latest)
You don't need to copy, you can set one directly https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent you can call this API and pass in the payment_intent to return the associated Checkout session.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ah....so I guess I would need to listen to another webhook event payment_intent.created T_T
Can you tell me what you want to achieve here?
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?
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.
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.
So you want to set a metadata data on the charge object?
on the payment_intent object
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
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.
Can you share with me the ID of one of the charge.failed event?
this is from my test mode ch_3O3OkgHFXzBK8JDh0azHDOfM
OK, you can get the associated payment_intent from the charge object through https://stripe.com/docs/api/charges/object#charge_object-payment_intent
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But, like I said, the payment_intent is not created until users try to complete the checkout, regardless of valid/invalid card?
it is only created after, and therefore i cannot set the metadata on payment_intent yet unless that event happen
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.
Yes you are right
Thank you so much, I didn't realize the difference hehe. I will test it out and come back! Really appreciate it
Happy to help.