seanpatrick Posted November 18, 2009 Posted November 18, 2009 I am running Paypal IPN on an an MS2 OSC store. I have used the EXACT same code on the same host for another site successfully, but for some reason I am having a problem on this particular install. When a customer pays via Paypal (my only option) and complete the transaction successful on Paypal.com, they are shown a "click to return to" button. When that button is clicked, they are momentarily sent to checkout_success.php but are redirected to shopping_cart.php with a "Your Shopping Cart is empty!" message displayed. On the administrative side of things, the order doesn't process completely and is set to Pending, not displaying the IPN data nor deducting the product from inventory (thus the main issue with this problem). I've tried changing the Paypal Module settings from GET to POST to NO IPN with no difference in the problem. I've also hardcoded the checkout_success.php URL into modules/payment/paypal.php but nothing changed. It seems the session ID isn't being passed back correctly? Any help would be greatly appreciated! Also: can I bypass the "click to return to" button in Paypal with an auto-return? If so, where is that setting? In OSC I don't see it so it's in Paypal? Thanks! Quote
satish Posted November 29, 2009 Posted November 29, 2009 When a customer returns from paypal after payment if sesion id is lost (paypal post the session id and code needs to handle it for session creation) then this will happen. Satish Quote 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.
seanpatrick Posted December 1, 2009 Author Posted December 1, 2009 When a customer returns from paypal after payment if sesion id is lost (paypal post the session id and code needs to handle it for session creation) then this will happen. Satish So how would I go about making sure it sends the session ID back to the store? Thanks Satish for the help! Quote
satish Posted December 1, 2009 Posted December 1, 2009 First thing is you make sure that 'Auto Return' is ON in your PayPal Merchant Account Profile. So a customer does not have to click on return to site button. Once that is achieved then You need to collect the post and get variables(probably once the auto return is fixed the error will be gone) and check which variable has session id. Now thru code modification You start that session Satish Quote 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.
seanpatrick Posted January 12, 2010 Author Posted January 12, 2010 Not sure if this is related, but I've noticed on stores that aren't handling IPN notifications properly I'm also seeing code like this added to URLs as customers browse the store: &osCsid=1a29ba8806e70988ee729d3abe4d63e3 I've compared the settings under "Sessions" in the Admin between a store doing this and one that isn't and they're both set to "False" for every option... could this be the culprit? Quote
satish Posted January 17, 2010 Posted January 17, 2010 "click to return to" button. this should not be there if auto return is set to on. IPN is not supposed to reach checkout_process.php it is to reach the notify url path.(provide link of the contribution used). Satish Quote 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.
seanpatrick Posted January 18, 2010 Author Posted January 18, 2010 I have auto-return turned on, pointing to checkout_process.php. Is that correct? I'm using PayPal Shopping Cart IPN v3.1.5. If you could tell me the IPN notification URL, I'd appreciate it. Thanks! Quote
satish Posted January 18, 2010 Posted January 18, 2010 tep_draw_hidden_field('notify_url', tep_href_link(FILENAME_IPN, '', 'SSL',false)) . it is ipn.php in catalog folder. Satish Quote 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.
seanpatrick Posted January 27, 2010 Author Posted January 27, 2010 I sandbox tested my ipn.php and it's giving a 500 Server Error message. If I test checkout_process.php (which Paypal told me should be used) it gives an "IPN Sent Successfully" message. I REALLY need to resolve this problem as it's now impacting two stores I've installed. Satish, could I give you access to one of them perhaps?? Quote
Guest Posted February 1, 2011 Posted February 1, 2011 got exact same issue with same contribution did some debug work, in domain logs i just get a simple die with error 500 ( "POST /ipn.php HTTP/1.0" 500 - "-" "-") I then checked in ipn.php and it had this line in it if($ipn->uniqueTxnID() && $ipn->isReversal() && strlen($ipn->key['parent_txn_id']) == 17) { as far as i can tell from the ipn debug emails the parent_txn_id isn't passed, but txn_id is which is 17 chars in length I have tried changing parent_txn_id to just txn_id but still get error 500. I even commented out the two dienice function calls to present error 500s but still the same ! any pointers as to help diagnosing would be much appreciated. The orders are generated within the shop but stay as pending with no ipn info (IPN History database table is also empty) I am receiving IPN info written to ipn.txt so the ipn info is returning back to the right place, but my debug lines to write lines to the ipn.txt log file always end with the last few lines of entry being mc_currency = GBP residence_country = GB transaction_subject = 7430003d447414d424b093fc47ec9040 payment_gross = got here ok and here txn_id length = 17 txn_id = 9G932957ME342024V this line 0 <?php /* $Id: ipn.php,v 1.1.1.1 2004/09/22 13:45:11 devosc Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com DevosC, Developing open source Code http://www.devosc.com Copyright (c) 2003 osCommerce Copyright (c) 2004 DevosC.com Released under the GNU General Public License */ function debugWriteFile($str,$mode="a") { $fp = @fopen("/home/admin/www/ipn.txt",$mode); @flock($fp, LOCK_EX); @fwrite($fp,$str); @flock($fp, LOCK_UN); @fclose($fp); } $postString = ''; foreach($_POST as $key => $val) $postString .= $key.' = '.$val."\n"; if($postString != '') { debugWriteFile("\n\n"); debugWriteFile($postString); } require_once('includes/modules/payment/paypal/application_top.inc.php'); require_once(DIR_WS_MODULES . 'payment/paypal/classes/IPN/IPN.class.php'); require_once(DIR_WS_MODULES . 'payment/paypal/classes/Debug/Debug.class.php'); require_once(DIR_WS_MODULES . 'payment/paypal/functions/general.func.php'); paypal_include_lng(DIR_WS_MODULES . 'payment/paypal/languages/', 'english', 'ipn.lng.php'); $debug = new PayPal_Debug(MODULE_PAYMENT_PAYPAL_IPN_DEBUG_EMAIL, MODULE_PAYMENT_PAYPAL_IPN_DEBUG); $ipn = new PayPal_IPN($_POST); $ipn->setTestMode(MODULE_PAYMENT_PAYPAL_IPN_TEST_MODE); unset($_POST); //post back to PayPal to validate // if(!$ipn->authenticate(MODULE_PAYMENT_PAYPAL_DOMAIN) && $ipn->testMode('Off')) $ipn->dienice('500'); //Check both the receiver_email and business ID fields match debugWriteFile("got here ok\n"); // if (!$ipn->validateReceiverEmail(MODULE_PAYMENT_PAYPAL_ID,MODULE_PAYMENT_PAYPAL_BUSINESS_ID)) $ipn->dienice('500'); debugWriteFile("and here\n"); $lengthof = strlen($ipn->key['txn_id']); debugWriteFile("txn_id length = ". $lengthof . "\n"); debugWriteFile("txn_id = ". $ipn->key['txn_id']. "\n"); debugWriteFile("this line 0\n"); if($ipn->uniqueTxnID() && $ipn->isReversal() && strlen($ipn->key['txn_id']) == 17) { debugWriteFile("this line\n"); //parent_txn_id is the txn_id of the original transaction $txn = $ipn->queryTxnID($ipn->key['txn_id']); debugWriteFile("txid = ". $txn. "\n"); if(!empty($txn)) { $ipn->insert($txn['paypal_id']); // update the order's status switch ($ipn->reversalType()) { case 'Canceled_Reversal': $order_status = MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID; break; case 'Reversed': $order_status = MODULE_PAYMENT_PAYPAL_ORDER_CANCELED_STATUS_ID; break; case 'Refunded': $order_status = MODULE_PAYMENT_PAYPAL_ORDER_REFUNDED_STATUS_ID; break; } $ipn->updateOrderStatus($txn['paypal_id'],$order_status); } } elseif ($ipn->isCartPayment() && !empty($PayPal_osC_Order->orderID)) { debugWriteFile("this loop instead\n"); //actually not essential since 'orders_status_name' is not required $languages_id = $PayPal_osC_Order->languageID; include(DIR_WS_CLASSES . 'order.php'); debugWriteFile("this line 1\n"); $order = new order($PayPal_osC_Order->orderID); //Check that txn_id has not been previously processed if ($ipn->uniqueTxnID()) { //Payment is either Completed, Pending or Failed debugWriteFile("this line 2\n"); $ipn->insert(); $PayPal_osC_Order->setOrderPaymentID($ipn->ID()); $PayPal_osC_Order->removeCustomersBasket($order->customer['id']); switch ($ipn->paymentStatus()) { case 'Completed': if ($ipn->validPayment($PayPal_osC_Order->payment_amount,$PayPal_osC_Order->payment_currency)) { include(DIR_WS_MODULES . 'payment/paypal/catalog/checkout_update.inc.php'); } else { $ipn->updateOrderStatus($ipn->ID(),MODULE_PAYMENT_PAYPAL_ORDER_ONHOLD_STATUS_ID); } break; case 'Failed': $ipn->updateOrderStatus($ipn->ID(),MODULE_PAYMENT_PAYPAL_ORDER_CANCELED_STATUS_ID); break; case 'Pending': //Assumed to do nothing since the order is initially in a Pending ORDER Status break; }//end switch } else { // not a unique transaction => Pending Payment debugWriteFile("this line 3\n"); //Assumes there is only one previous IPN transaction $pendingTxn = $ipn->queryPendingStatus($ipn->txnID()); if ($pendingTxn['payment_status'] === 'Pending') { $ipn->updateStatus($pendingTxn['paypal_id']); switch ($ipn->paymentStatus()) { case 'Completed': if ($ipn->validPayment($PayPal_osC_Order->payment_amount,$PayPal_osC_Order->payment_currency)) { include(DIR_WS_MODULES . 'payment/paypal/catalog/checkout_update.inc.php'); } else { $ipn->updateOrderStatus($pendingTxn['paypal_id'],MODULE_PAYMENT_PAYPAL_ORDER_ONHOLD_STATUS_ID); } break; case 'Denied': $ipn->updateOrderStatus($pendingTxn['paypal_id'],MODULE_PAYMENT_PAYPAL_ORDER_CANCELED_STATUS_ID); break; }//end switch }//end if Pending Payment } } elseif ($ipn->isAuction()) { if ($ipn->uniqueTxnID()) $ipn->insert(); if ($debug->enabled) $debug->add(PAYPAL_AUCTION,sprintf(PAYPAL_AUCTION_MSG)); } elseif ($ipn->txnType('send_money')) { if ($ipn->uniqueTxnID()) $ipn->insert(); if ($debug->enabled) $debug->add(PAYMENT_SEND_MONEY_DESCRIPTION,sprintf(PAYMENT_SEND_MONEY_DESCRIPTION_MSG,number_format($ipn->key['mc_gross'],2),$ipn->key['mc_currency'])); } elseif ($debug->enabled && $ipn->testMode('On')) { $debug->raiseError(TEST_INCOMPLETE,sprintf(TEST_INCOMPLETE_MSG),true); } if ($ipn->testMode('On') && $ipn->validDigest()) { include(DIR_WS_MODULES . 'payment/paypal/classes/Page/Page.class.php'); $page = new PayPal_Page(); $page->setBaseDirectory(DIR_WS_MODULES . 'payment/paypal/'); $page->setBaseURL(DIR_WS_MODULES . 'payment/paypal/'); $page->includeLanguageFile('admin/languages','english','paypal.lng.php'); $page->setTitle(HEADING_ITP_RESULTS_TITLE); $page->setContentFile(DIR_WS_MODULES . 'payment/paypal/admin/TestPanel/Results.inc.php'); $page->addCSS($page->baseURL . 'templates/css/general.css'); $page->addCSS($page->baseURL . 'templates/css/stylesheet.css'); $page->setTemplate('default'); include($page->template()); } require(DIR_WS_MODULES . 'payment/paypal/application_bottom.inc.php'); ?> Quote
ErichStauffer Posted January 4, 2012 Posted January 4, 2012 I fixed this issue by changing the HTTPS to "on" in the /includes/application_top.php file. I had changed the HTTPS to "off" instead of "on". I found where I changed it in the /includes/application_top.php file and changed it back. Paypal now redirects back to the shopping cart to allow the checkout process to continue. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.