Payment is not generated

My payments are not showing in QuickBooks.

I can successfully create and update Clients. I can also successfully create and update invoices. I cannot create payments. But here's what, when I execute the Update command on my Payment object, I get the correct ID and Domain (NG) that gets passed back. I checked the sync log file (IntuitSyncManagerLogger.log) after running Sync, but it has no error messages. Everything looks fine, there is simply no payment associated with the invoice in QuickBooks.

I believe I am setting all the required fields, but I am not sure about two of them.

1) PaymentLine has a field named TxnId. I am setting it as Id and Domain InvoiceHeader but not sure if this is correct.

2) There is another required field (in the documentation) but I leave it blank as I don't know what to fill in. This is the DiscountAccountId field. I don’t need invoice-related discount.

Here is my code ...

SqlConnection connection = new SqlConnection(m_connectionString);
connection.Open();

SqlCommand cmd = new SqlCommand("dbo.Intuit_GetPayment", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@glmvSyncId", SqlDbType.Int).Value = glmvSyncId;

SqlDataReader rdr = cmd.ExecuteReader();
rdr.Read();

Intuit.Ipp.Data.Qbd.PaymentHeader paymentHeader = new Intuit.Ipp.Data.Qbd.PaymentHeader();
paymentHeader.ARAccountId = new Intuit.Ipp.Data.Qbd.IdType() {
    idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB,
    Value = "37"
};
paymentHeader.ARAccountName = "Accounts Receivable";
paymentHeader.DepositToAccountId = new Intuit.Ipp.Data.Qbd.IdType() {
    idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB,
    Value = "35"
};
paymentHeader.DepositToAccountName = "Undeposited Funds";
paymentHeader.CustomerId = new Intuit.Ipp.Data.Qbd.IdType() {
    idDomain = (rdr["cust_iddomain"].ToString() == "QB" ? Intuit.Ipp.Data.Qbd.idDomainEnum.QB : Intuit.Ipp.Data.Qbd.idDomainEnum.NG),
    Value = rdr["cust_idvalue"].ToString()
}; // cust_iddomain and cust_idvalue are from the Customer
paymentHeader.DocNumber = rdr["invoicekey"].ToString();
paymentHeader.TxnDate = DateTime.Now; 

List<Intuit.Ipp.Data.Qbd.PaymentLine> listLine = new List<Intuit.Ipp.Data.Qbd.PaymentLine>();

var paymentLine = new Intuit.Ipp.Data.Qbd.PaymentLine();
paymentLine.Amount = Convert.ToDecimal(rdr["amount"]);
paymentLine.TxnId = new Intuit.Ipp.Data.Qbd.IdType() {
    idDomain = (rdr["invc_iddomain"].ToString() == "QB" ? Intuit.Ipp.Data.Qbd.idDomainEnum.QB : Intuit.Ipp.Data.Qbd.idDomainEnum.NG),
    Value = rdr["invc_idvalue"].ToString()
}; // invc_iddomain and invc_idvalue are from the InvoiceHeader

listLine.Add(paymentLine);

Intuit.Ipp.Data.Qbd.Payment syncPayment = new Intuit.Ipp.Data.Qbd.Payment();
syncPayment.Header = paymentHeader;
syncPayment.Line = listLine.ToArray();

connection.Close();

Intuit.Ipp.Data.Qbd.Payment resultPayment = new Intuit.Ipp.Data.Qbd.Payment();

resultPayment = commonService.Add(syncPayment);

      

I suspect the problem is with TxnId.

All I do is create a Client and then create an invoice for a Client and then create a Payment for an invoice. Am I missing an object?

Any help is greatly appreciated.

+3


source to share


2 answers


Adding the following lines of code seems to have fixed the problem. The payment is now recorded in QuickBooks.



paymentHeader.TotalAmt = Convert.ToDecimal(rdr["amount"]);
paymentHeader.TotalAmtSpecified = true;

      

+1


source


The payment probably goes into an error state after syncing. You can check by executing PaymentQuery and setting ErroredObjectsOnly = true.

https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0100_Calling_Data_Services/0015_Retrieving_Objects#Objects_in_Error_State

If the object is in an error state, you can query the specific reason using the Status API:

https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0600_Object_Reference/SyncStatus

SyncStatusRequest syncStatusRequest = new SyncStatusRequest();
syncStatusRequest.ErroredObjectsOnly = true;
syncStatusRequest.NgIdSet = new NgIdSet[] { new NgIdSet { NgId = <<EnterYourNgIdHere>>, NgObjectType = objectName.Payment } };
SyncStatusResponse[] response = dataServices.GetSyncStatus(syncStatusRequest);

      



If the payment is in error, you can delete the item from the cloud as it has never synced to QuickBooks:

https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0100_Calling_Data_Services/Deleting_an_Object

If a successful sync happened to the object at least once, but then the update moved it into an error state, you will need to do a Revert:

https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0100_Calling_Data_Services/Reverting_an_Object

You can also try updating directly on the entity in the error state as soon as you know the reason from the Status API, but it is not documented so it won't work.

+1


source







All Articles