Search code examples
phpquickbooksquickbooks-online

How to make an Invoice as paid using PHP code at quickbooks online sdk


I have created Invoice using this code : https://github.com/intuit/QuickBooks-V3-PHP-SDK/blob/master/src/_Samples/InvoiceCreate.php

But how can make this invoice as paid using PHP sdk?

Here I am getting payment using paper check ... so I am creating Invoice just for bookkeeping and not sending to client. ( not using QBO Payment ) so when I rec payment how to mark invoice as paid using php sdk ?

I try to update "Balance" as 0 but its not marking as paid.

Thanks


Solution

  • First I'd really recommend you use The library written by Keith Palmer for this as the QBO documentation is garbage that's all over the place.

    With that being said:

    You need to return the transaction Id from the invoice:

    return $resultingObj->TxnId;
    

    And then create a payment using supplying that transaction id:

    $invoiceId = CreateInvoice(); //returns txnId above
    
    $qbLinkedInvoice = new IPPLinkedTxn();
    $qbLinkedInvoice->TxnId = $invoiceId;
    $qbLinkedInvoice->TxnType = 'Invoice';
    
    $qbLine = new IPPLine();
    $qbLine->Amount = "";//set amount;
    $qbLine->LinkedTxn = $qbLinkedInvoice;
    
    $qbPayment = new IPPPayment();
    $qbPayment->CustomerRef = "";//customer id
    $qbPayment->TotalAmt = "";//I think this must match amount above;
    $qbPayment->Line = array($qbLine);
    
    $createdQbPayment = $this->dataService->Add($qbPayment);