Reputation: 59
OK,
I've literally spent hours on this and - for the life of me - can't figure it out.
I want to do something really simple - I want to poll my QuickBooks Online instance for all customers with overdue invoices. At a certain point, I want to send them warning emails, and if they go 30 days past due, I want to suspend their instance in my SaaS application.
I want the engine that does this to wake up on Tuesday and Thursday, and my intent is to write a C# app and use Windows Task Scheduler to run it on said schedule.
Now - I've been all over the Platform API and Intuit App center and it's a ton of pages but somehow, incoherent. It appears that in order to integrate w/ QuickBooks online I need to use a "blue dot" or some kind of federated/OAuth authentication that requires a UI - however, this is not suitable for me since my App has no UI. Other posts tell folks to look at the QBSDK, but that appears to only be for QuickBooks desktop.
Don't know why this is so hard - it should be a simple use case. Can someone help? If I could just get sample code it'd be beautiful.
Andrew
Upvotes: 0
Views: 1732
Reputation: 27982
A couple of points of clarification to get you going:
You do not need the blue-dot menu. Ignore anything about that.
You do not need to use anything "federated" (that's deprecated).
You do need to use OAuth, and it does need to have a GUI, BUT the GUI only appears once after which you will get long-lived tokens which you store and use to connect for all future sessions. i.e. only the very first connection requires a GUI (this is typical of most OAuth apps) after which it can run unattended without a GUI. If you really don't want to build a GUI at all, you can use the OAuth playground tools Intuit provides to generate one (e.g. use their GUI instead of yours).
Here is the playground that will allow you to generate those long-lived tokens:
From there, use the OAuth library of your choice (Intuit provides some if you browse developer.intuit.com) to make REST requests to Intuit's endpoints.
You'll want to use the standard Invoice
API endpoint - docs are here:
Basically you're going to hit this endpoint (using OAuth for auth):
https://quickbooks.api.intuit.com/v3/company/(your company ID)/query?query=SELECT * FROM Invoice WHERE Balance > 0
And you're going to get back a blob of XML like this:
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-04-23T08:30:37.983-07:00">
<QueryResponse startPosition="1" maxResults="1" totalCount="1">
<Invoice domain="QBO" sparse="false">
<Id>44</Id>
<SyncToken>1</SyncToken>
<MetaData>
<CreateTime>2013-04-23T08:30:17-07:00</CreateTime>
<LastUpdatedTime>2013-04-23T08:30:18-07:00</LastUpdatedTime>
</MetaData>
<CustomField>
<Name>Custom 1</Name>
<Type>StringType</Type>
</CustomField>
<CustomField>
<Name>Custom 2</Name>
<Type>StringType</Type>
</CustomField>
<CustomField>
<Name>Custom 3</Name>
<Type>StringType</Type>
</CustomField>
<DocNumber>1014</DocNumber>
<TxnDate>2012-04-20</TxnDate>
<CurrencyRef name="United States Dollar">USD</CurrencyRef>
<Line>
<Id>1</Id>
<LineNum>1</LineNum>
<Amount>15.00</Amount>
<DetailType>SalesItemLineDetail</DetailType>
<SalesItemLineDetail>
<ItemRef name="Sales">1</ItemRef>
<TaxCodeRef>NON</TaxCodeRef>
</SalesItemLineDetail>
</Line>
<Line>
<Amount>15.00</Amount>
<DetailType>SubTotalLineDetail</DetailType>
<SubTotalLineDetail/>
</Line>
...
Upvotes: 1