QuickBook API集成,在美国公司发行添加账单付款

时间:2016-11-25 06:21:17

标签: asp.net quickbooks

我正在尝试从我的应用程序添加帐单付款,验证错误来了: 请求中缺少必需的参数 CheckPayment / CreditCardPayment

无法获得解决方案。请参阅图片Image

整个连接性进展顺利但缺少参数问题即将到来。 我只是代码以下:

protected void btnBillPayment_Click(object sender, EventArgs e)
        {
            try
            {
                var dataService = GetDataService();
                var context = GetServiceContext();

                decimal _amount = 200m;

                BillPayment billPayment = new BillPayment
                {
                    VendorRef = new ReferenceType
                    {
                        Value = "71",
                        name = "Lotus"
                    },
                    APAccountRef = new ReferenceType
                    {
                        name = "Fuel",
                        Value = "56"
                    },
                    PayType = BillPaymentTypeEnum.Check,
                    PayTypeSpecified = true,
                    BillPaymentEx = new IntuitAnyType
                    {
                    },
                    TotalAmt = _amount,
                    TotalAmtSpecified = true,
                    domain = "QBO",
                    MetaData = new ModificationMetaData
                    {
                        CreateTime = DateTime.Now,
                        LastUpdatedTime = DateTime.Now
                    },
                    TxnDate = DateTime.Now,
                    TxnDateSpecified = true,
                    //DepartmentRef=new ReferenceType
                    //{

                    //},
                    CurrencyRef = new ReferenceType()
                                {
                                    //name = ?,
                                    //Value = ?
                                },
                    PrivateNote = "Private Note",
                    Line = new Line[] 
                    {
                        new Line
                        {
                            Amount=_amount,
                            AmountSpecified=true,

                            LinkedTxn=new LinkedTxn[]
                            {
                                new LinkedTxn
                                {
                                    TxnId="234",
                                    TxnType="Bill"
                                }
                            }
                        }
                    },


                };
                BillPayment resultBillPayment = dataService.Add<BillPayment>(billPayment);
            }
            catch (Exception ex1)
            {
                throw ex1;
            }
        }

提前感谢您提供正确的指导

1 个答案:

答案 0 :(得分:1)

您需要在对象中设置子对象CheckPayment,以提供特定于支票付款的付款详细信息。

换句话说,你告诉QuickBooks这是通过支票支付的:

PayType = BillPaymentTypeEnum.Check,

但是您没有告诉它支票付款的详细信息:

  "PayType": "Check",
  "CheckPayment": {
    "BankAccountRef": {
      "value": "35",
      "name": "Checking"
    }
  },

如果你参考Intuit的文档,你会在他们的例子中看到这一点:

记录:

CheckPayment:
required if PayType is Check
BillPaymentCheck 
Reference to the vendor for this transaction.

CreditCardPayment:
required if PayType is CreditCard
BillPaymentCreditCard, filterable via CCAccountRef, sortable 
Information about a credit card payment for the transaction. Not applicable to Estimate and SalesOrder. Used when PayType is CreditCard.

同时显示的子属性:

BillPaymentCheck 
Reference to the vendor for this transaction.

Child attributes

BankAccountRef:
required
ReferenceType, filterable, sortable 
Reference to the bank account. Query the Account name list resource to determine the appropriate Account object to reference here. Use Account.Id and Account.Name from that object for APAccountRef.value and APAccountRef.name, respectively. The specified account must have Account.AccountType set to Bank and Account.AccountSubType set to Checking.

PrintStatus:
optional
PrintStatusEnum, default is NeedToPrint 
Printing status of the invoice. 
Valid values: NotSet, NeedToPrint, PrintComplete.