Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Official PayPal IPN Support Thread


Mark Evans

Recommended Posts

Dear Morton,

 

I have exactly the same problem since mid of April, I wonder whether Paypal or my host Strato changed something. except for adding new articles I have not change anything else.

I have tried the IPN simulator in the sandbox toolbox but that seems not to reach me IPN.php, the simulator say html error 503 although if I enter the full address in the browser I do get an empty page.

One strange issue I found is that once I change the CMOD of the EXT path into 755 and a minute later I check the CMOD of this again it shows 600 instead.

 

Anyone facing the same issue? Please post your solution.

 

John

Hi John,

 

I have exactly the same problem since mid April. My host is Strato too!

I wish to have the solution too...

 

Regards,

 

Michal

Link to comment
Share on other sites

After a lot of false starts, I finally got the newest version of PayPal_IPN (v2.3.4.7) to work...

 

EXCEPT when Paypal returns to site after making payment (stock reduced ok, emails ok) the cart contents are not emptied.

 

Now, I see in the docs that if paypal doesnt return you to the site, they are not updated, but it IS being returned...

 

Any ideas on how to fix?

Link to comment
Share on other sites

Dear Morton,

 

I have exactly the same problem since mid of April, I wonder whether Paypal or my host Strato changed something. except for adding new articles I have not change anything else.

I have tried the IPN simulator in the sandbox toolbox but that seems not to reach me IPN.php, the simulator say html error 503 although if I enter the full address in the browser I do get an empty page.

One strange issue I found is that once I change the CMOD of the EXT path into 755 and a minute later I check the CMOD of this again it shows 600 instead.

 

Anyone facing the same issue? Please post your solution.

 

John

 

Same with me...I still haven't managed to get this contrib to work. With the first installation, the error emails that appeared had much more content, but for 2 weeks now the content is reduced to yours. I am also hostet on Strato.

 

It is a pity that nobody has an idea what could be wrong.

 

Alex

Link to comment
Share on other sites

Paypal Transaction ID recorded in database,

 

Has anyone got a solution on how to do this:

 

I want to record the Paypal Unique Transaction ID : 17 characters as example 23Q183171B041133K

 

Regards

 

Paul

Link to comment
Share on other sites

Is there a guide to explain to my buddy which information is needed to setup this module?

 

I need to setup this module for a buddies store. I do not have a PayPal Premier or Business account, so i can't log in and see the click path to tell him how to get the PayPal certificates and other things he may need.

 

Is there a more descriptive guide of this available that I can give to him so he can get all of the necessary info from PayPal prior to use installing this?

 

 

thanks,

Rich

Link to comment
Share on other sites

I am going through the troubleshooting section and the ext/modules/payment/paypal_ipn/ipn.php page is showing a 500 internal server error. The ext folder is CHMOD 755 (which is standard for my server) the actualy page CHMOD is 644.

 

Using latest paypal addon (2.3.4.7) I am using a United Hosting standard account that uses PHP5 and I am just finding out id Register Globals is on or off.

 

I have recently made the last 2 changes on the folder (as we use the price sensitive discount) but still stock is not deducting. Please help. If I cannot sort this then I am going to have to uninstall this add-on and try something else (which would be a shame).

Edited by dvharrison

Debbie Harrison

 

Link to comment
Share on other sites

Debbie under admin / configuration /stock ( i think) there is a setting that you can set to deduct stock after a sale i suppose yours is set to true?

The server error could be related to your htaccess (just to make your night really good!!)

Nic

Sometimes you're the dog and sometimes the lamp post

[/url]

My Contributions

Link to comment
Share on other sites

Hi Nic

 

My .htaccess reads as follows:

 

# $Id: .htaccess 1739 2007-12-20 00:52:16Z hpdl $
#
# This is used with Apache WebServers
#
# For this to work, you must include the parameter 'Options' to
# the AllowOverride configuration
#
# Example:
#
# <Directory "/usr/local/apache/htdocs">
#   AllowOverride Options
# </Directory>
#
# 'All' with also work. (This configuration is in the
# apache/conf/httpd.conf file)

# The following makes adjustments to the SSL protocol for Internet
# Explorer browsers

#<IfModule mod_setenvif.c>
#  <IfDefine SSL>
#	SetEnvIf User-Agent ".*MSIE.*" \
#			 nokeepalive ssl-unclean-shutdown \
#			 downgrade-1.0 force-response-1.0
#  </IfDefine>
#</IfModule>

# If Search Engine Friendly URLs do not work, try enabling the
# following Apache configuration parameter

# AcceptPathInfo On

# Fix certain PHP values
# (commented out by default to prevent errors occuring on certain
# servers)

# php_value session.use_trans_sid 0
# php_value register_globals 1


# anti xss script 1 - pci compliance - by pixclinic
Options +FollowSymLinks
RewriteEngine On 
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index_error.php [F,L]
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

