#TheUchi007 - invoice metadata
1 messages · Page 1 of 1 (latest)
Hello, that call won't attach metadata to any objects as far as I am aware. You will need to set the metadata on the invoice or payment intent beforehand
Ah ok, noted. What I am planning on doing is to attach it to the customer and and then just retrieve the customer on the webhook, so I can get that data. Will that work?
That sounds like a viable plan to me. Is there any specific customer info you are looking here?
Well, it is mostly just extra info. I am implementing an affiliate system, so that a referrer can get a commission. For that, I need to reference to that referrer's ID(if it is present) and then run a transfer once the payment clears
I could also just get the data from my own DB, but seeing that I can attach specific data to a user, I think that would be more reliable
Ah gotcha, so yeah either of those options are totally viable. Metadata is a viable option here
One thing I will mention to keep in mind is that metadata typically does not copy between related objects. So if you set this data on the invoice it won't get copied over to the payment intent or subscription or anything, it will just stay on the payment intent. So make sure to set/update this data on each object you want it on
Yeah. What I am doing is that, once I verify that the webhook receives an event, I then get the stripe customer data, which has the metadata. Then I will just use that data globally across all events
I do have a quick question. What event is the one that determines the payment was successful?
payment_intent.succeeded or invoice.payment_succeeded
Either of those events will work, both will get triggered whenever an invoice is paid with a card
Though actually we typically recommend listening to invoice.paid
It triggers for all of the things that those trigger for but it also includes if you mark an invoice as being paid out of band (basically, without Stripe)
So either payment_intent.succeeded or invoice.paid will work