<?php

require_once '../QuickBooks.php';
$ReceivePayment = new QuickBooks_Object_ReceivePayment();
$ReceivePayment->setTotalAmount(65);
print $ReceivePayment->asQBXML(QUICKBOOKS_ADD_RECEIVEPAYMENT);
$ReceivePayment2 = new QuickBooks_Object_ReceivePayment();
$ReceivePayment2->setTotalAmount('35.00');
$AppliedToTxn = new QuickBooks_Object_ReceivePayment_AppliedToTxn();
$AppliedToTxn->setPaymentAmount(50);
$AppliedToTxn->setDiscountAmount(25);
$ReceivePayment2->addAppliedToTxn($AppliedToTxn);
print $ReceivePayment2->asQBXML(QUICKBOOKS_ADD_RECEIVEPAYMENT);
$priority_of_add_estimate_request = 10;
// Make sure this is lower than the customer add it depends on
if ($API->addEstimate($Estimate, '_quickbooks_ca_estimate_add_callback', $primary_key_of_estimate_in_your_application, $priority_of_add_estimate_request)) {
    print 'Queued up a request to add estimate #' . $primary_key_of_estimate_in_your_application . ' to QuickBooks!' . "\n";
}
// Journal entry
$JournalEntry = new QuickBooks_Object_JournalEntry();
$JournalEntry->setTransactionDate('January 2, 2009');
$DebitLine = new QuickBooks_Object_JournalEntry_JournalDebitLine();
$DebitLine->setAmount(45.0);
$DebitLine->setAccountName('Test Bank Account');
$JournalEntry->addDebitLine($DebitLine);
$CreditLine = new QuickBooks_Object_JournalEntry_JournalCreditLine();
$CreditLine->setAmount(45.0);
$CreditLine->setAccountName('Automobile Expense');
$JournalEntry->addCreditLine($CreditLine);
if ($API->addJournalEntry($JournalEntry, '_quickbooks_ca_journalentry_add_callback')) {
    print 'Queued up an add journal entry request to QuickBooks!' . "\n";
}
// Adding a payment for a customer
$Payment = new QuickBooks_Object_ReceivePayment();
$Payment->setCustomerApplicationID($primary_key_of_customer_in_your_application);
$Payment->setRefNumber(1234);
$Payment->setTxnDate(date('Y-m-d'));
$Payment->setTotalAmount(50.0);
$Payment->setIsAutoApply(true);
$priority_of_add_payment_request = 5;
// Make sure this is lower than the customer add it depends on
if ($API->addReceivePayment($Payment, '_quickbooks_ca_payment_add_callback', null, $priority_of_add_payment_request)) {
    print 'Queued up a request to add a payment to QuickBooks!' . "\n";
}