# extra anti uri and xss attack script 2 - sql injection prevention
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ("|%22).*(>|%3E|<|%3C).* [NC]
RewriteRule ^(.*)$ log.php [NC]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC]
RewriteRule ^(.*)$ log.php [NC]
RewriteCond %{QUERY_STRING} (java script:).*(;).* [NC]
RewriteRule ^(.*)$ log.php [NC]
RewriteCond %{QUERY_STRING} (;|'|"|%22).*(union|select|insert|drop|update|md5|benchmark|or|and|if).* [NC]
RewriteRule ^(.*)$ log.php [NC]
RewriteRule (,|;|<|>|'|`) /log.php [NC]

 

I have no idea if that sheds any light on what the problem could be.

Debbie Harrison

 

Link to comment
Share on other sites

Hi Nic

 

My .htaccess reads as follows:

 

# $Id: .htaccess 1739 2007-12-20 00:52:16Z hpdl $
#
# This is used with Apache WebServers
#
# For this to work, you must include the parameter 'Options' to
# the AllowOverride configuration
#
# Example:
#
# <Directory "/usr/local/apache/htdocs">
#   AllowOverride Options
# </Directory>
#
# 'All' with also work. (This configuration is in the
# apache/conf/httpd.conf file)

# The following makes adjustments to the SSL protocol for Internet
# Explorer browsers

#<IfModule mod_setenvif.c>
#  <IfDefine SSL>
#	SetEnvIf User-Agent ".*MSIE.*" \
#			 nokeepalive ssl-unclean-shutdown \
#			 downgrade-1.0 force-response-1.0
#  </IfDefine>
#</IfModule>

# If Search Engine Friendly URLs do not work, try enabling the
# following Apache configuration parameter

# AcceptPathInfo On

# Fix certain PHP values
# (commented out by default to prevent errors occuring on certain
# servers)

# php_value session.use_trans_sid 0
# php_value register_globals 1


# anti xss script 1 - pci compliance - by pixclinic
Options +FollowSymLinks
RewriteEngine On 
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index_error.php [F,L]
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

# extra anti uri and xss attack script 2 - sql injection prevention
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ("|%22).*(>|%3E|<|%3C).* [NC]
RewriteRule ^(.*)$ log.php [NC]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC]
RewriteRule ^(.*)$ log.php [NC]
RewriteCond %{QUERY_STRING} (java script:).*(;).* [NC]
RewriteRule ^(.*)$ log.php [NC]
RewriteCond %{QUERY_STRING} (;|'|"|%22).*(union|select|insert|drop|update|md5|benchmark|or|and|if).* [NC]
RewriteRule ^(.*)$ log.php [NC]
RewriteRule (,|;|<|>|'|`) /log.php [NC]

 

I have no idea if that sheds any light on what the problem could be.

 

Server errors are usually due to permission problems,

 

additional do you have

 

index_error.php

and

log.php

on your directories?

as stated in your PCI parts above.

 

Also check your server error logs, these will give you an unsight into any problems.

 

Nic

Sometimes you're the dog and sometimes the lamp post

[/url]

My Contributions

Link to comment
Share on other sites

Hi!

Thanks for this great plugin.

I have the following issue:

I would like to set the language of the paypal page to english.

I m having a german paypal account, and buyers don t understand when they have to pay on the paypal page.

 

Could you send me the instructions lines to modify the code for the IPN 1.3?

I found only ressources to change the standard paypal IPN, and can t adapt myself to the IPN 1.3

Thanks in advance

Edited by elektrotribe
Link to comment
Share on other sites

On some orders I get continued notifications from the Paypal IPN module confirming the order. The problem is every time this happens it deducts from my stock.

 

 

Below is what an order would look like.

05/31/2008 16:15:00 Processing PayPal IPN Verified [Completed (Unverified; $40.98)]

05/31/2008 16:16:00 Processing PayPal IPN Verified [Completed (Unverified; $40.98)]

05/31/2008 16:17:00 Processing PayPal IPN Verified [Completed (Unverified; $40.98)]

 

 

 

Anyone experience this?

Link to comment
Share on other sites

Server errors are usually due to permission problems,

 

additional do you have

 

index_error.php

and

log.php

on your directories?

as stated in your PCI parts above.

 

Also check your server error logs, these will give you an unsight into any problems.

 

Nic

 

hi Nic

 

I removed the add-on accumulating that code and I am still getting a 500 error.

 

I think I may have to remove the IPN plug-in and look for another method, because this is unsettling.

Debbie Harrison

 

Link to comment
Share on other sites

I have been studing this and other topics for the last couple of days and can see my question posted a few times but not answered completly

 

I have also posted a simular question elsewhere, http://www.oscommerce.com/forums/index.php?showtopic=296916, and do not mean to cross post but this other thread has not been added to for over a year and is probably not being monitored.

 

I have managed to instal Multi stores the IPN is working fine on store 1 but on the others the orders are going to store 1 instead of store 2 or store 3

 

Now from what i have read i believe i need to send paypal the storeid in with the information so when it comes back my store knows for what store it is, now there in the IPN.php there is a little bit saying "Custom" wasnt sure if that was this was for.

 

I have the ext folder in all the stores and assume that the change will be made to the IPN.PHP as mentioned, and that this change will be different for all the stores, I have included the code below for my version

 

<?php
/*
 $Id: paypal_ipn.php,v 2.3.0.0 10/09/2007 11:58:21 alexstudio Exp $

 Copyright (c) 2004 osCommerce
 Released under the GNU General Public License

 Original Authors: Harald Ponce de Leon, Mark Evans 
 Updates by PandA.nl, Navyhost, Zoeticlight, David, gravyface, AlexStudio, windfjf, Monika in Germany and Terra
 v2.3 updated by AlexStudio

*/

 chdir('../../../../');
 require('includes/application_top.php');
 include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);
 // BOF configuration keys fix by AlexStudio
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment(paypal_ipn);
 // EOF configuration keys fix by AlexStudio

 $parameters = 'cmd=_notify-validate';

 foreach ($_POST as $key => $value) {
$parameters .= '&' . $key . '=' . urlencode(stripslashes($value));
 }

 if (MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER == 'Live') {
$server = 'www.paypal.com';
 } else {
$server = 'www.sandbox.paypal.com';
 }

 $fsocket = false;
 $curl = false;
 $result = false;

 if ( (PHP_VERSION >= 4.3) && ($fp = @fsockopen('ssl://' . $server, 443, $errno, $errstr, 30)) ) {
$fsocket = true;
 } elseif (function_exists('curl_exec')) {
$curl = true;
 } elseif ($fp = @fsockopen($server, 80, $errno, $errstr, 30)) {
$fsocket = true;
 }

 if ($fsocket == true) {
$header = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n" .
		  'Host: ' . $server . "\r\n" .
		  'Content-Type: application/x-www-form-urlencoded' . "\r\n" .
		  'Content-Length: ' . strlen($parameters) . "\r\n" .
		  'Connection: close' . "\r\n\r\n";

@fputs($fp, $header . $parameters);

$string = '';
while (!@feof($fp)) {
  $res = @fgets($fp, 1024);
  $string .= $res;

  if ( ($res == 'VERIFIED') || ($res == 'INVALID') ) {
	$result = $res;
	break;
  }
}

@fclose($fp);
 } elseif ($curl == true) {
$ch = curl_init();

// BOF add by AlexStudio
// For the poor souls on GoDaddy and the like, set the connection to go through their proxy
if (trim(MODULE_PAYMENT_PAYPAL_IPN_PROXY_SERVER) != '') {
  curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
  curl_setopt($ch, CURLOPT_PROXY, MODULE_PAYMENT_PAYPAL_IPN_PROXY_SERVER);
}
// Eof add by AlexStudio
curl_setopt($ch, CURLOPT_URL, 'https://' . $server . '/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec($ch);

curl_close($ch);
 }

 if ($result == 'VERIFIED') {
if (isset($_POST['invoice']) && is_numeric($_POST['invoice']) && ($_POST['invoice'] > 0)) {
  $order_query = tep_db_query("select currency, currency_value from " . TABLE_ORDERS . " where orders_id = '" . $_POST['invoice'] . "' and customers_id = '" . (int)$_POST['custom'] . "'");
  if (tep_db_num_rows($order_query) > 0) {
	$order_db = tep_db_fetch_array($order_query);

	// let's re-create the required arrays
	require(DIR_WS_CLASSES . 'order.php');
	$order = new order($_POST['invoice']);

	// let's update the order status
	$total_query = tep_db_query("select value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $_POST['invoice'] . "' and class = 'ot_total' limit 1");
	$total = tep_db_fetch_array($total_query);

	$comment_status = 'payment status: ' . $_POST['payment_status'] . ' (' . ucfirst($_POST['payer_status']) . '; ' . $currencies->format($_POST['mc_gross'], false, $_POST['mc_currency']) . ')';

	if ($_POST['payment_status'] == 'Pending') {
	  $comment_status .= '; ' . $_POST['pending_reason'];
	} elseif ( ($_POST['payment_status'] == 'Reversed') || ($_POST['payment_status'] == 'Refunded') ) {
	  $comment_status .= '; ' . $_POST['reason_code'];
	} elseif ( ($_POST['payment_status'] == 'Completed') && (tep_not_null($_POST['address_street'])) ) {
	  $comment_status .= ", \n" . PAYPAL_ADDRESS . ": " . $_POST['address_name'] . ", " . $_POST['address_street'] . ", " . $_POST['address_city'] . ", " . $_POST['address_zip'] . ", " . $_POST['address_state'] . ", " . $_POST['address_country'] . ", " . $_POST['address_country_code'] . ", " . $_POST['address_status'];
	} 

	$order_status_id = DEFAULT_ORDERS_STATUS_ID;

// modified AlexStudio's Rounding error bug fix 
// variances of up to 0.05 on either side (plus / minus) are ignored
	if ((((number_format($total['value'] * $order_db['currency_value'], $currencies->get_decimal_places($order_db['currency']))) -  $_POST['mc_gross']) <= 0.05)  
	  &&
	  (((number_format($total['value'] * $order_db['currency_value'], $currencies->get_decimal_places($order_db['currency']))) -  $_POST['mc_gross']) >= -0.05)) {

// Terra -> modified update. If payment status is "completed" than a completed order status is chosen based on the admin settings 
	  if ( (MODULE_PAYMENT_PAYPAL_IPN_COMP_ORDER_STATUS_ID > 0) && ($_POST['payment_status'] == 'Completed') ) {
		$order_status_id = MODULE_PAYMENT_PAYPAL_IPN_COMP_ORDER_STATUS_ID;
	  } elseif (MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID > 0) {
		$order_status_id = MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID;
	  }
	}

	// Let's see what the PayPal payment status is and set the notification accordingly
	// more info: https://www.paypal.com/IntegrationCenter/ic_ipn-pdt-variable-reference.html
	if ( ($_POST['payment_status'] == 'Pending') || ($_POST['payment_status'] == 'Completed')) {
	  $customer_notified = '1'; 
	} else {
	  $customer_notified = '0'; 
	}

	tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . $order_status_id . "', last_modified = now() where orders_id = '" . $_POST['invoice'] . "'");

	$sql_data_array = array('orders_id' => $_POST['invoice'],
							'orders_status_id' => $order_status_id,
							'date_added' => 'now()',
							'customer_notified' => $customer_notified,
							'comments' => 'PayPal IPN Verified [' . $comment_status . ']');

	tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

// If the order is completed, then we want to send the order email and update the stock
	if ($_POST['payment_status'] == 'Completed') { // START STATUS == COMPLETED LOOP

// initialized for the email confirmation
	  $products_ordered = '';
	  $total_tax = 0;

// let's update the stock  
#######################################################
	  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { // PRODUCT LOOP STARTS HERE
// Stock Update - Joao Correia
		if (STOCK_LIMITED == 'true') {
		  if (DOWNLOAD_ENABLED == 'true') {
			$stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename 
								FROM " . TABLE_PRODUCTS . " p
								LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
								ON p.products_id=pa.products_id
								LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
								ON pa.products_attributes_id=pad.products_attributes_id
								WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
			$products_attributes = $order->products[$i]['attributes'];
			if (is_array($products_attributes)) {
			  $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
			}
			$stock_query = tep_db_query($stock_query_raw);
		  } else {
			$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
		  }
		  if (tep_db_num_rows($stock_query) > 0) {
			$stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
			if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
			  $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
			} else {
			  $stock_left = $stock_values['products_quantity'];
			}
			tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
			if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
			  tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
			}
		  }
		}

// Update products_ordered (for bestsellers list)
		tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

// Let's get all the info together for the email
		$total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
		$total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
		$total_cost += $total_products_price;

// Let's get the attributes
		$products_ordered_attributes = '';
		if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
		  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
			$products_ordered_attributes .= "\n\t" . $order->products[$i]['attributes'][$j]['option'] . ' ' . $order->products[$i]['attributes'][$j]['value'];
		  }
		} 

// Let's format the products model	   
		$products_model = '';	  
		if ( !empty($order->products[$i]['model']) ) {
		  $products_model = ' (' . $order->products[$i]['model'] . ')';
		} 

// Let's put all the product info together into a string
		$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . $products_model . ' = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
	  }		// PRODUCT LOOP ENDS HERE
#######################################################

// lets start with the email confirmation
// BOF content type fix by AlexStudio
		$content_type = '';
		$content_count = 0;
		// BOF order comment fix
		$comment_query = tep_db_query("select comments from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . $_POST['invoice'] . "'");
		$comment_array = tep_db_fetch_array($comment_query);
		$comments = $comment_array['comments'];
		// EOF order comment fix

		if (DOWNLOAD_ENABLED == 'true') {
		  $content_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " where orders_id = '" . (int)$_POST['invoice'] . "'");
		  $content_count = tep_db_num_rows($content_query);
		  if ($content_count > 0) {
			$content_type = 'virtual';
		  }
		}
		switch ($content_type) {
		  case 'virtual':
			if ($content_count != sizeof($order->products)) $content_type = 'mixed'; 
			break;
		  default:
			$content_type = 'physical';
			break;
		}
// EOF content type fix by AlexStudio
// $order variables have been changed from checkout_process to work with the variables from the function query () instead of cart () in the order class
	  $email_order = STORE_NAME . "\n" . 
					 EMAIL_SEPARATOR . "\n" . 
					 EMAIL_TEXT_ORDER_NUMBER . ' ' . $_POST['invoice'] . "\n" .
					 EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $_POST['invoice'], 'SSL', false) . "\n" .
					 EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";

	  // BOF order comment fix by AlexStudio
	  if ($comments) {
		$email_order .= $comments . "\n\n";
	  }
	  // EOF order comment fix by AlexStudio

	  $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . 
					  EMAIL_SEPARATOR . "\n" . 
					  $products_ordered . 
					  EMAIL_SEPARATOR . "\n";

	  for ($i=0, $n=sizeof($order->totals); $i<$n; $i++) {
		$email_order .= strip_tags($order->totals[$i]['title']) . ' ' . strip_tags($order->totals[$i]['text']) . "\n";
	  }

	  // BOF content type fix by AlexStudio
	  if ($content_type != 'virtual') {
	  // EOF content type fix by AlexStudio
		$email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . 
						EMAIL_SEPARATOR . "\n" .
						tep_address_format($order->delivery['format_id'], $order->delivery,  0, '', "\n") . "\n";
	  }

	  $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)) {
		$email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . 
						EMAIL_SEPARATOR . "\n";
		$payment_class = $$payment;
		$email_order .= $payment_class->title . "\n\n";
		if ($payment_class->email_footer) { 
		  $email_order .= $payment_class->email_footer . "\n\n";
		}
	  }
	  tep_mail($order->customer['name'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, nl2br($email_order), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

// send emails to other people
	  if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
		tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, nl2br($email_order), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
	  }
	} // END STATUS == COMPLETED LOOP

	if ($_POST['payment_status'] == 'Pending') { // START STATUS == PENDING LOOP

	  $email_order = STORE_NAME . "\n" . 
					 EMAIL_SEPARATOR . "\n" . 
					 EMAIL_TEXT_ORDER_NUMBER . ' ' . $_POST['invoice'] . "\n" .
					 EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $_POST['invoice'], 'SSL', false) . "\n" .
					 EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n" . 
					 EMAIL_SEPARATOR . "\n" .
					 EMAIL_PAYPAL_PENDING_NOTICE . "\n\n"; 

	  tep_mail($order->customer['name'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

// send emails to other people
	  if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
		tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
	  } 
	} // END STATUS == PENDING LOOP
//emptying cart for everyone! by Monika in Germany
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$_POST['custom'] . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$_POST['custom'] . "'");
//end emptying cart for everyone
  }
}
 } else {
if (tep_not_null(MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL)) {
  $email_body = '$_POST:' . "\n\n";
  foreach ($_POST as $key => $value) {
	$email_body .= $key . '=' . $value . "\n";
  }
  $email_body .= "\n" . '$_GET:' . "\n\n";
  foreach ($_GET as $key => $value) {
	$email_body .= $key . '=' . $value . "\n";
  }
  tep_mail('', MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL, 'PayPal IPN Invalid Process', $email_body, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
}

if (isset($_POST['invoice']) && is_numeric($_POST['invoice']) && ($_POST['invoice'] > 0)) {
  $check_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . $_POST['invoice'] . "' and customers_id = '" . (int)$_POST['custom'] . "'");
  if (tep_db_num_rows($check_query) > 0) {
	$comment_status = $_POST['payment_status'];

	if ($_POST['payment_status'] == 'Pending') {
	  $comment_status .= '; ' . $_POST['pending_reason'];
	} elseif ( ($_POST['payment_status'] == 'Reversed') || ($_POST['payment_status'] == 'Refunded') ) {
	  $comment_status .= '; ' . $_POST['reason_code'];
	}

	tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . ((MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID > 0) ? MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID : DEFAULT_ORDERS_STATUS_ID) . "', last_modified = now() where orders_id = '" . $_POST['invoice'] . "'");

	$sql_data_array = array('orders_id' => $_POST['invoice'],
							'orders_status_id' => (MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID > 0) ? MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID : DEFAULT_ORDERS_STATUS_ID,
							'date_added' => 'now()',
							'customer_notified' => '0',
							'comments' => 'PayPal IPN Invalid [' . $comment_status . ']');

	tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
  }
}
 }

 require('includes/application_bottom.php');
