Jump to content
Mark Evans

Official PayPal IPN Support Thread

Recommended Posts

osCommerce PayPal IPN Module v2.3 For 2.2MS2 released. Download here.

 

This version has been tested in sandbox. It fixed many problems in the previous versions. Please report any bugs/issues/problems in this thread.

 

I made this update because there are too many people struggling to setup IPN to work but failed. Hopefully this one may work for everybody.

 

The old issues such as carts not emptied if customers don't return to store, unable to support CCGV... etc still remain.


Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

 

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

Share this post


Link to post
Share on other sites

Thanks Alex

 

Soon as I get v2.2 and CCGV stripped out, I'll give it a thrash-testing and let you know how I get on

 

Hopefully this will let me resume work on the project that it put a stop to.

 

Gaz


Wearing a seatbelt prevents head injuries when the computer crashes - - - Yeah Right!!! - not in this office.

Share this post


Link to post
Share on other sites
osCommerce PayPal IPN Module v2.3 For 2.2MS2 released. Download here.

 

This version has been tested in sandbox. It fixed many problems in the previous versions. Please report any bugs/issues/problems in this thread.

 

This update is working as far as adding the shipping to the order, thanks! I haven't run into any other issues so far.

Share this post


Link to post
Share on other sites

I added some extra customer fields (using this contrib), and I was wondering what kind of changes I needed to make to the IPN contrib in order to have the extra fields emailed along with the order like normal CC or other payment method orders?

 

tia

Share this post


Link to post
Share on other sites
Since v2.x the invoice email has been moved to ipn.php under the ext directory. You should find the email building block in ipn.php similar to checkout_process.php where the contribution you mentioned places its code at. The variable (int)$customer_id won't work in ipn.php because the customer's session doesn't exist, you should use (int)$_POST['custom'] instead.

Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

 

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

Share this post


Link to post
Share on other sites

AlexStudio:

Thanks for becoming involved with this contribution. I am very pleased to see that as everything you contribute is absolutely top notch and of the highest quality, in addition your responses to inquires have always been world class.

 

Again, thank you. This is the best thing that could happen to Official PayPal IPN Support Thread.

Share this post


Link to post
Share on other sites

I'm running PayPal Shopping Cart IPN v3.1.5 on a number of OSC 2.2 installs... a few of them are having a problem: when quantities reach zero, the products are still active on the site and able to be purchased. they're marked as "OUT OF STOCK" via the "stock" configurations, but how come they don't automatically switch to inactive since installing this module?

 

any help would be appreciated. thanks!

Share this post


Link to post
Share on other sites

Minor Update - osCommerce PayPal IPN Module v2.3 For 2.2MS2

 

2 more modifications update to v2.3

 

1. If your store is selling downloads, the customer's billing address should be sent to PayPal instead of the delivery address.

Find in catalog/includes/modules/payment/paypal_ipn.php line 412:

	  $state_abbr = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']);

Replace with:

	  // BOF billing address fix by AlexStudio
  if ($order->content_type != 'virtual') {
	$state_abbr = tep_get_zone_code($order->delivery['country']['id'], $order->delivery['zone_id'], $order->delivery['state']);
  } else {
	$state_abbr = tep_get_zone_code($order->billing['country']['id'], $order->billing['zone_id'], $order->billing['state']);
  }
  // EOF billing address fix by AlexStudio

 

