OK, I am looking at the code and I do not have an iDevAffilaite package (yet) so I need to guess a little what is going on here so bear with me as I try to summarize what this is doing.
Step 1: payments.php simply adds the IP address of the person who has purchased the subscription.
Comment: It really is too bad vBulletin doesn't have a hook right after the code you quote as we could simply run an update where "hash" = $hash. The hook that is in the while loop could be used however if we added a variable for example:
paidsub_order_paymentbit Plugin:
PHP Code:
if($vbulletin->options['idevaffiliate_active'] AND $ipsaved != '1'){
$escapedhash = $db->escape_string($hash);
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "paymentinfo
SET ipaddress = " . IPADDRESS . "
WHERE hash = " . $escapedhash . "
");
$ipsaved = '1';
}
Question - Is this IP information important and required (remember I don't use the script)? I ask as with vBulletin we know more about a user then just the IP they used to pay including registration IP, all IPs they used, plus e-mail, etc. Again, I have not used the affiliate script so just curious why this matters as we know who the user is and that is the most important matter for us.
Step 2: payment_gateway.php saves the sale in the affiliate script
This is really an amazing file in vBulletin as there is not a single hook in this file

There is no way around a file edit in this file but I am not convinced we have to use the file to do this. I say this as we do have hooks in class file that does subscriptions:
./includes/class_paid_subscription.php
I am curious why we can't use the paidsub_build hook to log the sale into the affiliate script? There could also be a plugin added to paidsub_delete to handle reversals too (I think).
Summary:
I am really not trying to be critical as I am very thankful you shared your work as I have been considering adding an affiliate script to my own premium site. I am really not going to be able to test this without buying the software but I think that if you look at the possibility of moving the STEP 2 of this to the Class that you may be able to remove the file edits.
Also, as I said above, I don't see the value in the "Step 1" addition as vBulletin allows us to know a whole lot about our users that are far above the IP they are using when they pay for a subscription
I welcome feedback on my humble oppinions as I know there are developers and coders on here with far more skill then I have.
Cheers,
Ken