Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PayPal_Shopping_Cart_IPN


devosc

Recommended Posts

  • Replies 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

...

Jeff, login as a customer start checking out and confirm the order and get transferred to the PayPal site, now open up another browser and go to your store, look at your account history, that order that you just initiated will show in your account history as pending payment, likewise so too in the admin. Now open another browser and enter the order# into the ipn.html test file and submit the form, this should now update the order from 'Pending Payment' to whatever your default status is. In admin->payment->paypal your Primarty Email address should be (snuff@) and your business ID should be (order@), your PayPal account should be a premier or business account both will work, this is why I suspect you have had problems in the live mode, you need to look back and check those Email config emails, this is how I suspect they should look:

 

STORE_NAME

Primary PayPal Email Address: snuff@

Business ID: order@

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

Primary PayPal Email Address: snuff@

Business ID: order@

 

Underneath the above line is what PayPal says your settings are, above the line is what you have configured in the admin.

OK, live tests. Customer bought 1 item from me today, I got a standard Notification email from paypal showing his purchase (10:32). Got 3 debugs (at 10:32--Debug, Email & Business ID, Verified), then an email from cust (he's helping me test)(10:39), then 2 more emails from "me" (at 10:49) (T-Nuts^com PayPal IPN: Unknown Transaction Type plus an Unknown Verification).

No order shown in the admin anywhere.

 

Following your above quote, I do that and my account history is blank, my admin is also empty, can't find the order# anywhere, and the contents are still in my "cart" as if they never checked out.

 

Log in as another test guy, pay cash for something, all works fine.

Using the old paypal mod (default), I would get the orders in the admin, etc, but only if they clicked all the way through paypal.

I can post the debugs or anything else you want to see, just let me know.

--Jeff

 

(edit) will change the primary email to snuff@ and see what happens. But why would that make a difference?

Edited by snuff
Link to comment
Share on other sites

Hmm, still no IPN info from the actual Paypal payment. And this is thus blank (PayPal Customer Registration Details). I did get an IPN notice from the ipn-test.html page, though. I guess as long as I get the order details, it's not really a big issue for me, as that was the main problem I was having before. :P

 

I am using the fixed paypal/ipn.php file. Also, I accidentally Uninstalled the Paypal payment module, and was sad to see all my settings got erased too. Would be nice if there was a Are You SURE you want to uninstall the module before it does it, or perhaps have it still save all the settings...

Link to comment
Share on other sites

One more odd thing.... the previously mentioned T-N.com Paypal IPN: Unknown Verification email contained this:

(extra spaces removed)

 

Connection Type

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

curl= , socket= ssl://, domain= www.paypal.com, port= 443

 

PayPal Response

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

HTTP/1.1 200 OK

Date: Mon, 05 Apr 2004 17:49:36 GMT

Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a

Cache-Control: private

Expires: Thu, 05 Jan 1995 22:00:00 GMT

Pragma: no-cache

Set-Cookie: KHcl0EuY7AKSMgfvHl7J5E7hPtK=cq1hIzqwvmaTs6VOw4stH_G-Bt-v8j_DaveRZusn8od5-FPn-OIqkj4lliWqm0X0ByK9zXfCeKpjNaYs; expires=Sun, 31-Mar-2024 17:49:36 GMT; path=/; domain=.paypal.com

Set-Cookie: cookie_check=yes; expires=Thu, 03-Apr-2014 17:49:36 GMT; path=/; domain=.paypal.com

Set-Cookie: Apache=216.86.199.225.235851081187376622; path=/; expires=Wed, 29-Mar-34 17:49:36 GMT

Connection: close

Content-Type: text/html; charset=windows-1252

 

PayPal - Welcome

 

 

Sign Up | Log In | Help

 

Member Log In

Email Address

 

Password

 

Forget your password?

Protect your password

 

What's New

 

Protect yourself from fraudulent emails and websites

Send invoices with the NEW PayPal Outlook Wizard

Refer new merchants and earn up to $100.00 USD

Join the PayPal team

Community Spotlight

 

Send Money

Pay anyone with an email address

 

Request Money

Send a personal or group bill

 

Over 40 million member accounts worldwide!

 

Sign up for your FREE PayPal account

 

Spotlight

 

Auction Tools

It's easy to buy and sell on eBay when you use PayPal to process your payments.

 

Merchant Tools

Accept online credit card payments immediately with PayPal's Merchant Tools.

 

PayPal Shops

Shop at one of over 42,000 websites that accept PayPal.

 

About

| Accounts

| Fees

| Privacy

| Security Center

| User Agreement

| Developers

| Referrals

| Shops | Mass Pay

an eBay Company

Copyright © 1999-2004 PayPal. All rights reserved.

Information about FDIC pass-through insurance

Link to comment
Share on other sites

Greg, thanks for the reply.

 

I figured curl wasn't working so I tried the following code instead.

 

echo "Starting Transaction...<BR>";
$header = '';
$paypal_response = '';
$_response_string = 'cmd=_notify-validate';
$domain = "www.paypal.com";

$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen($_response_string)."\r\n\r\n";
$socket = 'ssl://'; 
$port = '443';
$fp = @fsockopen ($socket.$domain,$port, $errno, $errstr, 30);
     
if(!$fp) 
{
 $socket = 'tcp://'; $port = '80';
 $fp = @fsockopen ($socket.$domain,$port, $errno, $errstr, 30);
}

if(!$fp) 
{
 $fp = @fopen('https://'.$domain.'/cgi-bin/webscr?'.$_response_string);
 $paypal_response = @fgets($fp, 1024); 
 @fclose($fp);

 if (!$paypal_response) 
 {
   $paypal_http_response = @file('http://'.$domain.'/cgi-bin/webscr?'.$_response_string);
    $paypal_response = @$paypal_http_response[0];
 } 
 else 
 {
   @fputs($fp, $header . $_response_string);
   while (!feof($fp)) 
  {
     $paypal_response .= @fgets($fp, 1024);
   }
   @fclose($fp);
 }
}

echo "Response String - " . $_response_string . "<BR>";      
echo "PayPal Response - " . $paypal_response . "<BR>";

echo "<BR>Transaction Complete<BR>";

 

The output I get is

 

Starting Transaction...
Response String - cmd=_notify-validate
PayPal Response - 

Transaction Complete

 

I figure there's something wrong my my server as it doesn't seem to be able to connect at all. Can you confirm that the above code is valid?

 

 

Also, I think there's a minor bug in the authenticate() method. There is a line towards the end which says fclose($log) when it should say fclose($fp);

Link to comment
Share on other sites

Yeah I know about the $log bug :)