2. 'Per Item' mode didn't work if Encrypted Web Payments is enabled. This is not a bug fix. I believe it was designed this way in the early versions to avoid potential problems using EWP. I have been using 'Per Item' mode with EWP enabled for years without a problem. If you want to give it a try, find in catalog/includes/modules/payment/paypal_ipn.php line 295:

	  if ( (MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE == 'Per Item') && (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'False') ) {

Replace with:

	  if ( (MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE == 'Per Item')/* && (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'False') // removed by AlexStudio*/) {

That's it.


Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

 

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

Share this post


Link to post
Share on other sites

Notice about PayPal IPN and osCommerce 2.2RC1

 

The PayPal IPN module came with the osCommerce 2.2RC1 is an re-written version of v1.1 which doesn't have most of the later fixes and improvements made by the community members. It contains a referral code of the author which is to collect bonus from PayPal Merchant Referral Bonus Program.

 

I didn't have a chance to test v2.3 on RC1. Please try it and report problems here, I'll see what I can do.


Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

 

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

Share this post


Link to post
Share on other sites
Since v2.x the invoice email has been moved to ipn.php under the ext directory. You should find the email building block in ipn.php similar to checkout_process.php where the contribution you mentioned places its code at. The variable (int)$customer_id won't work in ipn.php because the customer's session doesn't exist, you should use (int)$_POST['custom'] instead.

 

 

Does this look correct to you? ..I have not received the email yet and am not sure I put it in the correct place:

 

		  $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" .
					  EMAIL_SEPARATOR . "\n" .
					  tep_address_format($order->billing['format_id'], $order->billing, 0, '', "\n") . "\n\n";
	  if (is_object($$payment)) {
// START extra fields in email
 $it=0;
$semextrfields = tep_db_query("select * from " . TABLE_EXTRA_FIELDS . " where fields_required_email = '1'");
while($dataexfes = tep_db_fetch_array($semextrfields)) {
$cusextrfields = tep_db_query("select * from " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " where customers_id = '" . (int)$_POST['custom'] . "' and fields_id = '" . $dataexfes['fields_id'] . "'");
$rescusextrfields = tep_db_fetch_array($cusextrfields);
 if ($it < 1) {
$email_order .= "\n" . CATEGORY_EXTRA_FIELDS . "\n" . EMAIL_SEPARATOR . "\n";
$it++;
 }

$extrfieldsinf = tep_db_query("select fields_name from " . TABLE_EXTRA_FIELDS_INFO . " where fields_id = '" . $dataexfes[fields_id] . "' and languages_id = '" . $languages_id . "'");

$extrfieldsres = tep_db_fetch_array($extrfieldsinf);
$email_order .= $extrfieldsres['fields_name'] . ' : ' .
$rescusextrfields['value'] . "\n";
 }
 $email_order .= "\n";
 // END extra fields in email
		$email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . 
						EMAIL_SEPARATOR . "\n";

Share this post


Link to post
Share on other sites

Multi-language Addon - osCommerce PayPal IPN Module v2.3 For 2.2MS2

 

I forgot to include the post v2.2 multi-language support fix by Terra.

 

In order to pass through customer selected language to ipn.php for invoice email to use the correct language file:

Find in catalog/includes/modules/payment/paypal_ipn.php:

	  $parameters['notify_url'] = tep_href_link('ext/modules/payment/paypal_ipn/ipn.php', '', 'SSL', false, false);

Replace with:

	  $parameters['notify_url'] = tep_href_link('ext/modules/payment/paypal_ipn/ipn.php', 'language=' . $_SESSION['language'], 'SSL', false, false);


Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

 

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

Share this post


Link to post
Share on other sites
You can set it to "per item" but this can cause issues - if you want to use per item, give it a go & test thoroughly. The main problems are around tax (especially shipping tax) and CCGV - as long as your shop is simple (no tax, no CCGV) the per item should work. All the best - Terra

 

Hi Terra,

 

Regarding the store name being passed to Paypal instead of products,

 

Is it possible to replace the store name by a text: i.e. "Items bought from STORE_NAME"

 

Flo

Edited by cleverflo

Share this post


Link to post
Share on other sites

Hi,

 

I finally have Paypal IPN working properly, I'd like to know if it is possible to customise the checkout pages. For example., I'd like to get rid of the comments box. If I comment out the code, will it mess up my Paypal IPN?

 

Sorry, I'm scared to try, I'd rather know before hand as it's been a nightmare sorting my PIN problems out in the first place.

 

Thanks.

 

Flo

Share this post


Link to post
Share on other sites
Hi,

 

I finally have Paypal IPN working properly, I'd like to know if it is possible to customise the checkout pages. For example., I'd like to get rid of the comments box. If I comment out the code, will it mess up my Paypal IPN?

 

Sorry, I'm scared to try, I'd rather know before hand as it's been a nightmare sorting my PIN problems out in the first place.

 

Thanks.

 

Flo

 

don't you have a local copy of your store running on your pc? ...no harm in trying and restoring the files if it causes a mess up....no one should be experimenting with a live store unless they are asking for trouble :blink:

Share this post


Link to post
Share on other sites
don't you have a local copy of your store running on your pc? ...no harm in trying and restoring the files if it causes a mess up....no one should be experimenting with a live store unless they are asking for trouble :blink:

 

Hi,

 

No sorry I don't have a copy on my local PC, to be honest at first I wouldn't have known how to do to view it as webpages! I'm using cPanel and think it's quite straight forward.

 

I probably would be able to do it now (I have slightly more knowledge now) but I am happy using cPanel, and to be on the safe side...

 

Anyway I have password-protected my folder so nobody but me can see my site.

 

And now I back up every five minutes and create new folder as I go along, as long as I don't use all my web space!

Share this post


Link to post
Share on other sites
Hi,

 

No sorry I don't have a copy on my local PC, to be honest at first I wouldn't have known how to do to view it as webpages! I'm using cPanel and think it's quite straight forward.

 

I probably would be able to do it now (I have slightly more knowledge now) but I am happy using cPanel, and to be on the safe side...

 

Anyway I have password-protected my folder so nobody but me can see my site.

 

And now I back up every five minutes and create new folder as I go along, as long as I don't use all my web space!

 

All you need is to install Apache, Mysql, PHP, and phpadmin on your windows box, and you can use the same files (except for the two config.php files) to run OSC on your local PC.

 

I suggest you start with a pre-compiled combo package that installs all of these at one time...all of these should work, I'd try to get one that matches the version of PHP and MYSQL you have on your server, but it's not necessary:

 

http://sourceforge.net/project/showfiles.php?group_id=39203

http://www.devside.net/

http://sourceforge.net/project/showfiles.php?group_id=88654

 

I use phpdev but there are tons out there that will work or you can install them all individually. After you get that up and running, you just move a copy of your OSC site (keep the file structure) to the /www folder of your local php/mysql/apache install and edit the config.php to reflect local addresses instead of .coms. Then you can play away, and when you get it working just right, upload the modified files and they'll behave just like they did locally (99% of time heh).

Share this post


Link to post
Share on other sites
All you need is to install Apache, Mysql, PHP, and phpadmin on your windows box, and you can use the same files (except for the two config.php files) to run OSC on your local PC.

 

I suggest you start with a pre-compiled combo package that installs all of these at one time...all of these should work, I'd try to get one that matches the version of PHP and MYSQL you have on your server, but it's not necessary:

 

http://sourceforge.net/project/showfiles.php?group_id=39203

http://www.devside.net/

http://sourceforge.net/project/showfiles.php?group_id=88654

 

I use phpdev but there are tons out there that will work or you can install them all individually. After you get that up and running, you just move a copy of your OSC site (keep the file structure) to the /www folder of your local php/mysql/apache install and edit the config.php to reflect local addresses instead of .coms. Then you can play away, and when you get it working just right, upload the modified files and they'll behave just like they did locally (99% of time heh).

 

 

Hi Magicquote,

 

Thank you very much for your instructions. I am very pleased and grateful.

 

Now I know I would have never been able to run the copy on my PC if I had tried!

 

If I manage to do it, that will be very helpful when I want to update my site. I will be able to leave the actual site live and do the amendments on the PC copy!

 

Great.

Share this post


Link to post
Share on other sites
Notice about PayPal IPN and osCommerce 2.2RC1

 

The PayPal IPN module came with the osCommerce 2.2RC1 is an re-written version of v1.1 which doesn't have most of the later fixes and improvements made by the community members. It contains a referral code of the author which is to collect bonus from PayPal Merchant Referral Bonus Program.

 

I didn't have a chance to test v2.3 on RC1. Please try it and report problems here, I'll see what I can do.

 

Dear Mr. Alex,

 

Thanks for the update.

 

We are using "Order IP Recorder v1.0" for recording IP addresses for each of the orders.

 

IP details do not get recorded for checkouts done through this Paypal IPN module, even after adding the required codes to the ipn files.

 

We have added the codes as follows:

-----------------------------------------------------------

In /ext/modules/payment/paypal/ipn.php just after

 

require('includes/application_top.php');

 

* added

 

$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];

$client = gethostbyaddr($HTTP_SERVER_VARS["REMOTE_ADDR"]);

$str = preg_split("/\./", $client);

$i = count($str);

$x = $i - 1;

$n = $i - 2;

$isp = $str[$n] . "." . $str[$x];

 

In /includes/modules/payment/payment/paypal_ipn.php

 

* changed:

 

'email_address' => $order['customers_email_address']);

 

* to:

 

'email_address' => $order['customers_email_address'],

'ipaddy' => $order['ipaddy'],

'ipisp' => $order['ipisp']);

