Jump to content
Sign in to follow this  
SamyT

Pay Pal IPN Module and Affiliate Tracking Problem

Recommended Posts

I'm using the Pay Pal IPN module, I got it to work so that it inserts the order into oscommerce and properly records a Pay Pal sale. The only problem is, I've just joined shareasale so I can run an affiliate program and their tracking - which consists of this on catalog/checkout_process.php:

 

// Begin Affiliate Program - Sales Tracking

$orders_total=$currencies->format($cart->show_total()- $total_tax);

tep_session_register('orders_total');

$orders_id=$order_products_id;

tep_session_register('orders_id');

// End Affiliate Program - Sales Tracking

 

and this on catalog/checkout_success.php:

// Start Affiliate Program - Sales Tracking

 

<?php

echo '<img src="https://shareasale.com/sale.cfm?amount='.$orders_total.'&tracking='.$orders_id.'&transtype=sale&persale=&perlead=&perhit=&merchantID=0001" width=1 height=1">';

tep_session_unregister('orders_total');

tep_session_unregister('orders_id');

?>

 

// End Affiliate Program - Sales Tracking

 

Does anyone out there know why checks/money orders and bank deposit modules would track the correct amount but why Pay Pal payments with Pay Pal IPN do not?! I'm getting pretty desperate for help on this one - the future of my families business is depending on it and SAS is offering no help at all.

Share this post


Link to post
Share on other sites

I think that these two lines would cause problems:

 

tep_session_unregister('orders_total'); 
tep_session_unregister('orders_id');

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

One problem would be is that the IPN is processed offline, e.g there is no browser in which to show an image. You should be able to still communicate this info back to the other site using a fopen or something similar in the ipn script.

But then you risking sending the information twice, unless you put a checnk int the chekout_success.php to see which payment module was used, if it was PayPal then just let the IPN script handle the feedback.

Edited by gregbaboolal

"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

Technical blondeness already admitted, could you be more specific? What kind of problems?

Share this post


Link to post
Share on other sites

Hi Guys, thanks for the response but you may as well be talking another language altogether.

Share this post


Link to post
Share on other sites

Try changing:

 

tep_session_unregister('orders_total'); 
tep_session_unregister('orders_id');

 

to:

 

// tep_session_unregister('orders_total'); 
//tep_session_unregister('orders_id');

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

One of those had a gap after // and one didn't.... was that on purpose? Also, what does it achieve?!

Share this post


Link to post
Share on other sites

Put the gap in the second one - it stops your affiliate script from unregistering the session order info during checkout by causing those two lines to be ignored by PHP

 

Matti


Matti Ressler

 

We were all once expert at...... nothing

_____

Share this post


Link to post
Share on other sites

That won't make those two lines show up on the actual page will it? I had to entirely remove the // begin affiliate and end affiliate etc part because it was showing up on the checkout_success page when someone checked out!

Share this post


Link to post
Share on other sites

Now it won't show since those comments would be inside the php tags <?php ... ?>

What version of IPN are you using?


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

Ok, I would suggest that you upgarde to v2.0 when you get the chance.

 

The code you have above is for when the customer physically returns to the site.

 

Where are you registering the session variables in catalog/checkout_process.php, this will only work when the payment method is not PayPal.

 

If your using v1.7 then in catalog/ipn.php then whatever you did in catalog/checkout_process.php you need to do in catalog/ipn.php, look in the file and you will see this same script in between, the capitalized comments, now at the end I've put in a few lines to try and get what you need done so insert that too

 

////////

//// BEGIN CHEKOUT PROCESS

/////////

 

 

$affilate_response = '';

$affilate_response=@file(https://shareasale.com/sale.cfm?amount='.$orders_total.'&tracking='.$insert_id.'&transtype=sale&persale=&perlead=&perhit=&merchantID=0001");

if ($affilate_response != '') {

$paypal_payment = true;

tep_session_register('paypal_payment');

}

////////

//// END CHEKOUT PROCESS

/////////

 

in the file line above I changed your $orders_id to the $insert id, you will still need to ensure that the $orders_total variable you are using is assigned the correct total amount as per your contribs instructions.

 

Now in catalog/checkout_success.php change it to the below and insert what you have where shown:

 

<?php

if(!tep_session_is_registered('paypal_payment')) {

 

// Now put your stuff here

 

 

} else { // else the info has already been sent

tep_session_unregister('paypal_payment');

}

?>

 

I assume you might have a way of checking the results via your affiliate account maybe?


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

I'm going blind just reading what you wrote - I'm seriiiiiously concerned about getting it wrong here.

 

Just looking at it, where does 'affilate_response' come in and should it be spelled correctly LOL (affiliate).

 

Sorry, it's all french to me, I'm still surprised I got it up and running in the first place.

Share this post


Link to post
Share on other sites

the mispelled variable which you can correct (in both places) is just used to hold the response of opening a connection to that website, if a connection is made then their headers will be returned and stored in that variable thus if the variable is not empty then you know a connection was made, give it a go and see what happens.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

I just discovered a new problem too. (Old one seems impossible to fix), I have two currencies in my store. The default is US dollars, the other is Australian dollars - the affiliate program is meant to take 10% as commission for a sale, right now it takes 10% whether it's US or Australian dollars and the 10% is in US dollars - so it's taking a LOT more than it should when an Australian buyer checks out.

 

With these pieces of tracking code, is it possible to force a change of the order total into US dollars when it reports back to the affiliate program?

 

// Begin Affiliate Program - Sales Tracking

$orders_total=$currencies->format($cart->show_total()- $total_tax);

tep_session_register('orders_total');

$orders_id=$order_products_id;

tep_session_register('orders_id');

// End Affiliate Program - Sales Tracking

 

and

// Start Affiliate Program - Sales Tracking

 

<?php

echo '<img src="https://shareasale.com/sale.cfm?amount='.$orders_total.'&tracking='.$orders_id.'&transtype=sale&persale=&perlead=&perhit=&merchantID=0001" width=1 height=1">';

tep_session_unregister('orders_total');

tep_session_unregister('orders_id');

?>

 

// End Affiliate Program - Sales Tracking

Share this post


Link to post
Share on other sites

Try:

 

$orders_total=$currencies->format($cart->show_total()- $total_tax)*$currencies->get_value('USD');

 

actually I think it should just be

$orders_total=($cart->show_total()- $total_tax)*$currencies->get_value('USD');

because I think $currencies->format is supposed to prefix the the currency symbol which I suspect is not required here, but I'm not sure right now.


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×