Ok the script you have above doesn't look quite right, try echoing $socket and I think you'll see, i.e. i reckon it is using $fp = @fsockopen ($socket.$domain,$port, $errno, $errstr, 30); but you don't capture the response etc. try the the whole bit of the orginal code, even if it wasn't working you should get an email to that effect.

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

Link to comment
Share on other sites

Oh boy oh boy oh boy.

I guess I'm glad I washed my feet this morning 'cuz I've had them in my mouth all day.

I suppose one should triple-check their work when converting from default paypal to IPN ver 1.7 to IPN ver 2.0.

IPN's/orders were not posting to the Admin because I still had 1.7 files in my osC!

Somehow I did copy the 2.0 files to the osC directory, but they didn't save properly to the server. So I re-ran the install process, found 2 error files, and fixed those and now it works.

BTW, found a teeny tiny bug that showed up in my SQL, one of the tables modded by the paypal_ipn.sql was missing a letter "n", which was easily fixed. The error was not in the .sql file that I could see, must have just been a freak error during execution of the .sql. No biggie.

 

One question, now that it works (so far!)-- If a customer, like me, cancels out of paying IN PAYPAL, the order still shows Pending Payment and shows in the order history, etc. Is there a way to make the order remain "in-cart" until paypal confirms payment? Maybe this was answered somewhere already, I'm just half delirious from lack of sleep and no food.

 

