#JeremyFlight
1 messages ยท Page 1 of 1 (latest)
When I try to finalise the invoice, I get this error " Uncaught (Status 404) (Request req_IHWInpRPn3Rob4) No such invoice:"
That invoice ID exist, but the secret key you are using belongs to a different account.
I create the invoice on behalf of the connected account (as per my code - I pass the connected account's ID as the 2nd param to invoices->create() and invoiceItems->create()... but how do I finalize that invoice as I don't seem able to pass the connected account's ID as the 2nd param to invoices->finalizeInvoice() ?
as I don't seem able to pass the connected account's ID as the 2nd param
Well that's exactly what you need to do. Why you are not able to do so?
When I run this line of code:
$stripe->invoices->finalizeInvoice($invoice->id, array('stripe_account' => $contractor->api_account_id));
...I get this warning back "Warning: Options found in $params: stripe_account. Options should be passed in their own array after $params. (HINT: pass an empty array to $params if you do not have any.)" and I then get the error as above "Uncaught (Status 404) (Request req_qdJPQlam84p1Np) No such invoice: 'in_1NAVg4BLGHKIUHyOhYXm9ZQW'"
I add the array as the 2nd param to invoices->create() and invoiceItems->create() but doing the same for invoices->finalizeInvoice() doesn't seem to work!
I think it should be like this:
$stripe->invoices->finalizeInvoice($invoice->id, array(), array('stripe_account' => $contractor->api_account_id));
Ah, OK! Just done that for invoice "in_1NAVjhBLGHKIUHyObUnYAff9" and that looks successful. How do I now retrieve the URL for that invoice so that I can send it to the customer for them to pay? When I access $invoice->hosted_invoice_url, it returns null...
If the invoice is finalized, you should be able to get hosted_invoice_url as mentioned here: https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url
Thank you. I needed to call $invoice = $stripe->invoices->retrieve after finalizing to refresh my reference to the invoice and I now get a non-null response from $invoice->hosted_invoice_url ๐
I think you can directly do something like this: $invoice = $stripe->invoices->finalizeInvoice(...), and $invoice should contain hosted_invoice_url directly.
Ah, yes. That'd save a step! ๐