-----------------------------------------------------------

 

Kindly help us as to what we should do in this regard [to get the IP details recorded].

 

Thanks,

 

Lakshmanan S.

Share this post


Link to post
Share on other sites
Remove the code you added to ipn.php, and then in catalog/includes/modules/payment/paypal_ipn.php find:
	function confirmation() {
  global $cartID, $cart_PayPal_IPN_ID, $customer_id, $languages_id, $order, $order_total_modules;

Add after:

		  $ip = tep_get_ip_address();
	  $client = @gethostbyaddr($ip);
	  $isp = explode('.', $client);
	  $isp = array_reverse($isp);
	  $tmp = $isp[1];
	  if (preg_match("/\<(org?|com?|net|co|me|idv|edu|gov|ac|sch|or|pe|nc|ltd|plc|il|kids)\>/i", $tmp)) {
		$myisp = $isp[2].'.'.$isp[1].'.'.$isp[0];
	  } else {
		$myisp = $isp[1].'.'.$isp[0];
	  }
	  if (preg_match("/[0-9]{1,3}\.[0-9]{1,3}/", $myisp)) $myisp = 'NA';

and then find:

		  $sql_data_array = array('customers_id' => $customer_id,
							  'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'],
							  'customers_company' => $order->customer['company'],
							  'customers_street_address' => $order->customer['street_address'],
							  'customers_suburb' => $order->customer['suburb'],
							  'customers_city' => $order->customer['city'],
							  'customers_postcode' => $order->customer['postcode'],
							  'customers_state' => $order->customer['state'],
							  :
							  : (some of the code skipped)
							  :
							  'date_purchased' => 'now()',
							  'orders_status' => $order->info['order_status'],
							  'currency' => $order->info['currency'],
							  'currency_value' => $order->info['currency_value']);

