This is almost certainly incorrect:
$LinkedTxn->setTxnId('10001'); //real invoice number in quickbooks
You should be using the Id value from the invoice in QuickBooks. The Id value is different from the user-visible Invoice reference # (the DocNumber field).
You need to use the Id value.
This also doesn't make a whole lot of sense:
$Line->setAmount(1);
...
$Payment->setTotalAmt(0.01);
How can the total payment amount be only 1 penny, and then you try to apply a full dollar to the invoice?