如何使用 PHP SDK Quickbooks 创建多个付款

how to create multiple payments using PHP SDK Quickbooks

我正在 PHP

中为 Quickbook 创建应用程序

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

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

这怎么可能?

他们的示例代码在这里:

所以这是一个片段:

$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);

终于找到适合我的解决方案。

API 有批量选项可以在单个批次中添加多个对象。

感谢大家