How do I apply a payment to an existing invoice with the QuickBooks Online API v3 in C#?
I have tried the following code:
private void UpdateInvoice(Payment payment)
{
Invoice oldInvoice = cmbInvoices.SelectedItem as Invoice;
if (oldInvoice == null) return;
Invoice invoiceToUpdate = new Invoice();
invoiceToUpdate.Id = oldInvoice.Id;
invoiceToUpdate.SyncToken = oldInvoice.SyncToken;
invoiceToUpdate.Deposit = payment.TotalAmt;
invoiceToUpdate.DepositSpecified = true;
invoiceToUpdate.sparse = true;
invoiceToUpdate.sparseSpecified = true;
invoiceToUpdate.PaymentType = PaymentTypeEnum.CreditCard;
invoiceToUpdate.PaymentTypeSpecified = true;
invoiceToUpdate.PaymentMethodRef = payment.PaymentMethodRef;
invoiceToUpdate.PaymentRefNum = payment.PaymentRefNum;
invoiceToUpdate.CustomerRef = oldInvoice.CustomerRef;
QBO.DataService.Update(invoiceToUpdate);
}
and it fails with this error:
{"ValidationException was thrown."}
I'm clearly missing something here or I must be doing something wrong. The error message is useless and wish Intuit would clean this up.
I'm getting pretty frustrated with the bad documentation that Intuit puts out for their QuickBooks Online API v3 and wish their would start cleaning it up and making it useful. Also, please remove those dead 404 pages as well while you are at it.
Any help or pointers would be awesome.