Oh, yeah. Something else. Regarding "primary" vs "business" emails, I put all emails in the admin:paypal set to order@ (my paypal primary is snuff@) and it works fine (again, so far). We'll see for sure later on.

 

Thanks for your help and patience.

--Jeff

Link to comment
Share on other sites

Is there a way to make the order remain "in-cart" until paypal confirms payment?
Currently in order to achieve that you would have to use v1.7 and not use the Auto-Return feature.

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

Link to comment
Share on other sites

ok...I went live...so I thought....money was changing hands so I thought we were good to go....

 

did 2 purchases and money changed hands but when I view the order in the admin panel, none of the paypal registration details show up! I checked the database and nothing got written to the database for that transaction.

 

Ideas?

 

 

The order does show up and money did change hands but no details into the database. Is this normal behavior or bug or me? :(

Link to comment
Share on other sites

Hi Greg,

 

I wonder if you know where the problem might be. When I Press Confirm Order Button, a new window pops up with paypal page..... So I got 2 windows leading to paypal page and this coz orders to be dublicated in the Orders Report.

Here is a line in checkout_confirmation.php

?php

  if (isset($$payment->form_action_url)) {

    $form_action_url = $$payment->form_action_url;

  } else {

    $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');

  }

 

if(!ereg('(secure.paypal)|(nochex)', $form_action_url)){ 

  echo'<script language="JavaScript">

  function PostData(){

  window.document.addOrder.submit();

  }

</script>';

 

  echo tep_draw_form('checkout_confirmation', $form_action_url, 'post', 'target="_blank"');

if (is_array($payment_modules->modules)) {

    echo $payment_modules->process_button();

  }

 

  echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER, 'OnClick="java script:PostData();"') . '</form>' . "\n";

 

echo tep_draw_form('addOrder', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'), 'post');

    if (is_array($payment_modules->modules)) {

    echo $payment_modules->process_button();

  }

  echo  '</form>' . "\n";

}else{

echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');

  if (is_array($payment_modules->modules)) {

        echo $payment_modules->process_button();

    }

 

echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n";

}

?>

Please tell me if the above code is causing a new windows to pop up.

If not can anyone tell me where to start looking for the code that pops another windows up.

 

This does not happen before I install the paypal_ipn code

Thanks :huh:

Link to comment
Share on other sites

Greg,

 

I finally figured out that although curl is installed, it doesn't seem to be working correctly. So, I have prevented catalog/include/modules/payment/paypal/ipn.php from trying the curl method and that seems to have got everything going.

 

Thanks for all your help, this is an excellent contribution!

 

James

Link to comment
Share on other sites

Dear Greg,

 

Please ignore the previous post, I tried using the Cash on Delivery Payment and still new windows pops up. So it has nothing to do with this conribution. But If you can suggest what file I can try to look for this problem, I will really appreciate. thanks :(

Link to comment
Share on other sites

Nick, compare your checkout_confirmation.php script to the original osCommerce one, I think you'll find that there are differences.

 

carrerarod & szenses, this contrib was specifically developed with MS2 2.2 I am not accquainted with earlier versions etc, so it is hard to say what and how won't work etc.

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

Link to comment
Share on other sites

carrerarod & szenses, this contrib was specifically developed with MS2 2.2 I am not accquainted with earlier versions etc, so it is hard to say what and how won't work etc.

fair enough...can you tell me though where in your code do you write the information to the database? that seems to be the only part that does not work.

 

TIA

 

B)

Link to comment
Share on other sites

The original MS2 2.2 checkout_process.php script was split into 2 so now in includes/modules/payment/paypal/ there 2 scripts checkout_process.php and checkout_update.php.

 

paypal/checkout_process.php now only creates the order, i.e. it only updates etc the order related db tables, for example TABLE_ORDERS_PRODUCTS_ATTRIBUTES. It now no longer immediatly updates TABLE_ORDERS_PRODUCTS_DOWNLOAD this is done in checkout_update once a 'Completed' payment_status IPN has been received.

 

checkout_update.php now updates the stores inventory levels, order_history_status, orders_products_downloads and sends the order confirmation emails accordingly.

 

Both scripts are a disection of the original checkout_process.php, but there are some subtlies in order to get checkout_update.php to work, a specific example is: 'orders_products_id' => $order_products_id, had to be changed to

'orders_products_id' => $order->products[$i]['orders_products_id'],

You'll need to examine both files carefully to see what other changes have occurred in relation to their intended purposes.

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

Link to comment
Share on other sites

What would cause the 2.0 ver to do this?

1. customer confirms OK, transfer to paypal OK

2. paypal sends me email that funds are in.

3. debug emails received (Debug, E&B ID config, Verified)

 

4. NO 'IPN INSERTED' email

5. NO 'Order Process' email

6. Nothing in the 'admin:Paypal IPN'

7. Nothing in the 'admin:orders' info for paypal.

 

Settings:

return URL = POST

 

paypal IPN= ON, None

Auto Return=ON, http://site.com/catalog/

 

Q's--Should the Auto Return url in paypal be .../catalog/checkout_process.php, something else, or entirely blank? Or does it not matter?

Also, what difference does POST vs. GET make?

 

--Jeff

Link to comment
Share on other sites

The original MS2 2.2 checkout_process.php script was split into 2 so now in includes/modules/payment/paypal/ there 2 scripts checkout_process.php and checkout_update.php.

 

paypal/checkout_process.php now only creates the order, i.e. it only updates etc the order related db tables, for example TABLE_ORDERS_PRODUCTS_ATTRIBUTES. It now no longer immediatly updates TABLE_ORDERS_PRODUCTS_DOWNLOAD this is done in checkout_update once a 'Completed' payment_status IPN has been received.

 

checkout_update.php now updates the stores inventory levels, order_history_status, orders_products_downloads and sends the order confirmation emails accordingly.

 

Both scripts are a disection of the original checkout_process.php, but there are some subtlies in order to get checkout_update.php to work, a specific example is: 'orders_products_id' => $order_products_id, had to be changed to

'orders_products_id' => $order->products[$i]['orders_products_id'],

You'll need to examine both files carefully to see what other changes have occurred in relation to their intended purposes.

Thanks Greg. Just for clarification, the orders tables, etc. do get populated correctly with the data. It's the newly created tables from the contrib that are not getting populated.

 

If I understand your response correctly, the checkout_update.php file is the one I need to be concerned about?

 

Is there a condition that would prevent the data from getting written into those tables if though money has traded hands and that the other orders tables are populated?

 

TIA

 

B)

