devosc Posted April 4, 2004 Author Share Posted April 4, 2004 Thanks Mark, I forgot about that one. "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
devosc Posted April 4, 2004 Author Share Posted April 4, 2004 Ah crap, you STS lot should probably do the same in catalog/ipn.php "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
Thomas67 Posted April 4, 2004 Share Posted April 4, 2004 Thanks Greg, but it works also without it ;) Â Nice Sunday evening, write here next time..... Â Â Kind Regards from German. Regards from Germany... Link to comment Share on other sites More sharing options...
Kraven_UK Posted April 4, 2004 Share Posted April 4, 2004 Works fine without untill Paypal sends a IPN response. Â I've changed it anyhow. Link to comment Share on other sites More sharing options...
Thomas67 Posted April 4, 2004 Share Posted April 4, 2004 A little question: Â If payment is success, in Adminmen? I have seen, that the Status of this Order is set from "Pending Payment (Database = 3)" to "Waiting (Database = 1)". Â But the customer can't download the article, because Status must be "Deallocation (Database = 4)". Â What can I do ??? Regards from Germany... Link to comment Share on other sites More sharing options...
Kraven_UK Posted April 4, 2004 Share Posted April 4, 2004 (edited) Here is a small change to the posted code for catalog/includes/modules/payment/paypal/checkout_process.php require(DIR_WS_INCLUDES . 'application_bottom.php'); Should be replaced with // close session (store variables) tep_session_close(); if (STORE_PAGE_PARSE_TIME == 'true') { ? $time_start = explode(' ', PAGE_PARSE_START_TIME); ? $time_end = explode(' ', microtime()); ? $parse_time = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3); ? error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' - ' . getenv('REQUEST_URI') . ' (' . $parse_time . 's)' . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); ? if (DISPLAY_PAGE_PARSE_TIME == 'true') { ? ? echo '<span class="smallText">Parse Time: ' . $parse_time . 's</span>'; ? } } if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded == true) && ($ini_zlib_output_compression < 1) ) { ? if ( (PHP_VERSION < '4.0.4') && (PHP_VERSION >= '4') ) { ? ? tep_gzip_output(GZIP_LEVEL); ? } } Just taken the php tags out :lol: Â Thanks to Greg and Thomas67 for the eBeer. Edited April 4, 2004 by Kraven_UK Link to comment Share on other sites More sharing options...
devosc Posted April 4, 2004 Author Share Posted April 4, 2004 Hi there, Â Mark, smart thinking, actually there little mistake on my behalf, because process.tpl.php has application_bottom.php at the bottom of that file too, and because it is included just before the application_bottom.php in paypal/checkout_process.php means it is being called twice. I would remove the application_bottom.php from paypal/checkout_process.php and let the application_bottom.php in process.tpl.php handle (remember the tags though) especially since application_bottom.php has: Â if (DISPLAY_PAGE_PARSE_TIME == 'true') { Â Â echo '<span class="smallText">Parse Time: ' . $parse_time . 's</span>'; Â } Which should only displayed if there is any html output, which is what process.tpl.php is for. Â Thomas are you using a Downloader Contrib, what happens or rather what has been assumed by the paypal contrib is that one the payment has been made is that it's status is then updated to the store's default status which I think in your case is 'waiting'. Uhmm, if this is the case some extra stuff will need to happen, I think it easiest if there is another status select option in the admin->payment-paypal config so that you specify what the Download Status should be be. "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
Kraven_UK Posted April 4, 2004 Share Posted April 4, 2004 Yep, that did it. I took out all references to application_bottom.php from paypal/checkout_process.php I then replaced the <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> in paypal/process.tpl.php with <?php // close session (store variables) tep_session_close(); if (STORE_PAGE_PARSE_TIME == 'true') { Â $time_start = explode(' ', PAGE_PARSE_START_TIME); Â $time_end = explode(' ', microtime()); Â $parse_time = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3); Â error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' - ' . getenv('REQUEST_URI') . ' (' . $parse_time . 's)' . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); Â if (DISPLAY_PAGE_PARSE_TIME == 'true') { Â Â echo '<span class="smallText">Parse Time: ' . $parse_time . 's</span>'; Â } } if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded == true) && ($ini_zlib_output_compression < 1) ) { Â if ( (PHP_VERSION < '4.0.4') && (PHP_VERSION >= '4') ) { Â Â tep_gzip_output(GZIP_LEVEL); Â } } ?> Link to comment Share on other sites More sharing options...
Guest Posted April 5, 2004 Share Posted April 5, 2004 (edited) Greg, Thanks for the info on ipn.html testing a couple pages back. Installed into /catalog/ and it tests good, only still nothing shows up in orders.  Debug emails arrive; Order Process emails arrive, showing a link to the order placed (which does not exist when logging in to the cart). Also: (SQL) paypal_ipn --shows content paypal_ipn_orders --shows content orders_status_history --shows content w/ the orders_id# I used (happens to be 15) orders_total --does not show the #15 order_id orders_session_info --empty  Admin: paypal IPN in test mode debug at 2 emails are correct all other settings per your docs (auto return ON, IPN on + blank URL).  Just wondering, does test mode post the order into the cart, or is no order in test mode normal? :blink:  Sure would like to figure this one out. If any more info is needed, please advise. (2.0 version) --Jeff Edited April 5, 2004 by snuff Link to comment Share on other sites More sharing options...
devosc Posted April 5, 2004 Author Share Posted April 5, 2004 Hi Jeff, Â When you say the order is not in the cart, do you mean cart or Account History, it won't be in the cart but in the account history. Â Sounds like things went ok, not sure why you would a problem in live, mode, what are your email config settings? is your Primary PayPal email address the same as your Business ID, how many email accounts have you configured in your PayPal account profile? There is a debig email that lets you know the configuration settings. each one should match each corresponding field. Â You somewhat do need to find a way to make a live test. "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
Guest Posted April 5, 2004 Share Posted April 5, 2004 Hi Greg, Â First off, thanks for a great contrib...you also did an excellent job on the documentation which is a relief. Â So I am trying to do a test transaction and using the tip you posted above using the ipn.html file. Good thing I did this as I found a problem with the contrib. Probably specific to me but might be useful for others. Â I am running a version of osc that does not use the filenames.php or database_tables.php files. This data is found in my application_top.php file. Anyways, when I tried to run the ipn.html file, it obviously created and error because of the two lines in the /includes/modules/payment/paypal/application_top.php call the filenames.php and database_tables.php. Â My first reaction was the comment those out and simply require MY version of application_top.php located in my includes folder. That obviously caused a bunch of errors of redeclaring functions so I went ahead and commented out all the statements in YOUR application_top.php file. Â then I hit a snag in your code where set_language is not a function I have with my version of osc. Â I know there is probably an easier way. Can you recommend an easy way to scale back that file and make it compatible with my version? Also, I only use one language on my store so do I really need all the code for language? this might make it really easy for me. Â can you think of other parts of your code that will die because of the version of osc I am using? Link to comment Share on other sites More sharing options...
devosc Posted April 5, 2004 Author Share Posted April 5, 2004 Hi Rodney  In the contrib application_top.php change $lng = new language(); $lng->set_language($language); To $lng = new language($language); I can't be sure about other issues untill an error msg pops up. "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
Guest Posted April 5, 2004 Share Posted April 5, 2004 Hi Rodney In the contrib application_top.php change $lng = new language(); $lng->set_language($language); To $lng = new language($language); I can't be sure about other issues untill an error msg pops up. no dice...well progress but another related error:  Fatal error: Cannot instantiate non-existent class: language  Do we need all the language code? If it's constant can't I just take care of this section that way? Link to comment Share on other sites More sharing options...
Guest Posted April 5, 2004 Share Posted April 5, 2004 ok...well I hacked it enough to get through.... I just received 4 emails... Â 1- Debug info 2- paypal response: invalid 3- transaction ID 4- IPN 1 inserted..... Â I might've missed this earlier in the thread but does this mean it worked? Everything looks like it worked....except the paypal response which I assume is because I am either in TEST mode or because I never completed the transaction (paid myself)? Â ok, something I just noticed, now it changed that order (#368) to a different status....and not the one I want.... where is this setting? not in the admin is it? Â pretty slick if this works.... Link to comment Share on other sites More sharing options...
Guest Posted April 5, 2004 Share Posted April 5, 2004 Hi Jeff, When you say the order is not in the cart, do you mean cart or Account History, it won't be in the cart but in the account history.  Sounds like things went ok, not sure why you would a problem in live, mode, what are your email config settings? is your Primary PayPal email address the same as your Business ID, how many email accounts have you configured in your PayPal account profile? There is a debig email that lets you know the configuration settings. each one should match each corresponding field.  You somewhat do need to find a way to make a live test. I suppose clarification is better than second guessing... Cart, meaning anywhere in admin of osC. Since the ipn.html I ran didn't reference a "user account" it didn't post a purchase back into any "user's cart" or account. It does show up in order_status_history but nowhere else, and since It didn't originate from a user account I can't go look into that user's history.  I did originally try "live" settings with a customer who was willing to help by repeat "purchase/refund" cycles. I guess I'll have to resume that. However, up until now, I got debugs and paypal IPN emails, but nothing showed up in his orders, history, anywhere, and nothing showed up in admin: paypal IPN, orders, etc. It's like it never posted back to my osC from paypal.  Emails: I do have 3 or so emails tied to the account. It is not (yet) a "business" account. Does this matter? The primary email (snuff@) is not the same as the working email (order@). The settings in modules:payment:paypal are order@ for all 3, and I do successfully get debugs (this order: debug, Order Process, Email and Business ID config, Invalid, IPN INSERTED). All debug emails show the working (order@) email.  I'll resume once again with live testing, will post back any problems or successes. Also, real quick, is it recommended to edit for the the application_bottom/checkout_process issue mentioned just back a bit?  TIA-- --Jeff Link to comment Share on other sites More sharing options...
helohelo Posted April 5, 2004 Share Posted April 5, 2004 Hi there,is it possible to use this ipn contri with requiring billing from paypal? Sorry maybe its in this thread somewehere and I overlooked it? Anyone? Anyone? Keesjan Link to comment Share on other sites More sharing options...
devosc Posted April 5, 2004 Author Share Posted April 5, 2004 Rodney, once a 'Completed' IPN has been received it is then updated to the store's default order status, seems like this now needs to be revised, i.e. in the paypal config, there should be another slect option for you to choose what status it should go to, but then might need to be another if that product is a Download; I didn't want to hard code an order Status for the initial 'Pending Payment'. You would get an invalid response becasue your in test mode. Otherwise you seem ok. Â 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. Â helohelo, no sorry. "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
helohelo Posted April 5, 2004 Share Posted April 5, 2004 And will there be some in the future, plans? Keesjan Link to comment Share on other sites More sharing options...
spib Posted April 5, 2004 Share Posted April 5, 2004 Hi Greg,  I'm having real problems getting this working. I'm using a modified 2.2MS2 installation with Paypal IPN 2.0. IPN is enabled at paypal as is autoreturn.  The user can checkout no problem. They are auto-returned to my site correctly and the checkout_success.php page shows the correct details for their order.  However, the order remains in state 'Pending Payment'. The only emails I receive are one from the buyer (via paypal) to say the payment was made. I also receive 3 or so identical debug emails like this  ------------------------------------------------------ PayPal ORIGINAL POST ------------------------------------------------------ txn_type=cart payment_date=03:42:22 Apr 05, 2004 PDT last_name=Spibey payment_gross= mc_currency=GBP [email protected] payment_type=instant num_cart_items=1 payer_status=verified verify_sign=AsXE9E09mkfnZJv1zekutIasjwXLAK91ajMMbzg-q68z6yZeAICkF8Bi [email protected] tax=0.00 txn_id=89U5897588871734S first_name=James [email protected] payer_id=EERK6KN4JY6FY receiver_id=UJ2NKM8MRJRBE payment_status=Completed payment_fee= mc_fee=0.01 mc_gross=0.01 item_name1=Red XXL custom=11 item_number1= notify_version=1.6 quantity1=1 tax1=0.00 ------------------------------------------------------ PayPal Reconstructed Post ------------------------------------------------------ cmd=_notify-validate txn_type=cart payment_date=03%3A42%3A22+Apr+05%2C+2004+PDT last_name=Spibey payment_gross= mc_currency=GBP business=paypal%40xxx.co.uk payment_type=instant num_cart_items=1 payer_status=verified verify_sign=AsXE9E09mkfnZJv1zekutIasjwXLAK91ajMMbzg-q68z6yZeAICkF8Bi payer_email=xxxxxx%40hotmail.com tax=0.00 txn_id=89U5897588871734S first_name=James receiver_email=paypal%40xxxx.co.uk payer_id=EERK6KN4JY6FY receiver_id=UJ2NKM8MRJRBE payment_status=Completed payment_fee= mc_fee=0.01 mc_gross=0.01 item_name1=Red+XXL custom=11 item_number1= notify_version=1.6 quantity1=1 tax1=0.00   I also sometimes receive an email which says  An unknown POST from 64.4.241.140 was received. Are you running any tests?  Do you any suggestions for what could be wrong? Link to comment Share on other sites More sharing options...
devosc Posted April 5, 2004 Author Share Posted April 5, 2004 James, try this post and see what happens, if your checkout_process.php hs been modifie then these modifications will also have to occur in paypal/checkout_process.php and paypal/checkout_update.php where appropiate. Â The unkown post is when someone posts or trys to access the catalog/ipn.php script which generally due to a none related PayPal post and should not really occur especially in live mode, I wouldn't worry for now. Â Maybe post your catalog/checkout_process.php script here and we might be able to spot something. "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
Guest Posted April 5, 2004 Share Posted April 5, 2004 Hi Greg, Â Thanks for this Wonderful Contribution. Great Work. Â I have this problem... Â After adding items to the shopping cart and clicking check out, a new window pops up which also lead to the paypal page. 2 dublicated orders than appear in the orders report. Â Can you tell me how to stop a new window from poping up. Â Thanks Link to comment Share on other sites More sharing options...
spib Posted April 5, 2004 Share Posted April 5, 2004 Thanks for the prompt reply :)  As far as I can see, the only difference between the stock checkout_process.php and mine is that I have modified it to add a second address line. I made the appropriate changes in the paypal/* pages.  I also tried the test you suggested. When I tried it I got a 'Page Cannot Be Displayed' error. I'm not convinced that the information I entered into the form was correct. Here's the debug email for it  ------------------------------------------------------ PayPal ORIGINAL POST ------------------------------------------------------ [email protected] [email protected] [email protected] [email protected] custom=12 txn_type=cart txn_id=0FR37403YM0784849 payment_type=instant pending_reason=echeck mc_currency=USD mc_gross=0.01 mc_fee=0.01 payment_gross=0.01 payment_fee=0.01 payment_status=Completed num_cart_items=1 item_name=Hewlett Packard LaserJet 1100Xi item_number=HPLJ1100XI quantity=1 tax=0.00 payer_id= payment_date=13:13:57 Dec 29, 2003 PST first_name= last_name= address_owner=1 payer_status=unverified address_name= address_status=confirmed address_street= address_zip= address_city= address_state= address_country=US payer_email= memo= verify_sign=AW8SkcPa3mwZiYJL0zQRQs-RtU1tAqvna2-iADXH6fjFpqQeug0YK3tD ebay_address_id= notify_version=1.5 submit=submit transaction  Obviously something is wrong with the ipn.php file. Any clues on how to debug it?  My checkout_process.php follows  <?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('sendto')) {   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');  $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'],              // Second Address Field mod:              'customers_street_address_2' => $order->customer['street_address_2'],              // :Second Address Field mod              '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'],              'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'],              'delivery_company' => $order->delivery['company'],              'delivery_street_address' => $order->delivery['street_address'],              // Second Address Field mod:              'delivery_street_address_2' => $order->delivery['street_address_2'],              // :Second Address Field mod              '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'],     // Second Address Field mod:              'billing_street_address_2' => $order->billing['street_address_2'],              // :Second Address Field mod              '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'],              '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_quantity' => $order->products[$i]['qty']);   tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);   $order_products_id = tep_db_insert_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);     $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";  } // 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');  tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));  require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Link to comment Share on other sites More sharing options...
spib Posted April 5, 2004 Share Posted April 5, 2004 Upon further inspection, it looks like the ipn->authenticate() method is causing the problems. Â I wrote a simple page with only the curl code in it and that didn't work either. The code for that is below. Â $paypal_response = ''; $_response_string = 'cmd=_notify-validate'; $ch = @curl_init(); @curl_setopt($ch, CURLOPT_URL, "https://www.paypal.com/cgi-bin/webscr"); @curl_setopt($ch, CURLOPT_POST, 1); @curl_setopt($ch, CURLOPT_POSTFIELDS, $_response_string); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @curl_setopt($ch, CURLOPT_HEADER, 0); @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); @curl_setopt($ch, CURLOPT_TIMEOUT, 60); $paypal_response = @curl_exec($ch); @curl_close($ch); echo $paypal_response; Â My curl info from phpinfo() Â CURL support enabled CURL Information libcurl/7.10.5 OpenSSL/0.9.6b zlib/1.1.4 Link to comment Share on other sites More sharing options...
Guest Posted April 5, 2004 Share Posted April 5, 2004 Rodney, once a 'Completed' IPN has been received it is then updated to the store's default order status, seems like this now needs to be revised, i.e. in the paypal config, there should be another slect option for you to choose what status it should go to, but then might need to be another if that product is a Download; I didn't want to hard code an order Status for the initial 'Pending Payment'. You would get an invalid response becasue your in test mode. Otherwise you seem ok. Awesome! Â Here's what I do with the order status. When I receive an order, it either gets a staus of "Order received by CC" or "Order received by Paypal". I do this for many reasons. Once I verify the payment is valid, I place the order with a warehouse. At that point I change the status to "Order processed. Waiting for Shipping" regardless of the type of payment. Then once again, once an order ships, I change the status to "Order Shipped". Â With the contrib right now, when the order is received, I see it under "Order received by Paypal". Once it processes, it goes to "Order Received by Credit Card" which is not correct. Â I guess I could live with it but might try to hack the code to correct this before i go live! Â Great Contrib...now switching from test mode to live mode! :) Link to comment Share on other sites More sharing options...
devosc Posted April 5, 2004 Author Share Posted April 5, 2004 To create another order status specifically for paypal in modules/payment/paypal.php in the install function add: 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 Updated Order Status', 'MODULE_PAYMENT_PAYPAL_ORDER_STATUS_UPDATE_ID', '0', 'Set the updated status of orders made with this payment module to this value', '6', '21', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())"); Â Now in function keys add: MODULE_PAYMENT_PAYPAL_ORDER_STATUS_UPDATE_ID, Just after 'MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID,' (note the commas). Â Now in modules/payment/paypal/checkout_update.php replace 'DEFAULT_ORDERS_STATUS_ID' with 'MODULE_PAYMENT_PAYPAL_ORDER_STATUS_UPDATE_ID' (there are 2 instances) Â I haven't tested it but thats roughly what needs to be done, uninstall the paypal module in the admin and reinstall should now see this extra order status field that will be assigned when the order status is Updated. Â spib, that curl stuff works, it should return 'INVALID', in either case the way the script is designed is that if it doesn't work it will then try a socket connect, and if that don't work it will try fopen, note there is an error in the one for httpS those 2 lines should be: $fp = @fopen('https://'.$domain.'/cgi-bin/webscr?'.$this->_response_string); $paypal_response = @fgets($fp, 1024); @fclose($fp); here the '@' suppresses any errors so it will cascade through untill the it finally attempts 'http' "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
Recommended Posts