#xfechx

1 messages ยท Page 1 of 1 (latest)

austere quarryBOT
#

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.

plain breach
#

Hi, my colleague had to step away, could you summarise the question for me please?

slow frigate
#

hmm, can we open the chat window again?

#

all the info is there, it was quite the discussion

#

hard to summarize it

plain breach
#

Sorry, I won't be able to re-read everything right now.
What's the latest question I can help you with?

slow frigate
#

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.

plain breach
slow frigate
#

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.

fleet ingot
#

hey @slow frigate, I'm here

slow frigate
#

hi @fleet ingot

#

thanks

fleet ingot
#

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

slow frigate
#

ok, so something like:

  1. listen to event: invoice.payment.succeded
  2. discern if it is a subscription or one_off.
  3. retrieve charge, like invoice->charge,
  4. do whatever
fleet ingot
#

no

#

in the invoice.payment_succeded you don't have to do anything you'd just treat that event as is today

#

which gets you the latest version of that object

slow frigate
#

ah ok, ok

austere quarryBOT
slow frigate
#

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);```
tacit musk
#

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

slow frigate
#

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.

tacit musk
#

I asked you the same question yesterday if you remember ๐Ÿ™‚
#1207062347299164171 message

you could still use invoice.payment_succeeded for this no?

slow frigate
#

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

tacit musk
#

Sounds good ๐Ÿ‘ ๐Ÿ™‚

slow frigate
#

also, another thing I am doing in charge.succeded is updating the charge description

tacit musk
#

๐Ÿ‘

slow frigate
#

is metadata copied from charge to invoice?

tacit musk
#

Nope