How to prevent duplicate invoice in Quickbooks Online API? - php

I have been trying to integrate Quickbooks Online API with PHP in to my website and I have found an issue where I could keep on creating the same invoice.
Although there have been accepted answer in this forum however it is really being vague not exact.
"If you don't have the TxnID, there really isn't a way to detect a "duplicate" invoice in QuickBooks.Does this mean that upon creation of invoce there is no way to check if an invoice was already create via API?
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/invoice#create-an-invoice
When creating an invoice the values returned under "LinkedTxn" field is always empty
"The closest you can get is querying by RefNumber ...there's no guarantee that the invoice that you get back from that query is the invoice that you created."
Still same as first but I have been searching RefNumber under the documentation but I can't seem to find it.
If "RefNumber's" cannot be gauranteed then what are the other
alternatives?
Do I have to handle this on my local or at least add a column on my
local table for indicating if item is already sync?
PS: I also tried to insert txnid on the create invoice field however I wasn't successful.
While testing on sandbox I realized there is this number, what is this called? Can I use this for checking the existing invoice?

The NO. column you're showing in your screenshot is the DocNumber field. It's in the documentation here:
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/invoice#the-invoice-object
In most cases, the DocNumber is a unique field. But not in all cases (you'll see some exceptions noted in the docs related to France and also to custom document numbers).
The best way to avoid duplicates is to keep track of what you send to QuickBooks on your end. On your end, maintain a list of what you sent to QuickBooks. Don't send it again if you've already sent it.

Related

consolibyte | example_mysql_mirror | syncing related questions

I am using consolibyte "mysql_mirror script" for two way syncing. Till now syncing is working perfectly but there are questions related to syncing.
We want customer billing and shipping address without First Name and Last Name. Requirement is to get only customer's address that is valid and can be used in google maps API. Question is that
Is it possible through code modification or any other way to get customer's clear address.
Customer's Mobile and Website information is not synced from QBD to MySQL. Is it possible through code modification to sync this information and if yes, can you please give me direction what code modification is required to sync it.
Some tables are not synced from QBD to MySQL like "qb_unitofmeasureset". Is there any page that specifies the list of tables that wouldn't be synced?
As per my understanding if i set mode to MODE_READWRITE and use only QUICKBOOKS_OBJECT_** option for customer type, then two way sync will work correctly.
What is the purpose of other three
QUICKBOOKS_ADD_CUSTOMERTYPE',
QUICKBOOKS_QUERY_CUSTOMERTYPE'
QUICKBOOKS_IMPORT_CUSTOMERTYPE
I see these four actions for other entities as well.
Please make sure you read this first:
http://consolibyte.com/forum/viewtopic.php?id=20
And:
https://github.com/consolibyte/quickbooks-php/blob/master/docs/web_connector/example_mysql_mirror.php
We want customer billing and shipping address without First Name and Last Name.
The data synced is the data in QuickBooks. If QuickBooks has the first/last name in it, then the data that gets synced will have the first/last name in it.
Customer's Mobile and Website information is not synced from QBD to MySQL. Is it possible through code modification to sync this information
You should refer to the QuickBooks OSR for this. If it's accessible in the OSR, you should be able to add support for it.
I think you'd have to add the fields in here:
https://github.com/consolibyte/quickbooks-php/tree/master/QuickBooks/QBXML/Schema/Object
But I'm not 100% sure.
Some tables are not synced from QBD to MySQL like "qb_unitofmeasureset". Is there any page that specifies the list of tables that wouldn't be synced?
I don't have this information anywhere, no.
What is the purpose of other three QUICKBOOKS_ADD_CUSTOMERTYPE', QUICKBOOKS_QUERY_CUSTOMERTYPE' QUICKBOOKS_IMPORT_CUSTOMERTYPE
These are used in other parts of the framework. They are NOT used with the SQL mirror code.

Getting compact information from Square Connect API

I want to load Transactions with their Items and Customer from Square Connect API (using PHP client library), but Transactions don't contain any link to their Items unless there is order_id which often tends to be null.
As mentioned in Getting item names from Square Connect API I could go back to version 1 of the API and get list of Payments which includes Items, but there is no connection to Customer.
I know I could join Transactions to Payments by using Tenders which are included in both and get all information I need that way, but it doesn't seem to be good approach (combining two versions of API just seems wrong considering old versions of other APIs tend to deprecate and shut down after some time) and it would be very inefficient for both sides (more requests + downloading duplicate data just to try to match them).
So I would like to know if there's any better way to do this or why isn't.
Ditto on this (I can't comment yet - not enough rep). FreshKDS pull these details from the API (somehow) to display items on their Kitchen Screen. However as I'm already using a cloud service like Zapier (for Woo Orders to Trello Cards) and don't want to have the additional KDS cost as it doesn't pull square orders from WooCommerce (obviously).
So I need to be able to get the Square POS new order details to also create a Trello card - which I am using as a Kitchen Screen.
In regards to the OP's question: Does anyone have any info about webhooks perhaps, or a way to pull an entire order (even if I have to clone it to a database or cloud based spreadsheet) to allow viewing or iteration of individual food/ drink items?
Cheers.

Sending additional data to Google Analytics from other php app

I have some problem to solve. Client was using third-party SaaS e-commerce platform (http://shoper.pl), which has integrated GA for E-Commerce. Everything works fine, except passing information about discounts. All transactions was showing on GA, but client needs to find, which transactions was made with discount code.
And there comes the biggest problem - as I said, thats SaaS platform, and code was closed.
We have created additional PHP app, for processing orders from Shoper, maybe there will be a option to 'inject' additional GA data this way? From app, we have access to all order data. Is that possible, to update some data on GA, basing on transaction ID? Or maybe you have some other solution for that?
Google Analytics has a data import feature, however the only import type that ties to a transaction id is refund data (which will not allow you to attach a discount code to the transaction). I would suggest a workaround, but can give no real guarantee that it will actually work (since data imports take a while to process this would take a long time to test).
Data imports need a key field within GA, with the same key in the data you want to import from an external source.
One of the data import types is "custom data". With that you can use a custom dimension as key. For that you need to create two custom dimensions - for examples sake I'll call them "key" and "coupon", both are hit scoped.
Next you have to set up a advanced filter in your view settings. If the request url matches the confirmation page you extract the transaction id and copy it (via "Output to constructor") to the custom dimension "key".
Next you go to property settings -> data import -> new data set -> type "custom data".
Give the data set a name, attach a view. In the data schema setting select "custom dimensions->key" as key field. In the imported data field select "custom dimensions->coupon" (as created above). Select "overwrite hit data". Download the data schema.
Prepare the data you want to import. In the data schema file fill the first column with the transaction ids. In the second column fill the rows with coupon code per transaction where applicable.
Go to your data import, click "manage uploads" and upload your file. Wait 24 hours until the data is processed. If things work as hoped the pageviews for the transactions will now have the custom dimension with the coupon id attached (if applicable, else it will simply be empty). I.e. the dimension will still not be tied to the transaction id, but at least to the pageview where the transaction took place, so that's the next best thing.
As I've said that's untested, but I do not see any particular reason why it wouldn't work, even if it's quite a roundabout way.

Paypal multiple payments

I'm trying to write a PHP class for paypal express mutliple payments. All is well so far except one thing I haven't figured out.
In PayPal's docs it says that PAYMENTREQUEST_n_PAYMENTREQUESTID is a required field for multiple payments, however I have no idea where to obtain a value for it. Is it a user set value? I tried putting random values and PP returns a SUCCESS however I'm not sure if that's good or bad.
PAYMENTREQUESTID is a user set value. The purpose of this field is to allow you co-relate response data for each of your parallel payments with your request data - Therefore it is good enough that this field is unique amongst multiple payment data for a given API call but random numbers should work too. See the docs for more.

QuickBooks API error when updating

I'm attempting to use the QuickBooks API to sync up my company's product list with the workbook's item list. I have gotten through the OAuth system to be able to make read/write requests to the API, but always get an error while attempting to update an object.
The reference that I have been using is here, and within the same documentation is a reference to retrieving an object that I have been able to use just fine. This is the XML that I'm sending. I have been tweaking the XML for a few hours now to no avail.
The error message that I get is "QB item name already exists ERI=420962215". That ERI is my realm ID. It seems like QuickBooks thinks I am trying to add a new item, when I'm trying to modify an existing one. If I omit the name field or leave it null, it gives me an error as well.
The item that I am attempting to modify was created in QuickBooks, then synced through QuickBook's Sync Manager. I then authenticated my app to that workbook and have been able to read data easily. I only have an issue when I attempt to write. I have yet to try creating or deleting an object since I've been stalling out on updating.
I am trying to just set up a simple form on my company's site that will hit the API and update data when saving, but I can't find a way around this error.
Any help would be greatly appreciated. I began to have trouble on Friday and feel like I'm just spinning in circles now. I found a QuickBooks / PHP library and tried looking through it to see if I could find useful information, but it was a bit too large for me to locate what I was looking for, since I think the error is just some incorrect XML.
I have followed all the directions within the update reference and just can't make progress. I've double and triple checked that my authentication works, that the URL is correct, that I'm sending POST and not GET and that my XML matches the XML shown in that example.
UPDATE 2012-03-15
It seems the problem is that the API is not able to update an item that was created through QuickBooks. Ever item has an id and an idDomain, which indicates if it was made through the API (NG) or Quickbooks (QB). An example id/idDomain would be 1/QB or 2556587/NG.
Whenever I was doing this, I was able to perfectly update an item that was made through the API, but not one made through Quickbooks. After looking into the Supported Object Reference, I noticed that item assembly update/create is listed as beta.
It seems that what I wrote in the update is correct. I am not able to update items that were made in quickbooks through the API. I can read items made in quickbooks, I can create items and I can edit items made through the API, but editing an item made in quickbooks through the API returns this error.
A few things:
What URL are you POSTing to?
Can you show the full HTTP response you're getting? IDS has a bad
habit of returning error messages/codes that are sometimes ambiguous
if you don't look at the full XML response.
Some of these fields are not updateable: QtyOnPurchaseOrder,
QtyOnSalesOrder
You do know you can only use IDS/Sync Manager for applications you're
going to resell to other companies, right? i.e. you can't use it for
internal/one-off apps.
You're going to get much better support if you post these questions
to Intuit's developer forums: https://idnforums.intuit.com/
You may consider migrating to QBO V3 it is way better and easy to work with.
there is a very good api made to for this purpose. which you can get here.
https://github.com/consolibyte/quickbooks-php (Made By : Keith Palmer)
i am using this and am very satisfied with it.

Categories