?>

 

The version i installed was IPN 2 3 4 6

 

I also have CCGV installed along with many other contributions

 

Thank you for any info you may be able to give me

David

Link to comment
Share on other sites

I thought i would add that i have turned off Auto reply and IPN notification in Paypal as stated in the instructions and i have tried to merge my Check out _process.php with My paypal_ipn.php, i think this is only a couple of lines from what i can see sofar

 

'customers_tax_exempt' => $order->customer['tax_exempt'], //rmh M-S_pricing

'orders_stores_id' => STORES_ID, //rmh M-S_multi-stores

'products_distributors_id' => $order->products[$i]['distrib_id'], //rmh M-S_multi-stores

 

 

here is my Checkout_process.php

 

<?php
/*
 $Id: checkout_process.php,v 1.128 2003/05/28 18:00:29 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 include('includes/application_top.php');

// if the customer is not logged on, redirect them to the login page
 if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 if (!tep_session_is_registered('billto')) { //rmh M-S_fixes
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
 }

 if ( (tep_not_null(MODULE_PAYMENT_INSTALLED)) && (!tep_session_is_registered('payment')) ) {
tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}

// avoid hack attempts during the checkout procedure by checking the internal cartID
 if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
if ($cart->cartID != $cartID) {
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
}
 }

 include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_PROCESS);

// load selected payment module
 require(DIR_WS_CLASSES . 'payment.php');
// Line Added - MOD: CREDIT CLASS Gift Voucher Contribution
 if ($credit_covers) $payment='';
 $payment_modules = new payment($payment);

// load the selected shipping module
 require(DIR_WS_CLASSES . 'shipping.php');
 $shipping_modules = new shipping($shipping);

 require(DIR_WS_CLASSES . 'order.php');
 $order = new order;

// load the before_process function from the payment modules
 $payment_modules->before_process();

 require(DIR_WS_CLASSES . 'order_total.php');
 $order_total_modules = new order_total;

 $order_totals = $order_total_modules->process();

 $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'],
					  'customers_country' => $order->customer['country']['title'],
					  'customers_telephone' => $order->customer['telephone'],
					  'customers_email_address' => $order->customer['email_address'],
					  'customers_address_format_id' => $order->customer['format_id'],
					  'customers_tax_exempt' => $order->customer['tax_exempt'], //rmh M-S_pricing
					  'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],
					  'delivery_company' => $order->delivery['company'],
					  'delivery_street_address' => $order->delivery['street_address'],
					  'delivery_suburb' => $order->delivery['suburb'],
					  'delivery_city' => $order->delivery['city'],
					  'delivery_postcode' => $order->delivery['postcode'],
					  'delivery_state' => $order->delivery['state'],
					  'delivery_country' => $order->delivery['country']['title'],
					  'delivery_address_format_id' => $order->delivery['format_id'],
					  'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'],
					  'billing_company' => $order->billing['company'],
					  'billing_street_address' => $order->billing['street_address'],
					  'billing_suburb' => $order->billing['suburb'],
					  'billing_city' => $order->billing['city'],
					  'billing_postcode' => $order->billing['postcode'],
					  'billing_state' => $order->billing['state'],
					  'billing_country' => $order->billing['country']['title'],
					  'billing_address_format_id' => $order->billing['format_id'],
					  'payment_method' => $order->info['payment_method'],
					  'cc_type' => $order->info['cc_type'],
					  'cc_owner' => $order->info['cc_owner'],
					  'cc_number' => $order->info['cc_number'],
					  'cc_expires' => $order->info['cc_expires'],
					  'date_purchased' => 'now()',
					  'orders_status' => $order->info['order_status'],
					  'orders_stores_id' => STORES_ID, //rmh M-S_multi-stores
					  'currency' => $order->info['currency'],
					  'currency_value' => $order->info['currency_value']);
 tep_db_perform(TABLE_ORDERS, $sql_data_array);
 $insert_id = tep_db_insert_id();
 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
$sql_data_array = array('orders_id' => $insert_id,
						'title' => $order_totals[$i]['title'],
						'text' => $order_totals[$i]['text'],
						'value' => $order_totals[$i]['value'],
						'class' => $order_totals[$i]['code'],
						'sort_order' => $order_totals[$i]['sort_order']);
tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
 }

 $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';
 $sql_data_array = array('orders_id' => $insert_id,
					  'orders_status_id' => $order->info['order_status'],
					  'date_added' => 'now()',
					  'customer_notified' => $customer_notification,
					  'comments' => $order->info['comments']);
 tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

// initialized for the email confirmation
 $products_ordered = '';
 $subtotal = 0;
 $total_tax = 0;

 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
// Stock Update - Joao Correia
if (STOCK_LIMITED == 'true') {
  if (DOWNLOAD_ENABLED == 'true') {
	$stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename
						FROM " . TABLE_PRODUCTS . " p
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
						 ON p.products_id=pa.products_id
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
						 ON pa.products_attributes_id=pad.products_attributes_id
						WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
	$products_attributes = $order->products[$i]['attributes'];
	if (is_array($products_attributes)) {
	  $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
	}
	$stock_query = tep_db_query($stock_query_raw);
  } else {
	$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
  }
  if (tep_db_num_rows($stock_query) > 0) {
	$stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
	if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
	  $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
	} else {
	  $stock_left = $stock_values['products_quantity'];
	}
	tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
	if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
	  tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
	}
  }
}

// Update products_ordered (for bestsellers list)
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

$sql_data_array = array('orders_id' => $insert_id,
						'products_id' => tep_get_prid($order->products[$i]['id']),
						'products_model' => $order->products[$i]['model'],
						'products_name' => $order->products[$i]['name'],
						'products_price' => $order->products[$i]['price'],
						'final_price' => $order->products[$i]['final_price'],
						'products_tax' => $order->products[$i]['tax'],
						'products_distributors_id' => $order->products[$i]['distrib_id'], //rmh M-S_multi-stores
						'products_quantity' => $order->products[$i]['qty']);
tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
$order_products_id = tep_db_insert_id();

// Start - CREDIT CLASS Gift Voucher Contribution
// CCGV 5.19 Fix for GV Queue with Paypal IPN
 $order_total_modules->update_credit_account($i,$insert_id);
// End - CREDIT CLASS Gift Voucher Contribution

//------insert customer choosen option to order--------
$attributes_exist = '0';
$products_ordered_attributes = '';
if (isset($order->products[$i]['attributes'])) {
  $attributes_exist = '1';
  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
	if (DOWNLOAD_ENABLED == 'true') {
	  $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
						   from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
						   left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
							on pa.products_attributes_id=pad.products_attributes_id
						   where pa.products_id = '" . $order->products[$i]['id'] . "'
							and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'
							and pa.options_id = popt.products_options_id
							and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'
							and pa.options_values_id = poval.products_options_values_id
							and popt.language_id = '" . $languages_id . "'
							and poval.language_id = '" . $languages_id . "'";
	  $attributes = tep_db_query($attributes_query);
	} else {
	  $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . tep_get_prid($order->products[$i]['id']) . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'"); //rmh M-S_fixes
	}
	$attributes_values = tep_db_fetch_array($attributes);

	$sql_data_array = array('orders_id' => $insert_id,
							'orders_products_id' => $order_products_id,
							'products_options' => $attributes_values['products_options_name'],
							'products_options_values' => $attributes_values['products_options_values_name'],
							'options_values_price' => $attributes_values['options_values_price'],
							'price_prefix' => $attributes_values['price_prefix']);
	tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

	if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
	  $sql_data_array = array('orders_id' => $insert_id,
							  'orders_products_id' => $order_products_id,
							  'orders_products_filename' => $attributes_values['products_attributes_filename'],
							  'download_maxdays' => $attributes_values['products_attributes_maxdays'],
							  'download_count' => $attributes_values['products_attributes_maxcount']);
	  tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
	}
	$products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];
  }
}
//------insert customer choosen option eof ----
$total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);
$total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];
$total_cost += $total_products_price;

$products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";
 }

// Line Added - MOD: CREDIT CLASS Gift Voucher Contribution
 $order_total_modules->apply_credit();

// lets start with the email confirmation
 $email_order = STORE_NAME . "\n" .
			 EMAIL_SEPARATOR . "\n" .
			 EMAIL_TEXT_ORDER_NUMBER . ' ' . $insert_id . "\n" .
			 EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" .
			 EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n";
 if ($order->info['comments']) {
$email_order .= tep_db_output($order->info['comments']) . "\n\n";
 }
 $email_order .= EMAIL_TEXT_PRODUCTS . "\n" .
			  EMAIL_SEPARATOR . "\n" .
			  $products_ordered .
			  EMAIL_SEPARATOR . "\n";

 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
$email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n";
 }

 if ($order->content_type != 'virtual') {
$email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" .
				EMAIL_SEPARATOR . "\n" .
				tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";
 }

 $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" .
			  EMAIL_SEPARATOR . "\n" .
			  tep_address_label($customer_id, $billto, 0, '', "\n") . "\n\n";
 if (is_object($$payment)) {
$email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" .
				EMAIL_SEPARATOR . "\n";
$payment_class = $$payment;
$email_order .= $payment_class->title . "\n\n";
if ($payment_class->email_footer) {
  $email_order .= $payment_class->email_footer . "\n\n";
}
 }
 tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

// send emails to other people
 if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
 }

// load the after_process function from the payment modules
 $payment_modules->after_process();

 $cart->reset(true);

// unregister session variables used during checkout
 tep_session_unregister('sendto');
 tep_session_unregister('billto');
 tep_session_unregister('shipping');
 tep_session_unregister('payment');
 tep_session_unregister('comments');

// Start - CREDIT CLASS Gift Voucher Contribution
 if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers');
 $order_total_modules->clear_posts();
// End - CREDIT CLASS Gift Voucher Contribution

 tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));

 require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

 

 

and here is m paypal-ipn.php

 

<?php
/*
 $Id: paypal_ipn.php,v 2.3.3.0 11/17/2007 11:15:28 alexstudio Exp $

 Copyright (c) 2004 osCommerce
 Released under the GNU General Public License

 Original Authors: Harald Ponce de Leon, Mark Evans 
 Updates by PandA.nl, Navyhost, Zoeticlight, David, gravyface, AlexStudio, windfjf and Terra
 v2.3 Updated by AlexStudio

*/

 class paypal_ipn {
var $code, $title, $description, $enabled, $identifier;

// class constructor
function paypal_ipn() {
  global $order;

  $this->code = 'paypal_ipn';
  $this->title = MODULE_PAYMENT_PAYPAL_IPN_TEXT_TITLE;
  $this->description = MODULE_PAYMENT_PAYPAL_IPN_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER;
  $this->enabled = ((MODULE_PAYMENT_PAYPAL_IPN_STATUS == 'True') ? true : false);
  $this->email_footer = MODULE_PAYMENT_PAYPAL_IPN_TEXT_EMAIL_FOOTER;
  $this->identifier = 'osCommerce PayPal IPN v2.3.3';
  // BOF Additional show text added by AlexStudio
  $this->show = MODULE_PAYMENT_PAYPAL_IPN_TEXT_SELECTION;
  $this->last_confirm = MODULE_PAYMENT_PAYPAL_IPN_TEXT_LAST_CONFIRM;
  // EOF Additional show text added by AlexStudio

  if ((int)MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID > 0) {
	$this->order_status = MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID;
  }

  if (is_object($order)) $this->update_status();

  if (MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER == 'Live') {
	$this->form_action_url = 'https://www.paypal.com/cgi-bin/webscr';
  } else {
	$this->form_action_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
  }
}

// class methods
function update_status() {
  global $order;

  if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_IPN_ZONE > 0) ) {
	$check_flag = false;
	$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_IPN_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
	while ($check = tep_db_fetch_array($check_query)) {
	  if ($check['zone_id'] < 1) {
		$check_flag = true;
		break;
	  } elseif ($check['zone_id'] == $order->billing['zone_id']) {
		$check_flag = true;
		break;
	  }
	}

	if ($check_flag == false) {
	  $this->enabled = false;
	}
  }
}

