pyxero icon indicating copy to clipboard operation
pyxero copied to clipboard

Fetch online invoice url

Open mbarszcz opened this issue 8 years ago • 7 comments

Hello there,

Xero has added an online invoice URL to their API:

http://developer.xero.com/documentation/api/invoices/#onlineinvoice

Is there a way to fetch that URL using pyxero?

mbarszcz avatar Apr 19 '16 12:04 mbarszcz

Very interesting! I needed this personally and had to write a streaming server to download it. I'll see if I can get this in soon.

aidanlister avatar Apr 19 '16 12:04 aidanlister

As a matter of fact, it is possible to get the online invoice url using the standard invoices.get and appending "/OnlineInvoice" to the invoice guid, e.g. xero.invoices.get('bd709179-ba9b-492b-bd5c-305a31f2e5ca' + '/OnlineInvoice') .

kapetanos avatar Jun 21 '16 11:06 kapetanos

So is the following the best option to get the url for a recently created invoice? First query for the invoiceID given the invoice number and then use the ID to get the url.

invoiceID = xero.invoices.get('INV-0028')[0]['InvoiceID']
link = xero.invoices.get(invoiceID + '/OnlineInvoice')['OnlineInvoices'][0]['OnlineInvoiceUrl']
print(link)

Is there a better way to figure out the invoiceID (without the first call) so I can do this in one step?

carter-page avatar Dec 31 '16 03:12 carter-page

As stated in the API documentation only the InvoiceID can be used to retrieve the online invoice url. You could keep the InvoiceNumber and its InvoiceID locally when creating the invoice.

kapetanos avatar Jan 02 '17 14:01 kapetanos

@kapetanos, could you give an example of how to store those locally when creating the invoice?

carter-page avatar Jan 03 '17 02:01 carter-page

@carter-page when using put to create an invoice, the created invoice is returned. For example you can create an invoice and get the InvoiceID (invoice_dict is a dictionary with the required fields to create the invoice): invoice_id = xero_inst.invoices.put(invoice_dict)[0]['InvoiceID']

Depending on your application you can save the ids in a database, file, cache etc.

kapetanos avatar Jan 03 '17 08:01 kapetanos

Is there such a feature for viewing contacts? I'd like to open up a window from an external app with the customer displayed in it.

window.open('https://go.xero.com/Contacts/View/<ContactID>')

Responds with 500.

sandorvasas avatar Feb 16 '18 16:02 sandorvasas