#xfechx_webhooks
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/1232059004864430230
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I recommend listing CheckoutSessions by PaymentIntents ID: https://docs.stripe.com/api/checkout/sessions/list#list_checkout_sessions-payment_intent
both the Charge and the Invoice Event should have a PaymentIntent ID, and finding the backing Checkout Session will let you know if one was resulting of that or not
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
can you elaborate a bit, so with a payment intent id, I can tell that it comes from a checkout session?>
I am checking for if($charge->invoice == NULL){
see the link I shared above
that takes you from PaymentIntent ID -> to its Checkout Session
and both Charge and Invoice have a PaymentIntent ID
so that way you can tell if an Invoice had a CheckoutSession or not
Take the Charge's PaymentIntent ID and make the same API call to see if it had a CheckoutSession or not
and both Charge and Invoice have a PaymentIntent ID
so with if($charge->invoice == NULL)
then the Charge doesn't have an Invoice
ah cause this is that feature where Checkout generates the Invoice after, IIRC?
with a checkout session, a charge creates an invoice
yes
I need to know when a charge will have an invoice too
how can I check this in charge succeded?
even the payment intent succceded has invoice: null
๐ Stepping in for my teammate. Give me a few minutes to catch up
sure, thanks
I see the checkout.session.completed event includes a non-null invoice. Is the issue here that you're also looking at events for Invoices that were not created through a Checkout Session?
I think the other thing you can try is using the metadata you're already adding to the PaymentIntent when creating the Checkout Session. I see you're adding an invoice key and value to the PaymentIntent. When you receive charge.succeeded, you can retrieve the PaymentIntent to look at the metadata. There's also a one-time copy of a PaymentIntent's metadata to the Charge when the PaymentIntent is confirmed, so you can also look at the Charge's metadata.
exactly
Another thing you can do is pass metadata to the invoice when creating the Checkout Session: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-invoice_creation-invoice_data
Something to help you differentiate between Checkout-created Invoices and other Invoices
yes, at this point probably easier
then it could also be more explicit for me in code and in dashboard. Are there drawbacks of using extra metadata?
No, no drawbacks
this one?
invoice_creation.invoice_data.metadata
Yep!
I am also using the checkout to create subscriptions
Got it. You can also pass metadata to the Subscription: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-subscription_data
The resulting Invoice will have a value for subscription_details.metadata that match: https://docs.stripe.com/api/invoices/object#invoice_object-subscription_details-metadata
does charge.succeded happen always?
If a charge has succeeded, yes
then I can just make the calls when charge has succeded, and not on invoice payment succeded, correct?
an invoice payment succeded always have a charge.succeded? a subscription charge too?
Yep, that's correct