function javascript_validation() {
  return false;
}

function selection() {
  return array('id' => $this->code,
			   // BOF Additional show text addedby AlexStudio
			   'module' => $this->show);
			   // EOF Additional show text added by AlexStudio
}

function pre_confirmation_check() {
  return false;
}

function confirmation() {
  global $cartID, $cart_PayPal_IPN_ID, $customer_id, $languages_id, $order, $order_total_modules;

 // if (tep_session_is_registered('cartID')) {
 // PandA.nl: register_globals fix
 if (array_key_exists('cartID', $_SESSION)) {
	$insert_order = false;

	if (tep_session_is_registered('cart_PayPal_IPN_ID')) {
	  $order_id = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);

	  $curr_check = tep_db_query("select currency from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
	  $curr = tep_db_fetch_array($curr_check);

	   //if ( ($curr['currency'] != $order->info['currency']) || ($cartID != substr($cart_PayPal_IPN_ID, 0, strlen($cartID))) ) {
		//$check_query = tep_db_query('select orders_id from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int)$order_id . '" limit 1'); 
		$check_query = tep_db_query('select orders_id from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int)$order_id . '" limit 2');  //1.4
		$update_order = false;//1.4

		//if (tep_db_num_rows($check_query) < 1) {
		  //tep_db_query('delete from ' . TABLE_ORDERS . ' where orders_id = "' . (int)$order_id . '"');
		if (tep_db_num_rows($check_query) == 1) { //1.4
		  $update_order = true; //1.4
		  tep_db_query('delete from ' . TABLE_ORDERS_TOTAL . ' where orders_id = "' . (int)$order_id . '"');
		  tep_db_query('delete from ' . TABLE_ORDERS_STATUS_HISTORY . ' where orders_id = "' . (int)$order_id . '"');
		  tep_db_query('delete from ' . TABLE_ORDERS_PRODUCTS . ' where orders_id = "' . (int)$order_id . '"');
		  tep_db_query('delete from ' . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . ' where orders_id = "' . (int)$order_id . '"');
		  tep_db_query('delete from ' . TABLE_ORDERS_PRODUCTS_DOWNLOAD . ' where orders_id = "' . (int)$order_id . '"');
		}

		$insert_order = true;
	  //}	
	} else {
	  $insert_order = true;
	}

	if ($insert_order == true) {
	  $order_totals = array();
	  if (is_array($order_total_modules->modules)) {
		reset($order_total_modules->modules);
		while (list(, $value) = each($order_total_modules->modules)) {
		  $class = substr($value, 0, strrpos($value, '.'));
		  if ($GLOBALS[$class]->enabled) {
			for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
			  if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {
				$order_totals[] = array('code' => $GLOBALS[$class]->code,
										'title' => $GLOBALS[$class]->output[$i]['title'],
										'text' => $GLOBALS[$class]->output[$i]['text'],
										'value' => $GLOBALS[$class]->output[$i]['value'],
										'sort_order' => $GLOBALS[$class]->sort_order);
			  }
			}
		  }
		}
	  }

	  $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'],
							  'customers_country' => $order->customer['country']['title'],
							  'customers_telephone' => $order->customer['telephone'],
							  'customers_email_address' => $order->customer['email_address'],
							  'customers_address_format_id' => $order->customer['format_id'],
								'customers_tax_exempt' => $order->customer['tax_exempt'], //rmh M-S_pricing
							  'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],
							  'delivery_company' => $order->delivery['company'],
							  'delivery_street_address' => $order->delivery['street_address'],
							  'delivery_suburb' => $order->delivery['suburb'],
							  'delivery_city' => $order->delivery['city'],
							  'delivery_postcode' => $order->delivery['postcode'],
							  'delivery_state' => $order->delivery['state'],
							  'delivery_country' => $order->delivery['country']['title'],
							  'delivery_address_format_id' => $order->delivery['format_id'],
							  'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'],
							  'billing_company' => $order->billing['company'],
							  'billing_street_address' => $order->billing['street_address'],
							  'billing_suburb' => $order->billing['suburb'],
							  'billing_city' => $order->billing['city'],
							  'billing_postcode' => $order->billing['postcode'],
							  'billing_state' => $order->billing['state'],
							  'billing_country' => $order->billing['country']['title'],
							  'billing_address_format_id' => $order->billing['format_id'],
							  'payment_method' => $order->info['payment_method'],
							  'cc_type' => $order->info['cc_type'],
							  'cc_owner' => $order->info['cc_owner'],
							  'cc_number' => $order->info['cc_number'],
							  'cc_expires' => $order->info['cc_expires'],
							  'date_purchased' => 'now()',
							  'orders_status' => $order->info['order_status'],
														'orders_stores_id' => STORES_ID, //rmh M-S_multi-stores
							  'currency' => $order->info['currency'],
							  'currency_value' => $order->info['currency_value']);

	  //+1.4
	  if ( $update_order ){  
		tep_db_perform(TABLE_ORDERS, $sql_data_array, 'update', 'orders_id = "' . (int)$order_id . '"');
		$insert_id = (int)$order_id;
	  } else { 
	  //-1.4
	  tep_db_perform(TABLE_ORDERS, $sql_data_array);

	  $insert_id = tep_db_insert_id();
	  }//1.4

	  for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {
		$sql_data_array = array('orders_id' => $insert_id,
								'title' => $order_totals[$i]['title'],
								'text' => $order_totals[$i]['text'],
								'value' => $order_totals[$i]['value'],
								'class' => $order_totals[$i]['code'],
								'sort_order' => $order_totals[$i]['sort_order']);

		tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
	  }
	  //+1.4
	  $sql_data_array = array('orders_id' => $insert_id, 
								'orders_status_id' => $order->info['order_status'], 
								'date_added' => 'now()', 
					 'customer_notified' => '0', 
								'comments' => $order->info['comments']);
	  tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
	  //-1.4

	  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
		$sql_data_array = array('orders_id' => $insert_id,
								'products_id' => tep_get_prid($order->products[$i]['id']),
								'products_model' => $order->products[$i]['model'],
								'products_name' => $order->products[$i]['name'],
								'products_price' => $order->products[$i]['price'],
								'final_price' => $order->products[$i]['final_price'],
								'products_tax' => $order->products[$i]['tax'],
															'products_distributors_id' => $order->products[$i]['distrib_id'], //rmh M-S_multi-stores
								'products_quantity' => $order->products[$i]['qty']);

		tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);

		$order_products_id = tep_db_insert_id();

		$attributes_exist = '0';
		if (isset($order->products[$i]['attributes'])) {
		  $attributes_exist = '1';
		  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
			if (DOWNLOAD_ENABLED == 'true') {
			  $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
								   from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
								   left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
								   on pa.products_attributes_id=pad.products_attributes_id
								   where pa.products_id = '" . $order->products[$i]['id'] . "'
								   and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'
								   and pa.options_id = popt.products_options_id
								   and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'
								   and pa.options_values_id = poval.products_options_values_id
								   and popt.language_id = '" . $languages_id . "'
								   and poval.language_id = '" . $languages_id . "'";
			  $attributes = tep_db_query($attributes_query);
			} else {
			  $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
			}
			$attributes_values = tep_db_fetch_array($attributes);

			$sql_data_array = array('orders_id' => $insert_id,
									'orders_products_id' => $order_products_id,
									'products_options' => $attributes_values['products_options_name'],
									'products_options_values' => $attributes_values['products_options_values_name'],
									'options_values_price' => $attributes_values['options_values_price'],
									'price_prefix' => $attributes_values['price_prefix']);

			tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

			if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {
			  $sql_data_array = array('orders_id' => $insert_id,
									  'orders_products_id' => $order_products_id,
									  'orders_products_filename' => $attributes_values['products_attributes_filename'],
									  'download_maxdays' => $attributes_values['products_attributes_maxdays'],
									  'download_count' => $attributes_values['products_attributes_maxcount']);

			  tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
			}
		  }
		}
	  }

	// FS start
	$GLOBALS['cart_PayPal_IPN_ID'] = $cartID . '-' . $insert_id;
	// FS stop
	tep_session_register('cart_PayPal_IPN_ID');
	// FS start
	// Terra register globals fix
	//$_SESSION['cart_PayPal_IPN_ID'] = $cartID . '-' . $insert_id;
	// FS stop

	}
  }
  // BOF Confirmation Info added by AlexStudio
  $confirmation = array('title' => MODULE_PAYMENT_PAYPAL_IPN_TEXT_LAST_CONFIRM, 'fields' => array());
  return $confirmation;
  // EOF Confirmation Info added by AlexStudio
}

