0

Hi i've been trying to add payments using the quickbooks sdk, so far so good I'm able to do everything but when I send the request to quickbooks I got a message that the transaction is empty

here is my sample code: the code is using one of the sample company from quickbooks so if you past this on a c# project it will run right away

   private static void CreatePayment()
        {
            //var Customers = GetCustomers();
            bool sessionBegun = false;
            bool connectionOpen = false;
            QBSessionManager sessionManager = null;

            try
            {
                //Create the session Manager object
                sessionManager = new QBSessionManager();

                //Create the message set request object to hold our request
                IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 8, 0);
                requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;

                //Connect to QuickBooks and begin a session
                sessionManager.OpenConnection(@"qid", "QuickBooks Integration Demo");
                connectionOpen = true;
                sessionManager.BeginSession(@"C:\Users\Public\Documents\Intuit\QuickBooks\Sample Company Files\QuickBooks Enterprise Solutions 15.0\sample_product-based business.qbw", ENOpenMode.omMultiUser);
                //sessionManager.BeginSession("", ENOpenMode.omDontCare);
                sessionBegun = true;

                IReceivePaymentAdd Payment = requestMsgSet.AppendReceivePaymentAddRq();
                Payment.CustomerRef.ListID.SetValue("260000-933272658");
                //Payment.TotalAmount.SetValue(100.00);
                //Payment.ORApplyPayment.IsAutoApply.SetValue(true);


                ////// Create the AppliedToTxn request for the payment.

                IAppliedToTxnAdd PaymentLine = Payment.ORApplyPayment.AppliedToTxnAddList.Append();
                //// Set the invoice TxnID and amount of the payment to apply
                PaymentLine.TxnID.SetValue("8B8-933372331");
                PaymentLine.PaymentAmount.SetValue(100.00);






                //Send the request and get the response from QuickBooks
                IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
                IResponse response = responseMsgSet.ResponseList.GetAt(0);
                var StatusMessage = response.StatusMessage;
                Console.WriteLine(StatusMessage);



                //IReceivePaymentAdd Done = (IReceivePaymentAdd)response.Detail;

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //MessageBox.Show(ex.Message, "Error");
            }
            finally
            {
                //End the session and close the connection to QuickBooks
                if (sessionBegun)
                {
                    sessionManager.EndSession();
                }
                if (connectionOpen)
                {
                    sessionManager.CloseConnection();
                }
            }
            Console.ReadLine();
        }

1 Answers1

3

You must sent a total amount in order to add a payment to QuickBooks.

You have the line to set the total amount commented out:

//Payment.TotalAmount.SetValue(100.00);

Uncomment it and you're good to go.

Keith Palmer Jr.
  • 27,666
  • 16
  • 68
  • 105
  • already did, and still does not work, if you want to download the source and take a look, here is a link to download it https://intuitdeveloper.lc.intuit.com/questions/1168027 – Jose Manuel Ojeda Jun 01 '15 at 14:23
  • In the cost you posted there, you still have the total amount commented out. You need to uncomment that line. If you still have trouble, check the error message again and post *the exact error message* you get. – Keith Palmer Jr. Jun 01 '15 at 14:32
  • I think I have tried that on the past and did not work, now its working thanks for your help – Jose Manuel Ojeda Jun 01 '15 at 15:56