and add the IP/ISP record at the end of the sql data array, so it should look like this:

								  'orders_status' => $order->info['order_status'],
							  'currency' => $order->info['currency'],
							  'currency_value' => $order->info['currency_value'],
							  'ipaddy' => $ip,
							  'ipisp' => $myisp);


Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

 

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

Share this post


Link to post
Share on other sites
PayPal is not able to reach your ipn.php script if you password protected the directory. Make sure you can open http://yourdomain/catalog/ext/modules/payment/paypal_ipn/ipn.php in internet browser first.

Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

 

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

Share this post


Link to post
Share on other sites
PayPal is not able to reach your ipn.php script if you password protected the directory. Make sure you can open http://yourdomain/catalog/ext/modules/payment/paypal_ipn/ipn.php in internet browser first.

 

Hi Alex,

 

I have removed the password for my directory. My catalog is in https://. When I access my https:/yourdomain/ext/modules/payment/paypal_ipn/ipn.php

 

I receive an email from Paypal subject Paypal IPN Invalid Process. The email only shows:

 

 

$_POST:

 

$_GET:

 

 

I have checked in my Paypal IPN for no_shipping = "2" and it is 2 for the 1st parameter and for the 2nd parameter (or else) it's no_shipping = "1"

 

 

What is wrong?

Share this post


Link to post
Share on other sites
Did you try checking out after removing password protection?

 

When there is shipping in the order, the code sets no_shipping = "2" which means to force shipping to the address set by the customer at store and overriding addresses set in his PayPal account. Editing shipping address at PayPal is not allowed with this parameter sent.

 

When there is no shipping in the order (intangible items), the code sets no_shipping = "1" since it doesn't have any shipping address to send with.

 

The no_shipping parameter has nothing to do with IPN calls.

Edited by AlexStudio

Super Download Shop, PayPal Express Checkout IPN, Selling Downloads, Visual Validation (preventing robotic flood), phpBB2 Integration

 

Yes, I'm willing to help, but please ask in the right place. Think twice before trying to PM me, it might be ignored.

Share this post


Link to post
Share on other sites
Did you try checking out after removing password protection?

 

When there is shipping in the order, the code sets no_shipping = "2" which means to force shipping to the address set by the customer at store and overriding addresses set in his PayPal account. Editing shipping address at PayPal is not allowed with this parameter sent.

 

When there is no shipping in the order (intangible items), the code sets no_shipping = "1" since it doesn't have any shipping address to send with.

 

The no_shipping parameter has nothing to do with IPN calls.

 

Hi Alex,

 

Yes I tried after removing the password and it was still the same. I thought it didn't make sense to check the shipping but people's other threads mentioning the "invalid process" advised to change the no_shipping!!!

 

 

As you were insisting on the password issue on your last message, I have just emailed my webhosting company for them to check my htaccess file.

 

Before I reinstalled OSC I was able to go to my SSL catalog without redirection, but just by configuring my configure.php. files.

 

After reinstalling OSC I couldn't anymore somehow so my webhosting company set up a redirection of mydomain.com to https://mydomain.com/index.php

 

I don't know if this is relevant, will see.

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

×