Steven1978
Steven1978

Reputation: 506

QUickbooks PHP SDK add invoice payment

I am trying to add payments to an invoice using the Quickbooks PHP SDK.

I can create customers, invoices, items, sales lines etc but I am a little stuck when it comes to the correct way to create and link a payment to an invoice.

This is what I have been trying:

$qbLinkedInvoice = new IPPLinkedTxn();
$qbLinkedInvoice->TxnId = 277; // the QB invoice ID
$qbLinkedInvoice->TxnType = 'Invoice';

$qbPayment = new IPPPayment();
$qbPayment->Amount = 10.0;
$qbPayment->CustomerRef = 164; // the QB cusotmer ID
$qbPayment->LinkedTxn = $qbLinkedInvoice;

$createdQbPayment = $this->dataService->Add($qbPayment);

But this just gives:

CheckNullResponseAndThrowException - Response Null or Empty

Which means something isn't formatted correctly. All the refs are correct (Exist in quickbooks, invoice, customer etc).

I have been sending up invoice line items by creating an IPPSalesItemLineDetail Object and then assigning that to the line and then assigning that to the invoice as the 'Line' array property at the point when the invoice is created in quickbooks but I can't seem to figure out how to send a payment and link that to an invoice.

There aren't any samples within the SDK that give me any clues either.

Any help would be greatly appreciated. Thanks.

Upvotes: 2

Views: 1209

Answers (2)

hlu2
hlu2

Reputation: 119

Refer to the example here is you are using PHP official SDK, you can just pass an array to create Invoice and Payment: https://github.com/intuit/QuickBooks-V3-PHP-SDK

Upvotes: -1

Steven1978
Steven1978

Reputation: 506

Found how to do it. I was missing a IPPLine object to tie the Payment and LinkedTxn objects together. This is what worked:

$qbLinkedInvoice = new IPPLinkedTxn();
$qbLinkedInvoice->TxnId = 277;
$qbLinkedInvoice->TxnType = 'Invoice';

$qbLine = new IPPLine();
$qbLine->Amount = 10.0;
$qbLine->LinkedTxn = $qbLinkedInvoice;

$qbPayment = new IPPPayment();
$qbPayment->CustomerRef = 164;
$qbPayment->TotalAmt = 10.0;
$qbPayment->Line = [$qbLine];

$createdQbPayment = $this->dataService->Add($qbPayment);

Upvotes: 4

Related Questions