如何使用PHP SDK快速手册创建多个付款

时间:2019-02-06 11:06:01

标签: php sdk quickbooks quickbooks-online

我正在使用PHP创建Quickbook应用程序

我正在使用https://github.com/intuit/QuickBooks-V3-PHP-SDK/

我想在单个API调用中向多张发票付款。 我看到了他们的例子,但那些只付一次。我需要针对不同客户的各种发票进行多次付款。

那怎么可能?

2 个答案:

答案 0 :(得分:1)

他们的示例代码在这里:

这是一个代码段:

$theResourceObj = Payment::create([
  "CustomerRef" =>
  [
      "value" => "1"
  ],
  "TotalAmt" => 100.00,
  "Line" => [
  [
      "Amount" => 100.00,
      "LinkedTxn" => [
      [
          "TxnId" => "210",
          "TxnType" => "Invoice"
      ]]
  ]]
]);
$resultingObj = $dataService->Add($theResourceObj);

然后,如果您参考他们的文档:

您会看到Line元素由Zero or more transactions accounting for this payment.组成,包括The invoice to which payment is applied。也就是说,您可以在Line中重复操作,以将付款应用于多个发票。

因此,将付款应用于多个发票会在重复的Line节点数组中列出每个单独的发票以及要应用的付款金额:

$theResourceObj = Payment::create([
  "CustomerRef" =>
  [
      "value" => "1"
  ],
  "TotalAmt" => 100.00,
  "Line" => [
    [
        "Amount" => 50.00,
        "LinkedTxn" => [
        [
            "TxnId" => "210",
            "TxnType" => "Invoice"
        ]]
    ],
    [
        "Amount" => 25.00,
        "LinkedTxn" => [
        [
            "TxnId" => "211",
            "TxnType" => "Invoice"
        ]]
    ],
    [
        "Amount" => 25.00,
        "LinkedTxn" => [
        [
            "TxnId" => "212",
            "TxnType" => "Invoice"
        ]]
    ],
  ]
]);
$resultingObj = $dataService->Add($theResourceObj);

答案 1 :(得分:0)

最后我找到了解决方法。

API具有批处理选项,可在单个批处理中添加多个对象。

谢谢大家