I read out your requirements that you need to build affiliate program and i want to let you know that we recently develop affiliate script in php for sellout products of a magento site and that affiliate program is very similar to amazon affiliate program. If you need then i can explain more about that.
So as a experienced team in that work you can expect very good result from our side.
Thankyou