#JeremyFlight

1 messages ยท Page 1 of 1 (latest)

steel barnBOT
cold locust
#

Hi there!

#

What do you mean by "but doesn't let me finalize it"?

hasty spindle
#

When I try to finalise the invoice, I get this error " Uncaught (Status 404) (Request req_IHWInpRPn3Rob4) No such invoice:"

cold locust
#

That invoice ID exist, but the secret key you are using belongs to a different account.

hasty spindle
#

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() ?

cold locust
#

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?

hasty spindle
#

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!

cold locust
#

I think it should be like this:
$stripe->invoices->finalizeInvoice($invoice->id, array(), array('stripe_account' => $contractor->api_account_id));

hasty spindle
#

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...

cold locust
hasty spindle
#

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 ๐Ÿ™‚

cold locust
#

I think you can directly do something like this: $invoice = $stripe->invoices->finalizeInvoice(...), and $invoice should contain hosted_invoice_url directly.

steel barnBOT
hasty spindle