使用.NET IPP QBOV3 SDK在线添加发票到quickbooks

问题描述 投票:1回答:1

使用.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;


    }
c# quickbooks quickbooks-online
1个回答
2
投票

Sods Law,几天没找到任何东西 - 刚才我找到了一个有帮助的代码示例。

我现在设法将发票寄到QBO。

这是帮助的链接 - http://developer.qbapi.com/Create-Invoice-Error---Bad-Request.aspx

生病只是留在这里,以便其他人可以受益,如果挣扎。

谢谢阅读。

© www.soinside.com 2019 - 2024. All rights reserved.