Better way to track PPS in the rewards plugin

enricodias4654

Member
YetiShare User
Jan 13, 2015
411
1
16
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.
 

enricodias4654

Member
YetiShare User
Jan 13, 2015
411
1
16
I just realized that this topic may fit better in the "Request For Changes (RFCs)" area. Fell free to move it if you like, Adam.
 

adam

Administrator
Staff member
Dec 5, 2009
2,043
108
63
Thanks for the suggestions. I've moved this to the RFCs so it's reviewed on the next dev round.
 

enricodias4654

Member
YetiShare User
Jan 13, 2015
411
1
16
I'm attaching some files to improve the tracking on PPS. With this new method is super easy to give rewards for renewals as well. Here are some comments to whoever wants to use them

userPeer.class.php will add the affiliate id in a new field "affId" in the user's table. Don't forget to create this field in the table.
_append_master.inc.php will make sure that the session is aways set with the affiliate id. It will handle the affiliate link, cookies and session.
_append_payment_confirmed.php will add the reward and should be called only when the payment is confirmed. I'm using a custom table to handle all payment methods. There are some comments on the code explaining everything.

I have customized my script a lot and I had to remove lots of code from those files to leave only the basic. If they have any error it should be some minor mistake or a typo.
 

Attachments

enricodias4654

Member
YetiShare User
Jan 13, 2015
411
1
16
In the files I've also changed the affiliate link to ?ref=. To work with current installations just change it back to aff.
 

pilot830

New Member
YetiShare User
Jan 22, 2014
242
1
0
Yeah I too would like to see the rewards plugin be able to continue to give the PPS percentage to the user who initially referrerd the person who upgraded to premium.
 

chienb

New Member
YetiShare User
Jun 3, 2016
15
0
0
any updates on this? hoping changes are being made to the plugin for beta