quickbooks sdk添加付款

时间:2015-05-31 20:28:54

标签: c# quickbooks qbfc

您好我一直在尝试使用quickbooks sdk添加付款,到目前为止我已经能够做好所有事情但是当我向quickbooks发送请求时,我收到一条消息,说明交易是空的< / p>

这是我的示例代码: 代码正在使用来自quickbooks的示例公司之一,所以如果你在c#项目上通过它,它将立即运行

   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 个答案:

答案 0 :(得分:3)

您必须发送总金额才能向QuickBooks添加付款。

您可以使用该行设置已注释的总金额:

//Payment.TotalAmount.SetValue(100.00);

取消注释,你很高兴。