title: How to apply a payment to an invoice with the QBO API v3 in C#?
body: <p>How do I apply a payment to an existing invoice with the QuickBooks Online API v3 in C#?</p>
  
  <p>I have tried the following code:</p>
  
  <pre><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);
      }
  </code></pre>
  
  <p>and it fails with this error:</p>
  
  <pre><code>{"ValidationException was thrown."}
  </code></pre>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>Any help or pointers would be awesome.</p>