Jump to content
Mark Evans

Official PayPal IPN Support Thread

Recommended Posts

For example , I add 5 items to my cart, and I check out to the paypal site. Paypal always shows the quantity as 1 item. I'm just wondering if osCommerce is somehow giving paypal the wrong quantity. Something that just came to my mind is that maybe since the order is aggregated, it will just show the order as one. If it is aggregated as I believe that's the default option in the module options, wouldn't that sort of not give an accurate idea of how many items are bought since the receipt will always show 1?

 

Lastly I hope the next question isn't off topic. I'm wondering if it's better to let my shop calculate the tax or to let paypal handle it. Currently I'm doing it on my site but it adds the tax before shipping&handling - it should come after. Just in case you were wondering, I am using contribution 1124 (Canada Tax Zones Setup notes)

The "1" is because you are using PayPal in Aggregate mode (so it'll always show 1). If you use "per item" then it'll show the products but you might get into trouble with tax with that mode.

 

As for tax - I'm not sure what to advise as I've got no experience with Canada or the contrib you mention. Have you tried "move tax to total = true"? If your sort order under order totals is correct, it *should* pass the tax to PayPal when used in Aggregate mode.

 

Maryland comes to mind; the US state code is MD, but the county of Maryland in Liberia has the code ML. I ran into this while improving international support in the PayPal WPP contribution (the dynamoeffects version, contribution 3647).

Glen - many thanks! If it's okay with you, I'll take your code and include in the next update. I'm considering to leave the state name as default, but include the code if anybody wants to change it to the 2-letter abbreviation. It really depends on the country, I suppose - in the UK, we'd use the county name as there are no recognised abbreviations. Maybe a nifty "if / else" statement would be better (if USA then ...).

 

Is it just the USA which uses the 2-letter abbreviations or are there any other countries?

 

Terra

Edited by Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites
I'm not sure what the working path is supposed to look like, but I've tried: /tmp/ ; tmp/ ; mywebsite.com/tmp/ ; /home/content/a/a/a/user/html/tmp/ - and the chmod on that folder is set to 777

Leibtek

I've never used the working directory - I think you only need that when using Encrypted Payments, so just leave blank.

 

If you are getting an invalid response, then

-> PayPal has accesed the correct file (ipn.php), which is good

-> but could not verify the payment, hence it fails to update the status

 

Would help if you can tell us on what server you are (I hope not Windows - in which case, I really can't help), what your register globals status is etc. Also please have a read through the thread and check if any of the solutions posted helps to solve your problem. PS: the "invalid" response is sent back by PayPal so the IPN does communicate with PayPal, it just is not able to verify the payment, might be worth checking your settings in PayPal account regarding currency etc.

 

all the best, Terra

Edited by Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites
Is it just the USA which uses the 2-letter abbreviations or are there any other countries?

Terra

Canada uses 2 letter codes.

 

Alberta AB

British Columbia BC

Manitoba MB

New Brunswick NB

Newfoundland and Labrador NL

Northwest Territories NT

Nova Scotia NS

Nunavut NU

Ontario ON

Prince Edward Island PE

Quebec QC

Saskatchewan SK

Yukon YT

 

Sheri

Share this post


Link to post
Share on other sites
Would help if you can tell us on what server you are (I hope not Windows - in which case, I really can't help), what your register globals status is etc. Also please have a read through the thread and check if any of the solutions posted helps to solve your problem. PS: the "invalid" response is sent back by PayPal so the IPN does communicate with PayPal, it just is not able to verify the payment, might be worth checking your settings in PayPal account regarding currency etc.

 

all the best, Terra

 

Thanks Terra,

 

I did search a little on this thread for an answer... but haven't found anything related.

 

My HTTP server is Apache. The register_globals local value is "on" master value is "on".

 

We are using SSL.

 

The interesting part is, that the payment goes through, and the email states "payment_status=Completed".

 

My Paypal status is "Unverified", Biz account.

 

We are in the US and are using US accounts for the testing.

 

Many Thanks,

Leibtek

Share this post


Link to post
Share on other sites

Here is a debug email:

 

$_POST:

 

payment_date=10:16:32 Jul 11, 2006 PDT

txn_type=web_accept

last_name=*****

residence_country=US

item_name=*****.com

payment_gross=0.01

mc_currency=USD

business=l@******.com

payment_type=instant

verify_sign=AFdFtmbcbm.Q01wEydOwwwaRwQorA.rH9tqW6fV3hdBU5XwjMM8kw.0.

payer_status=unverified

test_ipn=1

tax=0.00

payer_email=*****@bigfoot.com

txn_id=7HH286663P898583M

quantity=1

receiver_email=l@******.com

first_name=Leibtek

invoice=31

payer_id=MBQCAJYX7BDHG

receiver_id=MCCN6PM8CEYJC

item_number=

payment_status=Completed

payment_fee=0.01

mc_fee=0.01

shipping=0.00

mc_gross=0.01

custom=4

charset=windows-1252

notify_version=2.1

 

$_GET:

Share this post


Link to post
Share on other sites

I am very new to this whole php, web payment thing so please be gentle :D I've downloaded the module for the Paypal IPN and I have a few questions. I've gone through the set up and hit a few snags along the way. Mainly the whole section on SSL and certificates. I've looked on my server for the certificates and can't find any. in Cpanel I have an ssl link but that is only to add certificates and so on. upon doing some research on ssl I looked at verisign and a few other places and the cost for a certificate is outrageous! Is there a way to impliment this module without having to have and pay for these certs? all I'd really like to have is that the info from the site is forwarded to paypal so the customer doesn't have to re-enter it all. I've followed all of the instructions that come with the package but, still can't get it to work. Any help would be greatly appreciated and remember please be gentle :D

Share this post


Link to post
Share on other sites

Hi all,

 

I'm using PayPal-IPN with Fee charge by Sebastian Kleine along with CCGV 5.16. I am getting the problem of paypal not passing discount voucher and ignoring the tax per item mode. In Aggregate mode the shipping and tax are not added so I get a negative total if the voucher exceeds the total. Any help would be appreciate.


Onnig

Share this post


Link to post
Share on other sites
Hi all,

 

I'm using PayPal-IPN with Fee charge by Sebastian Kleine along with CCGV 5.16. I am getting the problem of paypal not passing discount voucher and ignoring the tax per item mode. In Aggregate mode the shipping and tax are not added so I get a negative total if the voucher exceeds the total. Any help would be appreciate.

 

OK, now I'm getting somewhere, I installed paypal ipn 1.3 and set to aggregate mode and true to tax with total. When I do not use a voucher the total comes out correctly. When I do use a voucher, the shipping is ignored.

 

Onnig


Onnig

Share this post


Link to post
Share on other sites
OK, now I'm getting somewhere, I installed paypal ipn 1.3 and set to aggregate mode and true to tax with total. When I do not use a voucher the total comes out correctly. When I do use a voucher, the shipping is ignored.

 

Onnig

 

OK, it turns out that if the Total after coupons and vouchers equals less than the shipping cost then paypal goes haywire. Not sure where to look.


Onnig

Share this post


Link to post
Share on other sites
OK, it turns out that if the Total after coupons and vouchers equals less than the shipping cost then paypal goes haywire. Not sure where to look.

yes, that's a bug which is on the list for fixing - in the meantime you can fix it easily by changing the code. Please see my post (which is for the standard Paypal module but you get the idea & can adapt for the IPN):

http://forums.oscommerce.com/index.php?s=&...st&p=883171

 

Basically, instead of sending a total and shipping separately, you need to send just one total - then it'll be fine. all the best, Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites
Mainly the whole section on SSL and certificates.

You don't need an SSL - if cURL is enabled on your server, it'll use that for encryption. The Open SSL which the IPN mentions is different from an SSL you'd buy for your site -your hosting company should be able to advise. The certificate is a PayPal thing - please see your PayPal account help section for more details. all the best, Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites
Here is a debug email:

 

A few things to check out which can cause INVALID responses:

-> non alpha numeric characters in the product names or buyer's name (e.g. accents, plus, minus ...)

-> some people reported problems with fsocket

-> other contributions (e.g. download controler - there's a separate support thread for that)

-> your server environment (restrictions on folders / files) - PayPal & your shop must be able to communicate

-> IPN turned on in your PayPal account (should be off)

-> currency differences between shop/IPN and PayPal account inc. different currency abbreviations

 

INVALID means that PayPal could not verify the parameters which were originally sent, hence the INVALID response. This does not affect the payment, it just means PayPal is unable to verify your shop/info.

 

all the best, Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites
-> non alpha numeric characters in the product names or buyer's name (e.g. accents, plus, minus ...)

-> some people reported problems with fsocket

-> other contributions (e.g. download controler - there's a separate support thread for that)

-> your server environment (restrictions on folders / files) - PayPal & your shop must be able to communicate

-> IPN turned on in your PayPal account (should be off)

-> currency differences between shop/IPN and PayPal account inc. different currency abbreviations

Thanks Again, Terra,

 

I don't seem to have a problem with any of the above. The only thing that is missing in the "invalid" email, is the item number, but I can't beleive that that is the issue, since everyone would have the same problem.

 

I will ask on Paypal's forum, and will report back. If you think of something else.. please let me know.

 

Thanks So Much,

Leibtek

 

P.S. I can see Paypal accessing the ipn.php file after a sale in the Who's Online (enhanced contrib)

Share this post


Link to post
Share on other sites

Terra is it possible to remove the entire email function from this OSC PayPal module?

 

Mine still insists on putting "ser" in place of the order number and now starting last week most of the confirmation emails sent (if one is sent at all) are being truncated right after the point where the order number should be in the email. This in turn looks bad to the customer.

 

I cant just turn off sending emails in OSC because then no emails would be sent for the cash/money order payment method which I also use.

 

Since the paypal side works perfectly and PayPal sends the customer an email I don't need this module to send one.

 

I'm not that sharp on PHP so I'm not sure just how much code or in which file I need to remove to take out the email function.

Edited by ATVUtah

Share this post


Link to post
Share on other sites
yes, that's a bug which is on the list for fixing - in the meantime you can fix it easily by changing the code. Please see my post (which is for the standard Paypal module but you get the idea & can adapt for the IPN):

http://forums.oscommerce.com/index.php?s=&...st&p=883171

 

Basically, instead of sending a total and shipping separately, you need to send just one total - then it'll be fine. all the best, Terra

 

Thanks for the feedback Terra. OK I applied your fix but the cart is still sending a separate shipping amount, but this time I'm not getting a negative number, I'm getting the total minus the difference between the total and the shipping (which is a negative number). Example if my total after vouchers and coupons is $2.60 and my shipping was $2.79 from the total before any vouchers and coupons, I get this:

 

Amount: $2.60 USD

Shipping & Handling: $2.79 USD

Total Amount: $5.39 USD

 

it should read:

 

Amount: $2.60 USD

Shipping & Handling: $0.00 USD

Total Amount: $2.60 USD


Onnig

Share this post


Link to post
Share on other sites
Thanks for the feedback Terra. OK I applied your fix

Like I said - the fix was for the standard PayPal module, not the IPN so it was as example only. If you are unable to modify the code yourself, give this a try: NB: this is for AGGREGATE MODE only! won't work if you are using per item.

 

find this (around line 322) and delete or comment out:

		$parameters['shipping'] = number_format($order->info['shipping_cost'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

 

find this (around line 333):

	  if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
	   // PandA.nl move tax to total amount
	   $parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	   } else {
	   // default
	  $parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
  }

 

and replace with this:

	  if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
	   // PandA.nl move tax to total amount
	   $parameters['amount'] = number_format(($order->info['total']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	   } else {
	   // default
	  $parameters['amount'] = number_format(($order->info['total'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
  }

 

In theory this should work as now the IPN sends no shipping and the total amount includes everything.

 

all the best, Terra

Edited by Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites
Terra is it possible to remove the entire email function from this OSC PayPal module?

 

Mine still insists on putting "ser" in place of the order number and now starting last week most of the confirmation emails sent (if one is sent at all) are being truncated right after the point where the order number should be in the email. This in turn looks bad to the customer. Since the paypal side works perfectly and PayPal sends the customer an email I don't need this module to send one.

Gary - my worry is that something is wrong in your code / site and personally, I hate having bugs around - they usually surface when you least need them! If you do have a bit of spare time, might be worth giving it another go - the "ser" has go to come from somewhere, and once you know what's happening it *should* be easy to fix.

 

If you want, you can of course take the email function out - in paypal_ipn.php find this code around line 562:

	  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);
  }

and either delete or comment out. You can of course also delete the email functions above that code but these lines are the actual "email send" command, so that will disable it without too many modifications. Terra

 

PS: might also be worth posting the code from your paypal_ipn.php file from around line 424 (function before_process()) until the end for checking.

Edited by Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites
Like I said - the fix was for the standard PayPal module, not the IPN so it was as example only. If you are unable to modify the code yourself, give this a try: NB: this is for AGGREGATE MODE only! won't work if you are using per item.

 

find this (around line 322) and delete or comment out:

		$parameters['shipping'] = number_format($order->info['shipping_cost'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));

 

find this (around line 333):

	  if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
	   // PandA.nl move tax to total amount
	   $parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	   } else {
	   // default
	  $parameters['amount'] = number_format(($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
  }

 

and replace with this:

	  if(MOVE_TAX_TO_TOTAL_AMOUNT == 'True') {
	   // PandA.nl move tax to total amount
	   $parameters['amount'] = number_format(($order->info['total']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
	   } else {
	   // default
	  $parameters['amount'] = number_format(($order->info['total'] - $order->info['tax']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency));
  }

 

In theory this should work as now the IPN sends no shipping and the total amount includes everything.

 

all the best, Terra

 

That worked, thanks, the one part I did not do is comment out the shipping section. Thanks for your help.


Onnig

Share this post


Link to post
Share on other sites
PS: might also be worth posting the code from your paypal_ipn.php file from around line 424 (function before_process()) until the end for checking.

 

Terra here is the code from /catalog/includes/modules/payment/paypal_ipn.php

(function before_process()) begins at line 416 in my file.

The other bug besides the email problem is that orders processed by the PayPal IPN module doesnt update the inventory. Check or money order orders work perfectly so I'm fairly certain the database is ok. I'm suspecting it's all related somehow.

 

Orders are taken and added to the database payments are registered and the order status changes to "pending" but then the emails blow up and the stocks not updated so I cant use the reorder or most reports :(

 

By the way register_globals is on on my server. The PayPal profile setting are all basically set to the defaults except I add the sales tax there and I have my banner on the payment pages.

 

 

	function before_process() {
  global $customer_id, $order, $sendto, $billto, $payment, $languages_id, $currencies, $cart, $cart_PayPal_IPN_ID;
  global $$payment;

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

  $order_totals = $order_total_modules->process();

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

  $sql_data_array = array('orders_id' => $order_id,
						  'orders_status_id' => $order->info['order_status'],
						  'date_added' => 'now()',
						  'customer_notified' => (SEND_EMAILS == 'true') ? '1' : '0',
						  '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']) . "'");

//------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 = '" . $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);

		$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";
  }

// lets start with the email confirmation
  $email_order = STORE_NAME . "\n" .
				 EMAIL_SEPARATOR . "\n" .
				 EMAIL_TEXT_ORDER_NUMBER . ' ' . $order_id . "\n" .
				 EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $order_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
  $this->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');

  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', '3', '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 ('E-Mail Address', 'MODULE_PAYMENT_PAYPAL_IPN_ID', '', 'The e-mail address to use for the PayPal IPN service', '6', '4', 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', '6', 'tep_cfg_select_option(array(\'Selected Currency\',\'Only USD\',\'Only CAD\',\'Only EUR\',\'Only GBP\',\'Only JPY\'), ', 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', '0', 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', '2', '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', '0', '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', '0', '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', 'Per Item', 'Send individual items to PayPal or aggregate all as one total item?', '6', '6', 'tep_cfg_select_option(array(\'Per Item\',\'Aggregate\'), ', 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', '6', '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 ('Page Style', 'MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE', '', 'The page style to use for the transaction procedure (defined at your PayPal Profile page)', '6', '4', 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', '4', 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', '3', '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', '4', 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', '4', 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', '4', 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', '4', 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', '4', 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', '4', now())");

}

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

function keys() {
  return array('MODULE_PAYMENT_PAYPAL_IPN_STATUS', 'MODULE_PAYMENT_PAYPAL_IPN_ID', '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_GATEWAY_SERVER', 'MODULE_PAYMENT_PAYPAL_IPN_TRANSACTION_TYPE', 'MODULE_PAYMENT_PAYPAL_IPN_PAGE_STYLE', 'MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL', 'MODULE_PAYMENT_PAYPAL_IPN_SORT_ORDER', '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');
}
 }
?>

Share this post


Link to post
Share on other sites
Glen - many thanks! If it's okay with you, I'll take your code and include in the next update. I'm considering to leave the state name as default, but include the code if anybody wants to change it to the 2-letter abbreviation. It really depends on the country, I suppose - in the UK, we'd use the county name as there are no recognised abbreviations. Maybe a nifty "if / else" statement would be better (if USA then ...).

 

Is it just the USA which uses the 2-letter abbreviations or are there any other countries?

 

Terra

 

Terra,

You are certainly welcome to use it. The version in the PayPal WPP code makes two queries to the database. When I wrote it, I figured that there was a better way, but I'm still somewhat of a beginner at SQL and didn't know the proper syntax. I have further refined it as follows:

 

$state_query = tep_db_query("SELECT " . TABLE_ZONES . ".zone_code FROM ". TABLE_COUNTRIES . "," . TABLE_ZONES . " WHERE  ". TABLE_COUNTRIES . ".countries_id = " . TABLE_ZONES . ".zone_country_id AND " . TABLE_ZONES . ".zone_name = '" . $order->billing['state'] . "' AND ". TABLE_COUNTRIES . ".countries_name = '" . $order->billing['country'] . "'");

 

I will also pass this along to Brian Burton for inclusion in the next version of his PayPal WPP contribution.

 

--Glen

Share this post


Link to post
Share on other sites
I will ask on Paypal's forum, and will report back. If you think of something else.. please let me know.

 

Hi Terra,

 

We finally solved this problem. We are hosting at goDaddy.com, and they have a firewall in place...

Ok, so anyone out there hosting at goDaddy, add these two lines to the ipn.php file:

 

look for

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

 

and after that add:

curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);

//Route thru GoDaddy's proxy

curl_setopt ($ch, CURLOPT_PROXY,"http://64.202.165.130:3128");

 

Maybe you can add this to the contribution with the ip being a variable, for all those of us hosting at goDaddy or at any other hosting with a firewall.

Please take a look at this FAQ we found at goDaddy.. http://help.godaddy.com/article.php?articl...88&topic_id

 

Thank You,

Leibtek

Edited by Leibtek

Share this post


Link to post
Share on other sites
We finally solved this problem. We are hosting at goDaddy.com, and they have a firewall in place...

ah - well done! I did find a reference to GoDaddy when googling but I just couldn't narrow it down. I will include your info on the next update. Personally, I'm not keen on GoDaddy - but then as hosting provider I would probably say that! :lol: Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites
Personally, I'm not keen on GoDaddy - but then as hosting provider I would probably say that! :lol: Terra

 

Well they did cause a problem you know.

What is your hosting company? ... you never know I might come your way one day. :D

 

Leibtek

Edited by Leibtek

Share this post


Link to post
Share on other sites

Hello-

 

I'm in the process of installing PayPal IPN Payment Module v1.3 and I'm having a little bit of confussion with a couple of the details.

 

"Your Private Key" what is that? I have gone through all the steps in securing my domain, but dont recall any Private Key.

 

"Your Public Certificate" My domain is secured but I did not need to upload any files to my server. Do I need to now?

 

"PayPals Public Certificate" I have uploaded my cert to paypal and have downloaded theirs. Do I just rename it and place it somewhere on my server?

 

"Your PayPal Public Certificate ID" That would be the Cert ID they issued my cert when I uploaded it to paypal correct?

 

"Working Directory" That would simple be just a folder "/tempfiles/" right?

 

Thank you in Advance

Share this post


Link to post
Share on other sites
I'm in the process of installing PayPal IPN Payment Module v1.3 and I'm having a little bit of confussion with a couple of the details.

If you have cURL enabled and are not using PayPal's Certificates, just leave empty and you are fine (for more info on Certificates and Keys please go to PayPal). Terra


My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×