Verify affiliate/ referral code is associated to an order fulfilled

I am trying to develop a chrome extension that would have cashback functionality. In order to do this, I am supposed to add referral codes or affiliate IDs to product listings on different eCommerce stores. For the sake of understanding, I shall take Amazon.com as one of the eCommerce stores where the content script may modify the product urls on listing pages.
The cashback would work the following way if user did buy from the affiliate ID/ referral code then part of earnings made against that transactions are to be given back to the user.

I dont have much knowledge about affiliates or referral code programs offered by eCommerce stores, I want to figure out a way to verify that a particular transaction/ order fullfilled was associated with the referral code or affiliate ID, this needs to be done in order to make sure that user is indeed eligible for the cashback.

Any help would be appreciated.