2016-01-22 40 views
1

編輯QuickBooks的 - 所有的問題在本週一小型一體化項目中使用.NET IPP QBOV3 SDK添加發票網上使用.NET IPP QBOV3 SDK

我一直在努力(掙扎)回答

。 該項目的目的是能夠在Windows桌面客戶端應用程序與在線快速書籍之間進行一些帳戶集成。

我希望能 -

  1. 創建新客戶/供應商(可以做到這一點)
  2. 新增銷售發票(不能做到這一點)
  3. 返回信貸餘額(甚至沒有試過這種尚未)

在閱讀了幾個論壇和文章以瞭解QBOV3 .NET SDK的使用之後,出於兩個原因。

  1. 我將使用C#.NET,作爲一個WinForms應用程序編寫的 功能,我需要(這讓我有功能集成在 當前系統中,這也是用C# .net winforms)

  2. 看起來似乎覺得這是要走的路,因爲所有API都是 將被折舊。

因此,我的第一個障礙是OAuth--最終我找到了答案。我現在可以授權並連接到我的QBO沙盒帳戶 - 太棒了!

我也可以從winforms應用程序創建客戶,他們出現在QBO - 也很棒!

下一步,我打倒了最後2個左右,是能夠爲客戶創建一個發票 - 我似乎不知道該怎麼做。我不斷收到'錯誤的請求'錯誤。

我發現旁邊沒有例子在網上如何從C#winforms應用程序做到這一點。它不是那麼難 - 所以我現在真的踢了自己。

任何幫助,或樣品,讓我在正確的方向,將不勝感激。 我不相信這個已經存在的簡單例子 - 我想沒有多少人是通過桌面winforms應用程序來做到這一點,或者我只是在錯誤的地方尋找 - 或者錯過了一些明顯的東西!

通過API文檔閱讀令人困惑,並沒有真正提供任何示例代碼。我認爲添加銷售發票將是一件非常重要的事情。

這是我目前使用的代碼來獲得一些簡單的功能 - 創建客戶工作正常(如果客戶不在qbo中存在 - 這是我添加之前需要檢查的東西 - 所以任何操作都會也很棒)

這是我拼湊到一起的代碼..

private void button2_Click(object sender, EventArgs e) 
    { 
     string consumerKey = "consumerKey"; 
     string consumerSecret = "consumerSecret"; 

     string accessToken = "accessToken"; 
     string accessTokenSecret = "accessTokenSecret"; 

     string appToken = "appToken"; 
     string companyID = "companyID"; //realmID 

     OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret); 

     ServiceContext context = new ServiceContext(appToken, companyID, IntuitServicesType.QBO, oauthValidator); 
     //uses production as default, which is https://quickbooks.api.intuit.com 
     context.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/"; 
     //If not set, the default base URL, https://quickbooks.api.intuit.com, is used 



     DataService service = new DataService(context); 

     //add customer 
     Customer customer = new Customer(); 

     customer.CompanyName = "Jims Junk"; 
     customer.GivenName = "Jim"; 
     customer.FamilyName = "Little"; 
     customer.PrimaryEmailAddr = new EmailAddress() { Address = "[email protected]", Default = true }; 
     customer.DisplayName = "Jims Junk Ltd" 

     Customer resultCustomer = service.Add(customer) as Customer; 


     //invoice 

     //-An invoice must have at least one Line that describes an item. 
     //- An invoice must have CustomerRef populated. 
     //- The DocNumber attribute is populated automatically by the data service if not supplied. 
     //- If ShipAddr, BillAddr, or both are not provided, the appropriate customer address from Customer is used to fill those values. 
     //-DocNumber, if supplied, must be unique. 

     Invoice invoice = new Invoice(); 

     invoice.DocNumber = "uniqueNumber"; 
     invoice.TxnDate = DateTime.Today.Date; 
     invoice.TxnDateSpecified = true; 
     invoice.CustomerRef = new ReferenceType() 
     { 
      name = customer.DisplayName, 
      Value = resultCustomer.Id 
     }; 

     Line invLine = new Line(); 

     invLine.Amount = 10000; 
     invLine.DetailType = LineDetailTypeEnum.SalesItemLineDetail; 
     invLine.Description = "Test Product"; 

     invoice.Line = new Line[] { invLine }; 


     Invoice resultInvoice = service.Add(invoice) as Invoice; 


    } 
+0

你能告訴我,我應該通過什麼價值。 string accessTokenSecret =「」; string appToken =「appToken」; –

回答

2

Sods法律,幾天後沒有發現任何東西 - 剛纔我找到了一個有幫助的代碼示例。

我現在已經設法投遞到QBO的發票。

這裏是鏈接,幫助 - http://developer.qbapi.com/Create-Invoice-Error---Bad-Request.aspx

生病剛剛離開這裏,讓別人可以,如果掙扎受益。

感謝您的閱讀。

+0

使用上面的代碼創建發票。但我收到了一個錯誤。 「類型的異常‘Intuit.Ipp.E​​xception.IdsException’發生在Intuit.Ipp.DataService.dll」 你能告訴我我得到這個錯誤。 –