#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, 22 hours ago, 11 messages
Are these one-time invoices or subscription invoices?
Can you share an example?
Ideally, you'd set metadata when you make the request to create the invoice
https://docs.stripe.com/api/invoices/create
https://docs.stripe.com/api/invoices/create#create_invoice-metadata
evt_3OiexlABIsA579c61bbzjCg7
I don't see you sending any metadata when you create the invoice
https://dashboard.stripe.com/logs/req_qQfICDspPIFejh
No, I didn't
just want to know if I should send it on the product or on the invoice
Depends on your usecase ๐
for it to appear under charge.succeded
so, for it to apper under charge.succeded?
Also, we would like to edit the description that comes up in the payments list, so that we can include our reference there. Can we also modify that when charge.succeded event?
this is in the use case of one-off invoices
I'm not sure we automatically copy the metadata on the charge object.
if you set the metadata on the invoice then you can expand the invoice parameter when you receive charge.succeeded event
I am happy to do it alternatively, if there is a simpler way, for exmaple under product or price?
because for one off invoices I am creating the prouct and price on the fly
price/product info doesn't show up on the charge directly, it's nested under invoice
I'm thinking but there's no way to get the metadata over to charge.succeeded
Taking a step back, is there a reason you're not listening to invoice.paid events instead?
you should see my listener (webhook) file, it already does so much with all different events, so I am trying to keep it cleaner by listening to less events. I have already setup a system that listens for charge.succeded, it also listens for invoice.payment.succeded, but for when there are subscriptions as before in stripe invoices where only related to recurring payments
you could still use invoice.payment_succeeded for this no?
You can look at the invoice object that gets delivered and see if it has a value in subscription parameter
https://docs.stripe.com/api/invoices/object#invoice_object-subscription
if its null then the invoice was a one-time payment
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 added a note here on my listener:
if($collect_fees && $invoice->lines->data[0]->price->type != 'one_time'){ //for one-time invoices: only getting transfers from charge.succeded, not from invoice.payment_succeeded.
if($app_version === 'v1' || $app_version == null){
if($connected_account['stripe_account'] == null){
stripe_transfer_instantly();
}
else{
collect_fees_application();
if(!empty($metadata['Affiliate'])){
collect_fees_affiliate($metadata['Affiliate']);
}
}
}
else if ($app_version === 'v2'){
stripe_transfer_instantly();
}
}
๐
actually, can you help me expand
I see why I use the event with charge.succeded., because stripe_transfer_instantly() takes the charge details
as a source
uses the charge object, not the invoice object
but, I have this, under invoice.payment_succeded
$charge = \Stripe\Charge::retrieve($event->data->object->charge, $connected_account);
will that be sufficient to retrieve charge object from a one off invoice?
It should be afaik, I'd say give it a try in test mode to be 100% certain