#mikael2811_code
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/1271094182118821898
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
Hi
What Event are you listening for in your Webhook handler?
the payment completed one
or payment successful, i can't remember the name exactly
If you set it top-level like you are doing currently then the metadata is attached to the Checkout Session object. If you want the metadata associated to the PaymentIntent then you set it via payment_intent_data.metadata: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata
So yeah try that and that is likely what you are looking for
ok. So if i send that data on the checkout session, and the user payes
that data will be send to my webhook, right ? with the other stuff from the json
Ok, lemme testing it out
$session = $stripe->checkout->sessions->create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'usd',
'product_data' => [
'name' => 'T-shirt',
],
'unit_amount' => 2000,
],
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'https://yourdomain.com/success',
'cancel_url' => 'https://yourdomain.com/cancel',
'payment_intent_data' => [
'metadata' => [
'order_id' => '6735',
'customer_name' => 'John Doe',
],
],
]);
something like this, right ?
Yep
Okay yeah you can't set metadata on the Invoice
You want to listen for payment_intent.succeeded
ok, lemme try with this one then
so, right now this are the listeners
should i remove the invoice ones ?
Yeah if you aren't going to handle that Event type in your handler code then you should remove it
Ok, so, now on the payment intent
i can see the metadata
i think i can find the invoice reference number on the payment_intent.succeeded, i think
because i need to create an invoice in our system based on that payment
so...
When you receive the payment_intent.succeeded Event then you can retrieve the PaymentIntent and expand invoice
That will give you all the data for both the PaymentIntent and the Invoice
ok. I think i got it
just need to check out if the retrieve method will give me everything i need
Last question. Are these persistent ?
or they will be deleted from your server in the future ?
Those links?
yep
They are persistent