ej2 / python-quickbooks

A Python library for accessing the Quickbooks API.
MIT License
394 stars 193 forks source link

InvoiceLink is always empty #360

Closed 007SKRN closed 1 month ago

007SKRN commented 1 month ago

The InvoiceLink is always empty for me, I'm using minorversion=69, also tried 36 and 37, always empty

I generate it like this:

    invoice = Invoice()
    invoice.CustomerRef = customer.to_ref()
    invoice.Line.append(line)
    invoice.PrivateNote = 'This is a test invoice'
    invoice.DueDate = '2024-12-31'
    invoice.AllowOnlineCreditCardPayment = True
    invoice.AllowOnlineACHPayment = True
    invoice.save(qb=client, params={'include': 'invoiceLink'})

I don't know if it's a problem from my end or from the library itself, so will be pleased to see what you think about this.

Edit: after reviewing client.py, also tried to do this:

client = QuickBooks(
    auth_client=auth_client,
    refresh_token=REFRESH_TOKEN,
    company_id=COMPANY_ID,
    minorversion=36,
)
client.invoice_link = True

but no luck, still having the same problem, it's always empty.

ej2 commented 1 month ago

Here's what the QBO docs say about Sharable links:

Sharable link for the invoice sent to external customers. The link is generated only for invoices with online payment enabled and having a valid customer email address. Include query param include=invoiceLink to get the link back on query response.

So you have to add the param to the get request, not to the post when saving the invoice.

I wrote a test to try it out and discovered that get didn't have params... so I updated it and the readme. The new test is here.

Update your invoice query like so: invoice = Invoice.get(id, qb=self.qb_client, params={'include': 'invoiceLink'})

Also, you can remove the params on the save. All the changes are in release 0.9.10.