I always assumed that txn_id sent with IPN message is unique. PayPal guidelines seem to support this idea - https://cms.paypal.com/us/cgi-bin/?cmd=_render-conte
txn_id
In my PHP API call, i use these fields and store them in my database:
custom=xxxx
(or invoice=ZZZZZZ)
invoice=ZZZZZZ
then, when your page receives IPN, it should check (from database) if the custom=xxxx or etc...