#xfechx
1 messages ยท Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- xfechx-sub-schedule, 8 hours ago, 21 messages
- xfechx, 14 hours ago, 30 messages
- xfechx, 1 day ago, 11 messages
๐ happy to help
hi @rancid whale thanks
Checkout Sessions don't automatically invoices unless you tell it to
using the invoice_creation param https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-invoice_creation-enabled
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I have this problem because my webhook which I have been using for years, uses two main events: charge.succeded, and invoice.payment_succeded, for generating notification emails of payments
I think it is good that it creates an invoice, because then on the receipt email, I can just point them to view invoice/receipt from stripe hosted receipt and invoice urls
are Payment Links generating invoices also?
or can do?
So my problem at the moment, is that my webhook is sending two duplicate email receipts
Payment Links basically generate automatically Checkout Sessions
one for charge.succeded and another one for invoice.payment_succeded
so it's the same
so I am thinking about removing notification on charge.succeded and just leave it in invoice.payment_succeded
ok to handle that first, instead of listening to the charge.succeeded it's best to listen to payment_intent.succeeded
why is that?
and if the payment_intent.invoice is not null you ignore the event
thing is my webhook is extremelly big
does a lot of things
so, I would like to keep it without listening to new events
just change the event
also, many websites already have defined which events they listen to , and the only way to change it, would be to go into their dashboards, etc. etc.
instead of listening to the charge.succeeded you listen to payment_intent.succeeded
too much manual work, i don't have time at the moment
so, with those two options: charge.succeded and invoice.payment_sucdceded
then you would have to retrieve the PI and look at the invoice
from the charge.succeeded event
on the charge
yes
will it ALWAYS have it?
also, charges coming from checkout sessions, have metadata setup, which helps the webhook decide a few things.
Also, invoices coming from subscriptions and one-off charges have metadata setup.
Not sure if payment intent inherits any metadata? Or if the invoice coming from checkout session inherits metadata?
have what?
PI -> invoice
if it doesn't have PI-> Invoice then it definitely means that no invoice was created for this charge
Charges inherit the metadata from PaymentIntents
hmm, but for example. on my one-off invoices, the charge related to that invoice doesn't have metadata
so that is how my webhook discerns (maybe not the best way, but has worked so far)
the metadata topic is a wider issue, and you shouldn't rely on that
my advice is still to change from charge.succeeded to payment_intent.succeeded but if that means a big breaking change than the only thing to help here is as I explained retrieving the PaymentIntent and checking the invoice property whether it's null or not
in case it's not null you should just ignore the event
because it will be handled by the invoice.payment_succeded event
if you're using the latest APIs and not some legacy integration then yes
nop! Invoices use PIs
but there's a deprecated integration path where you would use Charges with Tokens instead of PaymentIntents and PaymentMethods
which in that case the charge.succeeded event won't have the PI in it
how can I test that, could you help me?
I can do a checkout session right now
and send test payment
I think it is updated, but with so many changes, and so many years, i don't really know
this one for example:
pi_3Ojga12lgzywWyEx0Wi6jSHa
test what exactly?
if you check charge.succeded of that one. charge->invoice == null
I should not rely on that , right?
and then check if pi->invoice != null ? or will it always have an invoice related to a pi ?
yes..
then there was no Invoice generated
so, it is confusing
is it in the case of Checkout Session with invoice_creation.enabled: true?
yes
hmmm that's interesting
i know
I really dislike listening to the charge.succeeded events for so many reason now you just added one to my list ๐
also, payment intent's invoice is null
i know! me too, i hate having to fix things on my listener
yes I agree
it is so convoluted
but i have to
because i come from the times where invoice was related ONLY to subscriptions
now invoices are everywhere
but does it send an invoice.payment_succeeded in this case?
yes
if you check that payment intent i sent you, you will see
I'm thinking of a way to solve this
ok I know what's happening
because i really can't find the element for my code to discern between all the different type of charges
my colleague @flint marten always advices not to rely on the data object that you receive in the event but rather retrieve the object from the API
and one of the reasons is because some events are sent while the whole process hasn't been done yet
ok, so they are async
so basically the invoice gets created afterwards
and then I guess what ends up happening is that charge.invoice would be null but then it will change
I'm testing it out
give me a second
do you happen to have an event ID?
that would be much easier than having to recreate everything
for a charge.succeeded event
no worries I found an example
so you can look at this event for example https://dashboard.stripe.com/test/events/evt_3Ojga12lgzywWyEx0AIDDmfJ
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
where charge.succeeded event didn't have the charge.invoice
but then a charge.updated event https://dashboard.stripe.com/test/events/evt_3Ojga12lgzywWyEx0qyfnL0n happened
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
which updated the invoice
which is why when Checkout Sessions is at play we don't recommend using neither payment_intent.* or charge.* events but rather checkout.session.* events
before checkout.session.completed you can't be really sure that all of the objects where created correctly and are at their final state
it's better explained here https://docs.stripe.com/payments/checkout/fulfill-orders#fulfill