First impression: You might be able to do this by creating a different non-stored custom field on Payment that sources from the attached Invoice's value.
This would be slow to search but otherwise acceptable. If the unique ID is available on the invoice when the payment is created, you could make it a stored field to mitigate that problem - but you could get mismatches/orphans if someone edits the unique ID on either transaction at a later time