Edited by carrerarod
Link to comment
Share on other sites

Jeff, you might have to post the contents of the debug email, just blank out any identifying info to yourself or the customer, one thing to look for is the payment_status field.

 

Generally an order is not updated, completed, untill an IPN that say the payment is 'Completed' has been received, i.e. you got the money. However even if you got an IPN saying, 'Pending' like for example eCheck then you should see IPN in the admin, there is still some tidying up to do in this area but as it stands it will suffice. Let's see the debug info.

 

Don't worry about auto-return in the admin section of the v2.0 contrib it is not need.

 

carrerarod,

Each IPN with a unique transaction id wil get stored, as above, the order is only updated once the IPN payment_status is 'Completed'. Check the orders_session_info db table, if there exists a record for that order then it means that order has not been fully completed, i.e. a 'Completed' payment_status IPN has not been received.

Edited by gregbaboolal

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

Link to comment
Share on other sites

Each IPN with a unique transaction id wil get stored, as above, the order is only updated once the IPN payment_status is 'Completed'. Check the orders_session_info db table, if there exists a record for that order then it means that order has not been fully completed, i.e. a 'Completed' payment_status IPN has not been received.

Now we are getting somewhere!

 

I do have a record for that order in the orders_session_info table! What should I look at next to narrow this puppy down!

 

If we can iron out these kinks that you know your contrib works on older snapshots of osc!

 

B)

Link to comment
Share on other sites

Where's the debug info? whats the payment_status?

