Hello,
Here is how the plugin works:
- The file _append_master.inc.php creates a session and a cookie with the affiliate id.
- The class orderPeer uses the session/cookie when a new order is created, totally outside the plugin scope.
- The file _append_payment_ipn_paypal.php is called after a paypal payment and add a new entry on the table plugin_reward.
This plugin has some flaws. The way it is it's not possible to pay for every renewal and it's also not possible to prevent payments for renewals. If the user gets a new cookie with an affiliate id and make a new order, the plugin will count it. It's also possible to a browser addon to create/change the user's cookie and make the user's renewals count as sales to a specific affiliate.
Here are some suggestions to improve it:
- The file _append_master.inc.php should create a session with the affiliate id only if the user is not logged in.
- The affiliate id should be stored on the user table in a new field affId. This will make possible to enable payments for each renewal.
- The file _append_payment_ipn_paypal.php should have a generic name like "payment_confirmed" or something. It should work for every payment method and not only for paypal. This file should get the affiliate id from the users' table and check if this is the user's first order, if you are not paying for renewals.
I'm making this changes in my script and I'll probably share some files here when I'm done.
Here is how the plugin works:
- The file _append_master.inc.php creates a session and a cookie with the affiliate id.
- The class orderPeer uses the session/cookie when a new order is created, totally outside the plugin scope.
- The file _append_payment_ipn_paypal.php is called after a paypal payment and add a new entry on the table plugin_reward.
This plugin has some flaws. The way it is it's not possible to pay for every renewal and it's also not possible to prevent payments for renewals. If the user gets a new cookie with an affiliate id and make a new order, the plugin will count it. It's also possible to a browser addon to create/change the user's cookie and make the user's renewals count as sales to a specific affiliate.
Here are some suggestions to improve it:
- The file _append_master.inc.php should create a session with the affiliate id only if the user is not logged in.
- The affiliate id should be stored on the user table in a new field affId. This will make possible to enable payments for each renewal.
- The file _append_payment_ipn_paypal.php should have a generic name like "payment_confirmed" or something. It should work for every payment method and not only for paypal. This file should get the affiliate id from the users' table and check if this is the user's first order, if you are not paying for renewals.
I'm making this changes in my script and I'll probably share some files here when I'm done.