Tips and Tricks HQ Support Portal › Forums › WP Affiliate Platform › Duplicate sales logged on download page refresh
Tagged: affiliate, Duplicate Sales
- This topic has 2 replies, 2 voices, and was last updated 13 years ago by coryshaw.
-
AuthorPosts
-
November 17, 2011 at 9:46 pm #4802coryshawMember
I’ve recently bought, installed, and configured the affiliate plugin. Everything seems to work great except for one thing…
When a user makes a purchase via paypal (I’ve configured PayPal option 1: PDT), PayPal redirects the user to a page outside of wordpress, so I used the API get option to give the affiliate credit for the sale.
Paypal adds the following string to the url on the download page after the redirect:
tx=57862310054145335&st=Completed&amt=49.00&cc=USD&cm=&item_number=
The issue I’m having is that when I refresh the download page, the affiliate plugin logs each refresh as a sale. The affiliate gets an email every refresh and I’ve refreshed the affiliate stats page to verify this.
I’m using the following php code on my page:
$affiliate_id = $_COOKIE;
if ($affiliate_id){
$secret = “my secret id”;
$referrer = $affiliate_id;
$sale_amt = $_GET;
$transaction_id = $_GET;
$prepared_data = “?secret=”.$secret.”&ap_id=”.$referrer.”&sale_amt=”.$sale_amt.”&transaction_id=”.$transaction_id;
$get_url = “http://myurl.com/wp-content/plugins/wp-affiliate-platform/api/post.php”.$prepared_data;
// Execute this GET Request
file_get_contents($get_url);
}
I was hoping that the “tx” attribute that paypal returns would log as a transaction_id, and upon refresh it wouldn’t log extra purchases.
Any ideas?
Thanks!
November 18, 2011 at 12:16 am #38641adminKeymasterYou have a mistake in the code… the
transaction_id
parameter name needs to be changed totxn_id
. So it should be like the following:$prepared_data = "?secret=".$secret."&ap_id=".$referrer."&sale_amt=".$sale_amt."&txn_id=".$transaction_id;
You are also not checking for the unique transaction ID in the database before calling the commission awarding API. The affiliate plugin has a built in integration option that can work with PayPal PDT and will take care of the issue… any reason why you are not using that build in option?
Anyway, I have also made a slight change in the API so it does the check for you before adding the commission (this will prevent duplicates). Please get a new build of the plugin from here and update it:
November 18, 2011 at 6:35 am #38642coryshawMemberThat did the trick. thanks so much for your help, and for the awesome plugin you’ve created! Cheers.
-
AuthorPosts
- You must be logged in to reply to this topic.