Your customer visits an affiliate (say, Affiliate123.com) and the affiliate sets a cookie. All subsequent requests from the browser to that site includes the browser cookie information from that point forward.
Then the customer clicks a link to your site.
The page the affiliate sends the customer to will likely have an image or JavaScript on it to call back to the affiliate site. For simplicity, this example is of an image pixel.
<img src="https://affiliate123.com/your-id-number/pixel.png" height="1" width="1">
This tracks that the customer actually arrived at your site.
Then, once the customer places an order there will be another pixel with query string parameters attached where you inject that data into the link.
For example, on your receipt page, you would place their pixel image tag and add the data as query string parameters.
<img src="https://affiliate123.com/your-id-number/pixel.png**?total=123.45&qty=5**" height="1" width="1">
The domain cookie from the affiliate is passed with the image request. That cookie would have the customer info along with whatever data they need to connect the affiliate link to the transaction.
The details provided in the query string parameters can vary widely depending on how specific the data requirements are. If you only pay for certain products being purchased, then obviously you will need to provide that data to the affiliate in the pixel. The example above is a common way to track conversion.
If the affiliate requires JavaScript, then they add the code and you will either add the data they need into META tags or in a JavaScript data layer with standard names that they can access.