DevosC, Developing open source Code
http://www.devosc.com

Copyright (c) 2003 osCommerce
Copyright (c) 2004 DevosC.com
Copyright (c) 2006 Dipl.-Ing.(TH) Winfried Kaiser (w.kaiser@fortune.de) -- Port to OL-Commerce

Released under the GNU General Public License
*/
include DIR_WS_CLASSES . 'order.php';
$order = new order($HTTP_GET_VARS['oID']);
require_once PAYPAL_IPN_DIR . 'Admin/languages/' . $language . '/paypal.lng.php';
require_once PAYPAL_IPN_DIR . 'Classes/TransactionDetails/TransactionDetails.class.php';
$paypal = new PayPal_TransactionDetails(TABLE_PAYPAL, $order->info['payment_id']);
if ($HTTP_GET_VARS['digest'] != $paypal->digest()) {
    $messageStack->add_session(ERROR_UNAUTHORIZED_REQUEST);
} elseif ($paypal->info['payment_status'] === 'Completed' && $order->info['orders_status'] === MODULE_PAYMENT_PAYPAL_ORDER_ONHOLD_STATUS_ID) {
    include PAYPAL_IPN_DIR . 'Functions/addressbook.func.php';
    include PAYPAL_IPN_DIR . 'Classes/osC/Order.class.php';
    $PayPal_osC_Order = new PayPal_osC_Order();
    $PayPal_osC_Order->setOrderID($HTTP_GET_VARS['oID']);
    $PayPal_osC_Order->loadOrdersSessionInfo();
    //$currency = $PayPal_osC_Order->currency;
    $PayPal_osC_Order->setAccountHistoryInfoURL(olc_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $PayPal_osC_Order->orderID, 'SSL', false));
    $PayPal_osC_Order->setCheckoutProcessLanguageFile(DIR_FS_CATALOG_LANGUAGES . $PayPal_osC_Order->language . '/' . 'checkout_process.php');
    $PayPal_osC_Order->updateProducts($order, $currencies);
    $PayPal_osC_Order->notifyCustomer($order);
    $affiliate_ref = $PayPal_osC_Order->affiliate_id;
    $affiliate_clickthroughs_id = $PayPal_osC_Order->affiliate_clickthroughs_id;
    $affiliate_clientdate = $PayPal_osC_Order->affiliate_date;
            $phColor = $phCount / 2 == floor($phCount / 2) ? '#FFFFFF' : '#EEEEEE';
            $mc_currency = $paypal_history['mc_currency'] . HTML_NBSP;
            $mc_gross = $paypal_history['mc_gross'];
            $mc_fee = $paypal_history['mc_fee'];
            echo '			          <tr bgcolor="' . $phColor . '">' . NEW_LINE . ' 	           		<td nowrap="nowrap">&nbsp;' . $paypal->date($paypal_history['payment_date']) . '&nbsp;</td>' . NEW_LINE . '   	         		<td nowrap="nowrap">&nbsp;' . $paypal_history['payment_status'] . '&nbsp;</td>' . NEW_LINE . '     	       		<td nowrap="nowrap">&nbsp;' . PayPal_Page::draw_href_link(TABLE_HEADING_DETAILS, 'action=details&info=' . $paypal_history['txn_id']) . '&nbsp;
									</td>' . NEW_LINE . '      	    		 	<td nowrap="nowrap">&nbsp;</td>' . NEW_LINE . '		            	<td nowrap="nowrap" align="right">&nbsp;' . $paypal->format($mc_gross, $mc_currency) . '
									</td>' . NEW_LINE . '		   		        <td nowrap="nowrap" align="right">&nbsp;' . $paypal->format($mc_fee, $mc_currency) . '
									</td>' . NEW_LINE . '       			    <td nowrap="nowrap" align="right">&nbsp;' . $paypal->format($mc_gross - $mc_fee, $mc_currency) . '
 									</td>' . NEW_LINE . '          			</tr>' . NEW_LINE;
            $phCount++;
        }
    }
    //Now determine whether the order is on hold
    if ($order->info['orders_status'] === MODULE_PAYMENT_PAYPAL_ORDER_ONHOLD_STATUS_ID) {
        $ppImgAccept = olc_image(PAYPAL_IPN_DIR . 'images/act_accept.gif', IMAGE_BUTTON_TXN_ACCEPT);
        $ppAction = HTML_A_START . olc_href_link(FILENAME_ORDERS, olc_get_all_get_params(array('action')) . 'action=accept_order&digest=' . $paypal->digest()) . '">' . $ppImgAccept . HTML_A_END;
    } else {
        $ppAction = '';
    }
    $mc_currency = $paypal->txn['mc_currency'];
    $mc_gross = $paypal->txn['mc_gross'];
    $mc_fee = $paypal->txn['mc_fee'];
    ?>
	          		<tr bgcolor="#FFFFFF">
			            <td nowrap="nowrap">&nbsp;<?php 
    echo $paypal->date($paypal->info['payment_date']);
    ?>
&nbsp;</td>
			            <td nowrap="nowrap">&nbsp;<?php 
    echo $paypal->info['payment_status'];
    ?>