#xfechx_webhooks

1 messages ยท Page 1 of 1 (latest)

last laurelBOT
#

๐Ÿ‘‹ 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.

plush oriole
#

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

robust basin
#

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){

plush oriole
#

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

robust basin
#

The invoice part is fine

#

the problem is the charge

plush oriole
#

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

robust basin
#

so with if($charge->invoice == NULL)

plush oriole
#

then the Charge doesn't have an Invoice

last laurelBOT
robust basin
#

but it does

#

that is the problem

plush oriole
#

ah cause this is that feature where Checkout generates the Invoice after, IIRC?

robust basin
#

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

steel nebula
#

๐Ÿ‘‹ Stepping in for my teammate. Give me a few minutes to catch up

robust basin
#

sure, thanks

steel nebula
#

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.

steel nebula
robust basin
#

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?

steel nebula
#

No, no drawbacks

robust basin
#

this one?
invoice_creation.invoice_data.metadata

steel nebula
#

Yep!

robust basin
#

I am also using the checkout to create subscriptions

steel nebula
robust basin
#

does charge.succeded happen always?

steel nebula
#

If a charge has succeeded, yes

robust basin
#

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?

steel nebula
#

Yep, that's correct