#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, 8 minutes ago, 112 messages
- xfechx-sub-schedule, 9 hours ago, 21 messages
- xfechx, 15 hours ago, 30 messages
- xfechx, 1 day ago, 11 messages
Hi, my colleague had to step away, could you summarise the question for me please?
hmm, can we open the chat window again?
all the info is there, it was quite the discussion
hard to summarize it
Sorry, I won't be able to re-read everything right now.
What's the latest question I can help you with?
it is just not a question, it is a design problem
about how invoices get created after invoice.payment.succeded, and charge.succeded in some cases
so how to find out if/when an invoice was created, for then to provide notification receipts to customers
sometimes charges do not have an invoice present, even though it was a checkout session with invoice_creation true
I would like to get rid of notifications from event charge.succeded, but instead change them to invoice.payment.succeded, as it seems invoices get created almost all the time (at least in my app)
from charges, checkout sessions, payment links, subscriptions
basically, from invoice.payment.succeded, I would like to create a notification system, that accounts for subscriptions, one_time invoices, checkout sessions and payment links.
I would suggest looking at invoice.paid then, since it covers more cases: https://stripe.com/docs/api/events/types#event_types-invoice.paid
I can't
It breaks many changes of my existing app to look at another event
I would have to manually go to dashboards of all accounts and instruct their individual webhooks to now listen to a new event
I want to keep using what I have and workaround it, because then I just have to change code, not manually enable more webhook events on dashboards.
hey @slow frigate, I'm here
as I explained you can try to retrieve the charge for example instead of using the data.object that you receive in the event, which can get you more up-to-date version of the object
that can eventually have the invoice property set after being updated
the only problem is that this is as you stated a design problem and at some point you need to take some time to rethink this through and change the current implemenation
ok, so something like:
- listen to event: invoice.payment.succeded
- discern if it is a subscription or one_off.
- retrieve charge, like invoice->charge,
- do whatever
no
in the invoice.payment_succeded you don't have to do anything you'd just treat that event as is today
in the charge.succeeded event instead of directly checking the charge.invoice on the event you would first call the retrieve a charge API https://docs.stripe.com/api/charges/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
which gets you the latest version of that object
ah ok, ok
will test for a moment
so instead of this:
try{
echo "--- EVENT: CHARGE.SUCCEDED ---";
$invoice = $event->data->object->invoice;
$charge = \Stripe\Charge::retrieve($event->data->object->id, $connected_account);```
try{
echo "--- EVENT: CHARGE.SUCCEDED ---";
//$invoice = $event->data->object->invoice;
$charge = \Stripe\Charge::retrieve($event->data->object->id, $connected_account);
$invoice = \Stripe\Invoice:retrieve($charge->invoice);```
๐ you'd need to test the code out to be 100% certain ๐
Also since you're already retrieving the charge, you can just expand invoice parameter
you don't need to make a separate request to retrieve the invoice
sure
wouldn't it be better to ditch notification in charge.succeded, and only use invoice.payment_succedded event? as it is a newer event, and inside invoice, look for the charge object using API, not json?
and I can see that our payment forms, subscriptions, payment links all use invoices, there are no charges that come up without invoice. the problem was that invoice object was getting created after event
and we were searching for invoice directly through the charge event, and it is one of the first triggered events, and many things happen after that in stripe.
I asked you the same question yesterday if you remember ๐
#1207062347299164171 message
you could still use invoice.payment_succeeded for this no?
sorry, still getting my head around updating all of this, maybe I wasn't aware of what I just said, but last night
ok, so I will try to only use that invoice event
and I will definitely start ditching charge.succeded, moving code slowly out of tha event
Sounds good ๐ ๐
also, another thing I am doing in charge.succeded is updating the charge description
๐
is metadata copied from charge to invoice?
Nope