function process_button() {
  global $customer_id, $order, $languages_id, $currencies, $currency, $cart_PayPal_IPN_ID, $shipping, $order_total_modules;

  if (MODULE_PAYMENT_PAYPAL_IPN_CURRENCY == 'Selected Currency') {
	$my_currency = $currency;
  } else {
	$my_currency = substr(MODULE_PAYMENT_PAYPAL_IPN_CURRENCY, 5);
  }

  if (!in_array($my_currency, array('AUD', 'CAD', 'CHF', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'SGD', 'USD'))) {
	$my_currency = 'EUR';
  }

  // BOF Per Item mode fix by alexstudio
  $order_totals = array();
  if (is_array($order_total_modules->modules)) {
	reset($order_total_modules->modules);
	while (list(, $value) = each($order_total_modules->modules)) {
	  $class = substr($value, 0, strrpos($value, '.'));
	  if ($GLOBALS[$class]->enabled) {
		for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
		  if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {
			$order_totals[] = array('code' => $GLOBALS[$class]->code,
									'title' => $GLOBALS[$class]->output[$i]['title'],
									'text' => $GLOBALS[$class]->output[$i]['text'],
									'value' => $GLOBALS[$class]->output[$i]['value'],
									'sort_order' => $GLOBALS[$class]->sort_order);
		  }
		}
	  }
	}
  }
  foreach ($order_totals as $ot) {
	$order_total[$ot['code']] = $ot['value'];
  }
  $subtotal = $order_total['ot_subtotal'];
  if (DISPLAY_PRICE_WITH_TAX == 'true') $subtotal -= $order->info['tax'];
  // EOF Per Item mode fix by alexstudio

  $parameters = array();

  if ( (MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE == 'Per Item')/* && (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'False') // removed by AlexStudio*/) {
	$parameters['cmd'] = '_cart';
	$parameters['upload'] = '1';

	// Decide how many items are virtual (no shipping)
	$shipping_count = 0;
	$shipping_added = 0;
	$handling_added = 0;
	$item_tax = 0;
	$virtual_items = 1;
	for ($y=0; $y<sizeof($order->products); $y++) {
	  if (is_array($order->products[$y]['attributes'])) {
		while (list($key, $value) = each($order->products[$y]['attributes'])) {
		  $z = $key;
		  $attributes_query = "select pad.products_attributes_filename
							   from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
							   " . TABLE_PRODUCTS_ATTRIBUTES . " pa left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
							   on pa.products_attributes_id=pad.products_attributes_id
							   where pa.products_id = '" . $order->products[$y]['id'] . "'
							   and pa.options_id = '" . $order->products[$y]['attributes'][$z]['option_id'] . "'
							   and pa.options_id = popt.products_options_id
							   and pa.options_values_id = '" . $order->products[$y]['attributes'][$z]['value_id'] . "'
							   and pa.options_values_id = poval.products_options_values_id";
		  $attributes = tep_db_query($attributes_query);
		  $attributes_values = tep_db_fetch_array($attributes);
		  if (tep_not_null($attributes_values['products_attributes_filename'])) $virtual_items++;
		}
	  }
	}

	for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
	  $item = $i+1;

	  $tax_value = ($order->products[$i]['tax'] / 100) * $order->products[$i]['final_price'];

	  $parameters['item_name_' . $item] = $order->products[$i]['name'];
	  $parameters['item_number_' . $item] = $order->products[$i]['model'];
	  // BOF Tax pre item fix by AlexStudio
	  if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') $parameters['amount_' . $item] = number_format(($order->products[$i]['final_price'] + $tax_value) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	  else {
		$parameters['amount_' . $item] = number_format($order->products[$i]['final_price'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
		$parameters['tax_' . $item] = number_format($tax_value * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	  }
	  $item_tax += number_format($tax_value * $order->products[$i]['qty'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	  // EOF Tax pre item fix by AlexStudio
	  $parameters['quantity_' . $item] = $order->products[$i]['qty'];

	  // BOF shipping & handling fix by AlexStudio
	  $item_has_shipping = true;
	  // EOF shipping & handling fix by AlexStudio
	  if (isset($order->products[$i]['attributes'])) {
		for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
		  if (DOWNLOAD_ENABLED == 'true') {
			$attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
								 from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
								 left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
								 on pa.products_attributes_id=pad.products_attributes_id
								 where pa.products_id = '" . $order->products[$i]['id'] . "'
								 and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'
								 and pa.options_id = popt.products_options_id
								 and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'
								 and pa.options_values_id = poval.products_options_values_id
								 and popt.language_id = '" . $languages_id . "'
								 and poval.language_id = '" . $languages_id . "'";
			$attributes = tep_db_query($attributes_query);
		  } else {
			$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");
		  }
		  $attributes_values = tep_db_fetch_array($attributes);
		  // BOF shipping & handling fix by AlexStudio
		  if (tep_not_null($attributes_values['products_attributes_filename'])) $item_has_shipping = false;
		  // EOF shipping & handling fix by AlexStudio

// Unfortunately PayPal only accepts two attributes per product, so the
// third attribute onwards will not be shown at PayPal
		  $parameters['on' . $j . '_' . $item] = $attributes_values['products_options_name'];
		  $parameters['os' . $j . '_' . $item] = $attributes_values['products_options_values_name'];
		}
	  }
	  // BOF shipping & handling fix by AlexStudio
	  $handling = $order_total['ot_loworderfee'];
	  if ($n == 1 || $item < $n) {
		$parameters['handling_' . $item] = number_format($handling/$n * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
		$handling_added += $parameters['handling_' . $item];
	  } else {
		$parameters['handling_' . $item] = number_format($handling * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)) - $handling_added;
	  }
	  if ($item_has_shipping) {
		$shipping_count++;
		$shipping_items = $n - $virtual_items;
		if ($shipping_items == 1 || $shipping_count < $shipping_items) {
		  $parameters['shipping_' . $item] = number_format(($order_total['ot_shipping']/$shipping_items) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
		  $shipping_added += $parameters['shipping_' . $item];
		} else {
		  $parameters['shipping_' . $item] = number_format($order_total['ot_shipping'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency)) - $shipping_added;
		}
	  }
	  // EOF shipping & handling fix by AlexStudio
	}
	// BOF Tax pre item fix by AlexStudio
	$tax_total = number_format($order->info['tax'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	if ($tax_total > $item_tax && DISPLAY_PRICE_WITH_TAX != 'true') {
	  $item++;
	  $parameters['item_name_' . $item] = 'Shipping Tax';
	  $parameters['amount_' . $item] = $tax_total - $item_tax;
	  $parameters['quantity_' . $item] = 1;
	}
	// EOF Tax pre item fix by AlexStudio

	if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
	  // BOF Tax pre item fix by AlexStudio
	  $parameters['amount'] = number_format(($subtotal + $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	} else {
	  // default
	  $parameters['amount'] = number_format($subtotal * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	  // EOF Tax pre item fix by AlexStudio
	}

  } else {
	$parameters['cmd'] = '_ext-enter';
	$parameters['redirect_cmd'] = '_xclick';
	$parameters['item_name'] = STORE_NAME;
	// BOF shipping & handling fix by AlexStudio
	if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
	  $parameters['amount'] = number_format(($subtotal + $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	} else {
	  // default
	  $parameters['amount'] = number_format($subtotal * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	  $parameters['tax'] = number_format($order->info['tax'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	}
	if ($order->content_type != 'virtual') {
	  $parameters['shipping'] = number_format($order_total['ot_shipping'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	}
	$parameters['handling'] = number_format($order_total['ot_loworderfee'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	// EOF shipping & handling fix by AlexStudio
  }

  // 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

  $parameters['business'] = MODULE_PAYMENT_PAYPAL_IPN_ID;

  // let's check what has been defined in the shop admin for the shipping address
// BOF parameters fix by AlexStudio
  if ($order->content_type != 'virtual') {
	$parameters['address_override'] = '1';
	$parameters['no_shipping'] = '2';
	$parameters['night_phone_b'] = $order->customer['telephone'];
	$parameters['first_name'] = $order->delivery['firstname'];
	$parameters['last_name'] = $order->delivery['lastname'];
	$parameters['address1'] = $order->delivery['street_address'];
	$parameters['address2'] = $order->delivery['suburb'];
	$parameters['city'] = $order->delivery['city'];
	$parameters['zip'] = $order->delivery['postcode'];
	$parameters['state'] = $state_abbr;
	$parameters['country'] = $order->delivery['country']['iso_code_2'];
	$parameters['email'] = $order->customer['email_address'];
  } else {
	$parameters['no_shipping'] = '1';
	$parameters['night_phone_b'] = $order->customer['telephone'];
	$parameters['first_name'] = $order->billing['firstname'];
	$parameters['last_name'] = $order->billing['lastname'];
	$parameters['address1'] = $order->billing['street_address'];
	$parameters['address2'] = $order->billing['suburb'];
	$parameters['city'] = $order->billing['city'];
	$parameters['zip'] = $order->billing['postcode'];
	$parameters['state'] = $state_abbr;
	$parameters['country'] = $order->billing['country']['iso_code_2'];
	$parameters['email'] = $order->customer['email_address'];
  }
  /********************************************************************************
*************
  *	Currently these are the supported charsets:											 *
  *	big5, euc-jp, euc-kr, euc-tw, gb2312, hz-gb-2312, ibm-862, iso-2022-cn, iso-2022-jp,	*
  *	iso-2022-kr, iso-8859-1, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6,	*
  *	iso-8859-7, iso-8859-8, iso-8859-9, iso-8859-13, iso-8859-15, ko18-r, shift_jis,		*
  *	utf-7, utf-8, utf-16, utf-16be, utf-16le, utf-16_platformendian, utf-16_oppositeendian, *
  *	utf-32, utf-32be, utf-32le, utf-32_platformendian, utf-32_oppositeendian, usa-ascii,	*
  *	windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255,	 *
  *	windows-1256, windows-1257, windows-1258, windows-874, windows-949, x-mac-greek,		*
  *	x-mac-turkish, x-mac-centraleurroman, x-mac-cyrillic, ebcdic-cp-us, ibm-1047			*
  ***************************************************************************
*******************/
  $parameters['charset'] = "iso-8859-2"; // Modify this line if you have problems with the character set.
// EOF parameters fix by AlexStudio

  $parameters['currency_code'] = $my_currency;
  $parameters['invoice'] = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);
  $parameters['custom'] = $customer_id;
  $parameters['no_note'] = '1';
  $parameters['notify_url'] = tep_href_link('ext/modules/payment/paypal_ipn/ipn.php', 'language=' . $_SESSION['language'], 'SSL', false, false);
  $parameters['cbt'] = CONFIRMATION_BUTTON_TEXT;  
  $parameters['return'] = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
//	  $parameters['cancel_return'] = tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL');
  $parameters['cancel_return'] = tep_href_link(FILENAME_SHOPPING_CART, 'ipn=cancel_ipn&order='.$parameters['invoice'], 'SSL');
  $parameters['bn'] = $this->identifier;
  $parameters['lc'] = $order->customer['country']['iso_code_2'];

  if (tep_not_null(MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE)) {
	$parameters['page_style'] = MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE;
  }

  if (MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS == 'True') {
	$parameters['cert_id'] = MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID;

	$random_string = rand(100000, 999999) . '-' . $customer_id . '-';

	$data = '';
	reset($parameters);
	while (list($key, $value) = each($parameters)) {
	  $data .= $key . '=' . $value . "\n";
	}

	$fp = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt', 'w');
	fwrite($fp, $data);
	fclose($fp);

	unset($data);

	if (function_exists('openssl_pkcs7_sign') && function_exists('openssl_pkcs7_encrypt')) {
	  openssl_pkcs7_sign(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt', MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY), file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY), array('From' => MODULE_PAYMENT_PAYPAL_IPN_ID), PKCS7_BINARY);

	  unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt');

// remove headers from the signature
	  $signed = file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');
	  $signed = explode("\n\n", $signed);
	  $signed = base64_decode($signed[1]);

	  $fp = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', 'w');
	  fwrite($fp, $signed);
	  fclose($fp);

	  unset($signed);

	  openssl_pkcs7_encrypt(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt', MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt', file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY), array('From' => MODULE_PAYMENT_PAYPAL_IPN_ID), PKCS7_BINARY);

	  unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');

// remove headers from the encrypted result
	  $data = file_get_contents(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');
	  $data = explode("\n\n", $data);
	  $data = '-----BEGIN PKCS7-----' . "\n" . $data[1] . "\n" . '-----END PKCS7-----';

	  unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');
	} else {
	  exec(MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL . ' smime -sign -in ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt -signer ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY . ' -inkey ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY . ' -outform der -nodetach -binary > ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');
	  unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'data.txt');

	  exec(MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL . ' smime -encrypt -des3 -binary -outform pem ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY . ' < ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt > ' . MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');
	  unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'signed.txt');

	  $fh = fopen(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt', 'rb');
	  $data = fread($fh, filesize(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt'));
	  fclose($fh);

	  unlink(MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY . '/' . $random_string . 'encrypted.txt');
	}

	$process_button_string = tep_draw_hidden_field('cmd', '_s-xclick') .
							 tep_draw_hidden_field('encrypted', $data);

	unset($data);
  } else {
	reset($parameters);
	while (list($key, $value) = each($parameters)) {
	  $process_button_string .= tep_draw_hidden_field($key, $value);
	}
  }
  return $process_button_string;
}

function before_process() {
  global $cart;

  $cart->reset(true);

// unregister session variables used during checkout
  tep_session_unregister('sendto');
  tep_session_unregister('billto');
  tep_session_unregister('shipping');
  tep_session_unregister('payment');
  tep_session_unregister('comments');

  tep_session_unregister('cart_PayPal_IPN_ID');

  tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));
}

function after_process() {
  return false;
}

function output_error() {
  return false;
}

function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_IPN_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
}

function install() {
  $check_query = tep_db_query("select orders_status_id from " . TABLE_ORDERS_STATUS . " where orders_status_name = 'Preparing [PayPal IPN]' limit 1");

  if (tep_db_num_rows($check_query) < 1) {
	$status_query = tep_db_query("select max(orders_status_id) as status_id from " . TABLE_ORDERS_STATUS);
	$status = tep_db_fetch_array($status_query);

	$status_id = $status['status_id']+1;

	$languages = tep_get_languages();

	foreach ($languages as $lang) {
	  tep_db_query("insert into " . TABLE_ORDERS_STATUS . " (orders_status_id, language_id, orders_status_name) values ('" . $status_id . "', '" . $lang['id'] . "', 'Preparing [PayPal IPN]')");
	}
  } else {
	$check = tep_db_fetch_array($check_query);

	$status_id = $check['orders_status_id'];
  }

  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable PayPal IPN Module', 'MODULE_PAYMENT_PAYPAL_IPN_STATUS', 'False', 'Do you want to accept PayPal IPN payments?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Gateway Server', 'MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER', 'Testing', 'Use the testing (sandbox) or live gateway server for transactions?', '6', '2', 'tep_cfg_select_option(array(\'Testing\',\'Live\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '3', now())");			
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('E-Mail Address', 'MODULE_PAYMENT_PAYPAL_IPN_ID', '', 'The e-mail address to use for the PayPal IPN service', '6', '5', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Currency', 'MODULE_PAYMENT_PAYPAL_IPN_CURRENCY', 'Selected Currency', 'The currency to use for transactions', '6', '10', 'tep_cfg_select_option(array(\'Selected Currency\',\'Only USD\',\'Only GBP\',\'Only AUD\',\'Only CAD\',\'Only CHF\',\'Only CZK\',\'Only DKK\',\'Only EUR\',\'Only HKD\',\'Only HUF\',\'Only JPY\',\'Only NOK\',\'Only NZD\',\'Only PLN\',\'Only SEK\',\'Only SGD\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_PAYPAL_IPN_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '11', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Preparing Order Status', 'MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID', '" . $status_id . "', 'Set the status of prepared orders made with this payment module to this value', '6', '12', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set PayPal Acknowledged Order Status', 'MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '13', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set PayPal Completed Order Status', 'MODULE_PAYMENT_PAYPAL_IPN_COMP_ORDER_STATUS_ID', '0', 'Set the status of orders which are confirmed as paid (completed) to this value', '6', '13', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Transaction Type', 'MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE', 'Aggregate', 'Send individual items to PayPal or aggregate all as one total item?', '6', '14', 'tep_cfg_select_option(array(\'Per Item\',\'Aggregate\'), ', now())");
  // bof PandA.nl move tax to total amount
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Move tax to total amount', 'MOVE_TAX_TO_TOTAL_AMOUNT', 'True', 'Do you want to move the tax to the total amount? If true PayPal will allways show the total amount including tax. (needs Aggregate instead of Per Item to function)', '6', '15', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  // eof PandA.nl move tax to total amount	  
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Page Style', 'MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE', '', 'The page style to use for the transaction procedure (defined at your PayPal Profile page)', '6', '20', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Debug E-Mail Address', 'MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL', '', 'All parameters of an Invalid IPN notification will be sent to this email address if one is entered.', '6', '21', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('cURL Proxy server', 'MODULE_PAYMENT_PAYPAL_IPN_PROXY_SERVER', '', 'If curl transactions need to go through a proxy, type the address here starting with http://. Otherwise, leave it blank. The current GoDaddy proxy address is http://proxy.shr.secureserver.net:3128', '6', '22', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Encrypted Web Payments', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS', 'False', 'Do you want to enable Encrypted Web Payments?', '6', '30', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Your Private Key', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY', '', 'The location of your Private Key to use for signing the data. (*.pem)', '6', '31', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Your Public Certificate', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY', '', 'The location of your Public Certificate to use for signing the data. (*.pem)', '6', '32', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('PayPals Public Certificate', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY', '', 'The location of the PayPal Public Certificate for encrypting the data.', '6', '33', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Your PayPal Public Certificate ID', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID', '', 'The Certificate ID to use from your PayPal Encrypted Payment Settings Profile.', '6', '34', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Working Directory', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY', '', 'The working directory to use for temporary files. (trailing slash needed)', '6', '35', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('OpenSSL Location', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL', '/usr/bin/openssl', 'The location of the openssl binary file.', '6', '36', now())");

}

function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}

  function keys() {
// PandA.nl move tax to total amount added: ", 'MOVE_TAX_TO_TOTAL_AMOUNT'"
 return array('MODULE_PAYMENT_PAYPAL_IPN_STATUS', 'MODULE_PAYMENT_PAYPAL_IPN_GATEWAY_SERVER', 'MODULE_PAYMENT_PAYPAL_IPN_ID', 'MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER', 'MODULE_PAYMENT_PAYPAL_IPN_CURRENCY', 'MODULE_PAYMENT_PAYPAL_IPN_ZONE', 'MODULE_PAYMENT_PAYPAL_IPN_PREPARE_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYPAL_IPN_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYPAL_IPN_COMP_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE', 'MOVE_TAX_TO_TOTAL_AMOUNT', 'MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE', 'MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL', 'MODULE_PAYMENT_PAYPAL_IPN_PROXY_SERVER', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_STATUS', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PRIVATE_KEY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PUBLIC_KEY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_PAYPAL_KEY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_CERT_ID', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_WORKING_DIRECTORY', 'MODULE_PAYMENT_PAYPAL_IPN_EWP_OPENSSL');
  }
 }
?>

David

Link to comment
Share on other sites

Back again

 

Just an update, I done all the above again

 

and now i am beginning to get somewhere, the admin now reconises where the order came from, however there are now other problems, my CCGV doent not appear to be passing the discounts, but more importantly the IPN does not appear to be updating the admin section, so no emails are going out or confirmation that the order was paid. Cant see Paypal attempting to make a connection at all, when i had a return address in the paypal IPN section i could see paypal make a connection in the whos online, but it seems very quite now, I read in the set up that this must not be switched on on the paypal site

David

Link to comment
Share on other sites

Hi David

 

I have just finished configuring this pesky thing for a few weeks, so hopefully I can chime in with what has been a steep learning curve. :D

 

Regarding the discounts bit. What setup/add-on are you using for the discounts? There was a recent patch update resolving a conflict between IPN and 2 discount add-ons. (drex's add-on from 26 April)

 

I also read somewhere about not turning stuff on in PayPal, but if you go to the Instant PayPal Notification preferences in your PayPal account, you have to add the URL to the path eg http://yourdomain/catalog/includes/modules.../paypal_ipn.php (which gets payPal to communicate with your site) and a return URL (taking you back to the site). PayPal does get huffy if you have any shipping calculations set up in the PayPal account.

 

Also is permissions on your /tmp folder set to 777?

 

2 guides I have found to be a gospel over the last few days are:

 

http://www.oscommerce.com/forums/index.php?sho...=0&p=730503 - which is a payPal IPN and downloads guide, but confirms what I've just covered above.

 

http://www.oscommerce.com/forums/index.php?showtopic=166092 - which tackles encryption.

 

I hope this helps and good luck! ;)

Debbie Harrison

 

Link to comment
Share on other sites

Thanks for your input Debbie,

 

I have turned back on the IPN on the paypal website and it is now sending the data back to the main store, not sure if its working for all the stores yet and still have other issues but i am now a lot further forward

 

Regards

David

Link to comment
Share on other sites

I am a lot further forward than i was, but still an issue, to do with Discount CCGV

 

I have set the Pay pal transaction to agrreate

 

ensured that in admin>modules>order total that the sort order of total is highest

 

I have made the changes to ipn.php and paypal_ipn.php that would have been made to checkout_process.php on the install of CCGV

 

But its still not passing on the discounted price to the paypal portal

 

I am gusessing this is something very simple but i just cant see it, i have now spent days on it, if somebody has any ideas please speak up

 

Thank you

David

Link to comment
Share on other sites

hey David

 

Fellow Essex, eh? Is it easier for me to shout this out of the door? :lol:

 

Whichever contribution you are using (I am assuming http://addons.oscommerce.com/info/282) have you tried approaching the recent programmer/contributor to that particular add-on?

 

I have no idea if this breaches etiquette rules on this forum (and if it does then apologies), but as no rules seem to be available, so I think this might be a good place to start if you aren't a PHP developer.

 

Hope this helps.

Debbie Harrison

 

Link to comment
Share on other sites

What is the order status set to allow download.

 

This should be a value less then or equal to order status on order payment recd.

 

 

Satish

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Link to comment
Share on other sites

I am a lot further forward than i was, but still an issue, to do with Discount CCGV

 

I have set the Pay pal transaction to agrreate

 

ensured that in admin>modules>order total that the sort order of total is highest

 

I have made the changes to ipn.php and paypal_ipn.php that would have been made to checkout_process.php on the install of CCGV

 

But its still not passing on the discounted price to the paypal portal

 

I am gusessing this is something very simple but i just cant see it, i have now spent days on it, if somebody has any ideas please speak up

 

Thank you

 

 

1)setting to aggregate is the first thing that You need to do and You have done that.

2)You need to make sure value of order->total has the CCGV effect (deduction done) before its getting posted.

A missplaced line to call CCGV to modify order total might result in this bug.

Had seen this happen on few shop codes.

 

Satish

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Link to comment
Share on other sites

Hi There

 

The version I have of IPN.php and paypal_ipn.php is 2.3.4.6

 

As I have Multi stores I add to ipn.php

 

'orders_status' => $order->info['order_status'],

'orders_stores_id' => STORES_ID, //rmh M-S_multi-stores

'currency' => $order->info['currency'],

 

 

and

 

'customers_address_format_id' => $order->customer['format_id'],

'customers_tax_exempt' => $order->customer['tax_exempt'], //rmh M-S_pricing

'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],

and

'products_tax' => $order->products[$i]['tax'],

'products_distributors_id' => $order->products[$i]['distrib_id'], //rmh M-S_multi-stores

'products_quantity' => $order->products[$i]['qty']);

 

with these additions every thing works fine apart from a discount applied in CCGV and can receive payments from multiple stores and updateing to Admin perfectly

 

 

I then add

 

 

require(DIR_WS_CLASSES . 'payment.php');

// Line Added - MOD: CREDIT CLASS Gift Voucher Contribution

if ($credit_covers) $payment='';

 

 

and

 

// Start - CREDIT CLASS Gift Voucher Contribution

// CCGV 5.19 Fix for GV Queue with Paypal IPN

$order_total_modules->update_credit_account($i,$insert_id);

// End - CREDIT CLASS Gift Voucher Contribution

 

//------insert customer choosen option to order--------

$attributes_exist = '0';

 

and

 

// Line Added - MOD: CREDIT CLASS Gift Voucher Contribution

$order_total_modules->apply_credit();

 

// lets start with the email confirmation

$email_order = STORE_NAME . "\n" .

 

and

 

tep_session_unregister('comments');

 

// Start - CREDIT CLASS Gift Voucher Contribution

if(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers');

$order_total_modules->clear_posts();

// End - CREDIT CLASS Gift Voucher Contribution

 

 

and everything still works fine apart from CCGV again, no discount is passed to paypal at all

 

 

I tried using various versions of ipn.php & paypal-ipn.php and found that if I use version 2.2 the discount is passed straight through to paypal but other errors occur before the site is updated.

 

The problem appears to me that even though its set to agreate the total passed to paypal does not include the discount, this must be due to the file that is collected by the ipn is not the updated one, but I do not know how to check what the wrong info is,

 

Perhaps someone could advise on how much this would cost to put right for me as it appears beyond my capabilities.

 

Thank you

 

 

David

David

Link to comment
Share on other sites

Hello,

 

We are also getting multiple emails for the same order for the last one month or so. There is some problem with this module or with Paypal IPN notification. We had to de-activate this module.

 

Please give us a solution to this problem if there is any.

 

Thanks,

 

Lakshmanan

 

 

 

 

 

On some orders I get continued notifications from the Paypal IPN module confirming the order. The problem is every time this happens it deducts from my stock.

 

 

Below is what an order would look like.

05/31/2008 16:15:00 Processing PayPal IPN Verified [Completed (Unverified; $40.98)]

05/31/2008 16:16:00 Processing PayPal IPN Verified [Completed (Unverified; $40.98)]

05/31/2008 16:17:00 Processing PayPal IPN Verified [Completed (Unverified; $40.98)]

 

 

 

Anyone experience this?

Link to comment
Share on other sites

IPN concept is to send IPN till it receives an ack.

So paypal will keep sending for 48 hrs or so if no ack is sent.

 

Your code part that should send ack appears to have been not working.

 

Satish

Ask/Skype for Free osCommerce value addon/SEO suggestion tips for your site.

 

Check My About US For who am I and what My company does.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...