Custom Affiliate Link For Each Client

Hi, I have a vision that I’m not even sure if possible but would love some feedback on this.

When a client signs up on our website they will be redirected to a “Thank You/Confirmation” page. When this web page is loaded ideally we would populate a unique link that allows us to track and offer a discount to the client for sharing and getting friends to sign up with it.

In summary, i am looking to have affiliate marketing done with a custom link for each purchase. And have no idea how to achieve this. Any help or insight would be greatly appreciated.