That is what I had also ... not yet working completely because the payment processor triggers the payment_gateway.php, which means that the tracking token for the affiliate script is not present.
Currently I am looking at other ways including having a successful payment send the actual user back through the payment_gateway.php script.