the payment status for that transaction shows "completed" in my paypal account.

 

which debug information are you talkng about? the emails?

Link to comment
Share on other sites

yeah, just mask out any identifiable info

ok...I wasn't getting the debug emails....not sure why...but here is another piece of data that might explain. Since I am paying myself (using my different credit cards) the account I was using was "unverified" which forced my merchant account to "accept" the payment.

Link to comment
Share on other sites

ok ... got it working! It requires really hacking the application_top.php file included with the contrib (the one in /includes/payment/module/paypal/)

 

this is a 2.1 heavily modified snapshot.....

 

here is what the application_top.php looks like now (I commented out the lines instead of deleting. You will see it pretty much only involves adding a reference at the top of the file to the original application_top.php file as this one contains most of the same information):

 

<?php
/*
 $Id: module/payment/paypal/application_top.php,v 1.0 2004/03/29 06:00:00 [email protected] Exp $

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

 Copyright (c) 2003 osCommerce
 Copyright (c) 2004 Gregory Baboolal

 Released under the GNU General Public License
*/

require('includes/application_top.php');

// set the level of error reporting
//  error_reporting(E_ALL & ~E_NOTICE);

// check if register_globals is enabled.
// since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
//  if (function_exists('ini_get')) {
//    ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');
//  }

// Set the local configuration parameters - mainly for developers
//  if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

// include server parameters
//  require('includes/configure.php');

// define the project version
//  define('PROJECT_VERSION', 'osCommerce 2.2-MS2');

// set php_self in the local scope
 if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];

// include the list of project filenames
//  require(DIR_WS_INCLUDES . 'filenames.php');

// include the list of project database tables
//  require(DIR_WS_INCLUDES . 'database_tables.php');

// include the database functions
//  require(DIR_WS_FUNCTIONS . 'database.php');

// make a connection to the database... now
//  tep_db_connect() or die('Unable to connect to database server!');

// set the application parameters
//  $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
//  while ($configuration = tep_db_fetch_array($configuration_query)) {
//    define($configuration['cfgKey'], $configuration['cfgValue']);
//  }

// define general functions used application-wide
//  require(DIR_WS_FUNCTIONS . 'general.php');
//  require(DIR_WS_FUNCTIONS . 'html_output.php');

// some code to solve compatibility issues
//  require(DIR_WS_FUNCTIONS . 'compatibility.php');

// define how the session functions will be used
//  require(DIR_WS_FUNCTIONS . 'sessions.php');

// include currencies class and create an instance
//  require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

// include the mail classes
//  require(DIR_WS_CLASSES . 'mime.php');
//  require(DIR_WS_CLASSES . 'email.php');

// retrieve order session info
 $orders_session_query = tep_db_query("select * from " . TABLE_ORDERS_SESSION_INFO . " where orders_id ='" . (int)$_POST['custom'] . "'");
 $orders_session = tep_db_fetch_array($orders_session_query);
 $sendto = $orders_session['sendto'];
 $billto = $orders_session['billto'];
 $payment = 'paypal';
 //$payment = $orders_session['payment'];
 //$shipping = unserialize($orders_session['shipping']);

// set the language
 $language = $orders_session['language'];
//  include(DIR_WS_CLASSES . 'language.php');
//  $lng = new language();
//  $lng->set_language($language);
//  $lng = new language($language);
//  $language = $lng->language['directory'];
//  $languages_id = $lng->language['id'];

// include the language translations
//  require(DIR_WS_LANGUAGES . $language . '.php');

// currency
 $currency = $orders_session['currency'];

// tidy up
 if ( strcmp(phpversion(),'4.0.6') <= 0 ) {
   $_GET = $HTTP_GET_VARS;
   $_POST = $HTTP_POST_VARS;
   $_SERVER = $HTTP_SERVER_VARS;
 }
 unset($_GET,$HTTP_GET_VARS,$HTTP_POST_VARS);
?>

 

Now the last thing I need to do is try Greg's hack for the order status and this contrib is solid!

 

You Da Man Greg! B)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...