/* -----------------------------------------------------------------------------------------
   $Id: paypalinstallment.php 10434 2016-11-23 15:54:02Z GTB $

   modified eCommerce Shopsoftware
   http://www.modified-shop.org

   Copyright (c) 2009 - 2013 [www.modified-shop.org]
   -----------------------------------------------------------------------------------------
   Released under the GNU General Public License
   ---------------------------------------------------------------------------------------*/
chdir('../../');
include 'includes/application_top.php';
// include needed classes
require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
if (isset($_GET['amount']) && is_numeric($_GET['amount']) && isset($_GET['country']) && $_GET['country'] == 'DE') {
    $paypal_installment = new PayPalPayment('paypalinstallment');
    if ($paypal_installment->enabled === true) {
        $presentment_array = $paypal_installment->get_presentment($_GET['amount'], isset($_GET['currency']) ? $_GET['currency'] : $_SESSION['currency'], $_GET['country']);
        $pp_smarty = new Smarty();
        $pp_smarty->assign('logo_image', xtc_image(DIR_WS_IMAGES . 'icons/pp_credit-german_v_rgb.png'));
        $pp_smarty->assign('tpl_path', DIR_WS_BASE . 'templates/' . CURRENT_TEMPLATE . '/');
        $pp_smarty->assign('html_params', TEMPLATE_HTML_ENGINE == 'xhtml' ? ' ' . HTML_PARAMS : ' lang="' . $_SESSION['language_code'] . '"');
        $pp_smarty->assign('doctype', TEMPLATE_HTML_ENGINE == 'xhtml' ? ' PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"' : '');
        $pp_smarty->assign('charset', $_SESSION['language_charset']);
        if (DIR_WS_BASE == '') {
            $pp_smarty->assign('base', ($request_type == 'SSL' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG);
        }
        $store_owner = explode("\n", STORE_NAME_ADDRESS);
        for ($i = 0, $n = count($store_owner); $i < $n; $i++) {
            if (trim($store_owner[$i]) == '') {
                unset($store_owner[$i]);
    if ($order->info['shipping_method']) {
        $smarty->assign('SHIPPING_METHOD', $order->info['shipping_method']);
    }
}
$order_total = $order->getTotalData($order->info['order_id']);
$smarty->assign('order_data', $order->getOrderData($order->info['order_id']));
$smarty->assign('order_total', $order_total['data']);
// Payment Method
if ($order->info['payment_method'] != '' && $order->info['payment_method'] != 'no_payment') {
    include DIR_WS_LANGUAGES . '/' . $_SESSION['language'] . '/modules/payment/' . $order->info['payment_method'] . '.php';
    $smarty->assign('PAYMENT_METHOD', constant('MODULE_PAYMENT_' . strtoupper($order->info['payment_method']) . '_TEXT_TITLE'));
}
## PayPal
if ($order->info['payment_method'] == 'paypallink' || $order->info['payment_method'] == 'paypalpluslink') {
    require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
    $paypal = new PayPalPayment($order->info['payment_method']);
    if ($paypal->get_config('MODULE_PAYMENT_' . strtoupper($order->info['payment_method']) . '_USE_ACCOUNT') == 1) {
        $button = $paypal->create_paypal_link($order->info['order_id']);
        if ($button != '') {
            $smarty->assign('PAYPAL_LINK', sprintf(constant('MODULE_PAYMENT_' . strtoupper($order->info['payment_method']) . '_TEXT_SUCCESS'), $button));
        }
        if ($messageStack->size($order->info['payment_method']) > 0) {
            $smarty->assign('info_message', $messageStack->output($order->info['payment_method']));
        }
    }
}
// Order History
$history_block = '';
//DokuMan - 2010-09-18 - set undefined variable
$statuses_query = xtc_db_query("-- /account_history_info.php\n                                SELECT os.orders_status_name,\n                                       osh.date_added,\n                                       osh.comments,\n                                       osh.comments_sent\n                                FROM " . TABLE_ORDERS_STATUS . " os,\n                                     " . TABLE_ORDERS_STATUS_HISTORY . " osh\n                                WHERE osh.orders_id = '" . $order->info['order_id'] . "'\n                                  AND osh.customer_notified = 1\n                                  AND osh.orders_status_id = os.orders_status_id\n                                  AND os.language_id = '" . (int) $_SESSION['languages_id'] . "'\n                                ORDER BY osh.date_added");
while ($statuses = xtc_db_fetch_array($statuses_query)) {
 function install()
 {
     parent::install();
     $stati = array('PAYPAL_INST_ORDER_STATUS_ACCEPTED_NAME' => 'PAYPAL_ORDER_STATUS_ACCEPTED_ID');
     $this->status_install($stati);
 }
 function __construct()
 {
     PayPalPayment::__construct('paypal');
 }
<?php

/* -----------------------------------------------------------------------------------------
   $Id$

   modified eCommerce Shopsoftware
   http://www.modified-shop.org

   Copyright (c) 2009 - 2013 [www.modified-shop.org]
   -----------------------------------------------------------------------------------------
   Released under the GNU General Public License
   ---------------------------------------------------------------------------------------*/
require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
$paypal_cart = new PayPalPayment('paypalcart');
if ($paypal_cart->enabled === true && $paypal_cart->get_config('MODULE_PAYMENT_' . strtoupper($paypal_cart->code) . '_SHOW_PRODUCT') == '1') {
    $info_smarty->assign('ADD_CART_BUTTON_PAYPAL', $paypal_cart->product_checkout_button());
}
$paypal_installment = new PayPalPayment('paypalinstallment');
require_once DIR_FS_INC . 'xtc_get_countries.inc.php';
$country = xtc_get_countriesList(isset($_SESSION['country']) ? $_SESSION['country'] : (isset($_SESSION['customer_country_id']) ? $_SESSION['customer_country_id'] : STORE_COUNTRY), true);
if ($paypal_installment->enabled === true && $country['countries_iso_code_2'] == 'DE') {
    $amount = $xtPrice->xtcGetPrice($product->data['products_id'], false, 1, $product->data['products_tax_class_id'], $product->data['products_price']);
    $presentment = $paypal_installment->get_presentment_details($amount, $_SESSION['currency'], $country['countries_iso_code_2'], 'product', true);
    $info_smarty->assign('PAYPAL_INSTALLMENT', $presentment);
}
    $smarty->assign('BUTTON_RELOAD', xtc_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART));
    $smarty->assign('BUTTON_CHECKOUT', '<a href="'.xtc_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL').'">'.xtc_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT).'</a>');
    */
    if (isset($_SESSION['paypal_warten'])) {
        $smarty->assign('info_message', $_SESSION['paypal_warten']);
        //Tomcraft - 2009-12-08 - fixed duplicate error messages in shopping cart
    } else {
        if (isset($_GET['info_message']) && xtc_not_null($_GET['info_message'])) {
            $smarty->assign('info_message', str_replace('+', ' ', encode_htmlspecialchars($_GET['info_message'])));
        }
        if (isset($o_paypal) && is_object($o_paypal)) {
            $smarty->assign('BUTTON_PAYPAL', $o_paypal->build_express_checkout_button());
        }
        ## PayPal
        require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
        $paypal_cart = new PayPalPayment('paypalcart');
        if ($paypal_cart->enabled === true) {
            $smarty->assign('BUTTON_PAYPAL', $paypal_cart->checkout_button());
            if (isset($_GET['payment_error'])) {
                include_once DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/paypalcart.php';
                $error = $paypal_cart->get_error();
                $smarty->assign('info_message', $error['error']);
            }
        }
        $smarty->assign('BUTTON_RELOAD', xtc_image_submit('button_update_cart.gif', IMAGE_BUTTON_UPDATE_CART));
        $smarty->assign('BUTTON_CHECKOUT', '<a href="' . xtc_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . xtc_image_button('button_checkout.gif', IMAGE_BUTTON_CHECKOUT) . '</a>');
    }
    // EOF - Tomcraft - 2009-10-03 - Paypal Express Modul
} else {
    // empty cart
    $cart_empty = true;
 function __construct()
 {
     global $order;
     PayPalPayment::__construct('paypalcart');
     $this->tmpOrders = true;
 }
 function __construct($class)
 {
     PayPalPayment::__construct($class);
 }
/* -----------------------------------------------------------------------------------------
   $Id$

   modified eCommerce Shopsoftware
   http://www.modified-shop.org

   Copyright (c) 2009 - 2013 [www.modified-shop.org]
   -----------------------------------------------------------------------------------------
   Released under the GNU General Public License
   ---------------------------------------------------------------------------------------*/
$paypal_payment_method = array('paypalplus', 'paypalclassic', 'paypalcart', 'paypallink', 'paypalpluslink');
if (is_object($order) && in_array($order->info['payment_method'], $paypal_payment_method)) {
    // include needed classes
    require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
    $paypal = new PayPalPayment($order->info['payment_method']);
    if (strpos($order->info['payment_method'], 'link') !== false) {
        $paypal_payment_info = array(array('title' => $paypal->title . ': ', 'class' => $paypal->code, 'fields' => array(array('title' => '', 'field' => sprintf(constant('MODULE_PAYMENT_' . strtoupper($paypal->code) . '_TEXT_SUCCESS'), $paypal->create_paypal_link($order->info['order_id']))))));
        $paypal_smarty = new Smarty();
        if (defined('RUN_MODE_ADMIN')) {
            $paypal_smarty->template_dir = DIR_FS_CATALOG . 'templates';
            $paypal_smarty->compile_dir = DIR_FS_CATALOG . 'templates_c';
            $paypal_smarty->config_dir = DIR_FS_CATALOG . 'lang';
        }
        $paypal_smarty->caching = 0;
        $paypal_smarty->assign('PAYMENT_INFO', $paypal_payment_info);
        $paypal_smarty->assign('language', $_SESSION['language']);
        $payment_info_content = $paypal_smarty->fetch(DIR_FS_EXTERNAL . 'paypal/templates/payment_info.html');
        $smarty->assign('PAYMENT_INFO_HTML', $payment_info_content);
        $smarty->assign('PAYMENT_INFO_TXT', sprintf(constant('MODULE_PAYMENT_' . strtoupper($paypal->code) . '_TEXT_SUCCESS'), $paypal->create_paypal_link($order->info['order_id'], true)));
    } else {
chdir('../../');
include 'includes/application_top.php';
// include needed classes
require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
if (isset($_GET['oID']) && is_numeric($_GET['oID']) && isset($_GET['key']) && strlen($_GET['key']) == '32') {
    // include needed function
    require_once DIR_FS_INC . 'set_customers_status_by_id.inc.php';
    // include needed classes
    require_once DIR_WS_CLASSES . 'order.php';
    $order = new order((int) $_GET['oID']);
    $hash = md5($order->customer['email_address']);
    if ($_GET['key'] == $hash) {
        if (!isset($_SESSION['customer_id'])) {
            set_customers_status_by_id($order->info['status']);
        }
        $paypal = new PayPalPayment('paypalpluslink');
        include_once DIR_WS_LANGUAGES . $order->info['language'] . '/modules/payment/paypalpluslink.php';
        // confirmed
        if (isset($_GET['PayerID']) && $_GET['PayerID'] != '' && isset($_GET['token']) && $_GET['token'] != '' && isset($_GET['paymentId']) && $_GET['paymentId'] != '' && $_GET['paymentId'] == $_SESSION['paypal']['paymentId']) {
            $_SESSION['paypal']['PayerID'] = $_GET['PayerID'];
            $insert_id = (int) $_GET['oID'];
            $paypal->complete_cart();
            if (isset($_SESSION['customer_id'])) {
                $messageStack->add_session('paypalpluslink', MODULE_PAYMENT_PAYPALPLUSLINK_TEXT_COMPLETED);
                xtc_redirect(xtc_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'info=1&order_id=' . (int) $_GET['oID'], 'SSL'));
            } else {
                $messageStack->add_session('logoff', MODULE_PAYMENT_PAYPALPLUSLINK_TEXT_COMPLETED);
                xtc_redirect(xtc_href_link(FILENAME_LOGOFF, 'info=1', 'SSL'));
            }
        } else {
            $approval = $paypal->payment_redirect(false, true, true);
 static function set_page_style($page_style)
 {
     self::$page_style = $page_style;
 }
   Copyright (c) 2009 - 2013 [www.modified-shop.org]
   -----------------------------------------------------------------------------------------
   Released under the GNU General Public License
   ---------------------------------------------------------------------------------------*/
chdir('../../');
include 'includes/application_top.php';
if (!isset($_SESSION['customer_id'])) {
    die('Currently not available');
}
if (isset($_GET['checkout']) && $_SESSION['payment'] == 'paypalplus') {
    echo '<script src="https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js" type="text/javascript"></script>' . "\n";
    echo '<script type="text/javascript">PAYPAL.apps.PPP.doCheckout();</script>' . "\n";
} elseif (isset($_SESSION['paypal']['approval'])) {
    require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
    $selection = get_third_party_payments();
    $paypal = new PayPalPayment('paypalplus');
    $module = array();
    if (ACTIVATE_GIFT_SYSTEM == 'true') {
        require_once DIR_WS_CLASSES . 'order_total.php';
        $order_total_modules = new order_total();
        $credit_selection = $order_total_modules->credit_selection();
    }
    if (!isset($credit_selection) || !is_array($credit_selection) || count($credit_selection) < 1) {
        for ($i = 0, $n = sizeof($selection); $i < $n; $i++) {
            $description = $paypal->get_config(strtoupper($selection[$i]['id'] . '_' . $_SESSION['language_code']));
            $module[] = array('redirectUrl' => $paypal->encode_utf8($paypal->link_encoding(xtc_href_link('callback/paypal/paypalplus_redirect.php', 'payment=' . $selection[$i]['id'], 'SSL'))), 'methodName' => $paypal->encode_utf8(strip_tags($selection[$i]['module'])), 'description' => $paypal->encode_utf8($description != '' ? $description : strip_tags($selection[$i]['description'])));
        }
    }
    $country_query = xtc_db_query("SELECT c.countries_iso_code_2\n                                   FROM " . TABLE_COUNTRIES . " c\n                                   JOIN " . TABLE_ADDRESS_BOOK . " ab\n                                        ON c.countries_id = ab.entry_country_id\n                                           AND address_book_id = '" . $_SESSION['customer_default_address_id'] . "'");
    $country = xtc_db_fetch_array($country_query);
    echo '<div id="ppplus"></div>';
   -----------------------------------------------------------------------------------------
   Released under the GNU General Public License
   ---------------------------------------------------------------------------------------*/
chdir('../../');
include 'includes/application_top.php';
// include needed functions
require_once DIR_FS_INC . 'get_external_content.inc.php';
// include needed classes
require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
// get request
$request_input = get_external_content('php://input', 3, false);
// get params
parse_str($request_input, $request);
$request['cmd'] = '_notify-validate';
// set payment
$paypal = new PayPalPayment('paypal');
// get transaction
$transaction = $paypal->get_transaction($request['txn_id']);
// set endpoint
$paypal_url = "https://www.paypal.com/cgi-bin/webscr";
if ($paypal->get_config('PAYPAL_MODE') == 'sandbox') {
    $paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
}
// validate
$ch = curl_init($paypal_url);
if ($ch === false) {
    header("HTTP/1.0 404 Not Found");
    header("Status: 404 Not Found");
    exit;
}
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
   $Id$

   modified eCommerce Shopsoftware
   http://www.modified-shop.org

   Copyright (c) 2009 - 2013 [www.modified-shop.org]
   -----------------------------------------------------------------------------------------
   Released under the GNU General Public License
   ---------------------------------------------------------------------------------------*/
chdir('../../');
include 'includes/application_top.php';
// include needed functions
require_once DIR_FS_INC . 'get_external_content.inc.php';
// include needed classes
require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
$request_json = get_external_content('php://input', 3, false);
$request = json_decode($request_json, true);
$check_query = xtc_db_query("SELECT p.orders_id,\n                                    o.orders_status\n                               FROM " . TABLE_PAYPAL_PAYMENT . " p\n                               JOIN " . TABLE_ORDERS . " o\n                                    ON o.orders_id = p.orders_id\n                              WHERE p.payment_id = '" . xtc_db_input($request['resource']['parent_payment']) . "'");
if (xtc_db_num_rows($check_query) > 0) {
    $check = xtc_db_fetch_array($check_query);
    $paypal = new PayPalPayment('paypal');
    $orders_status_id = $paypal->get_config($request['event_type']);
    if ($orders_status_id < 0) {
        $orders_status_id = $check['orders_status'];
    }
    $paypal->update_order($request['summary'], $orders_status_id, $check['orders_id']);
} else {
    // order is missing
    header("HTTP/1.0 404 Not Found");
    header("Status: 404 Not Found");
}
/* -----------------------------------------------------------------------------------------
   $Id$

   modified eCommerce Shopsoftware
   http://www.modified-shop.org

   Copyright (c) 2009 - 2013 [www.modified-shop.org]
   -----------------------------------------------------------------------------------------
   Released under the GNU General Public License
   ---------------------------------------------------------------------------------------*/
chdir('../../');
include 'includes/application_top.php';
// include needed classes
require_once DIR_WS_CLASSES . 'order.php';
require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
$paypal = new PayPalPayment('paypalcart');
$paypal->validate_payment_paypalcart();
if (!isset($_SESSION['customer_id'])) {
    xtc_redirect(xtc_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'));
}
// shipping
$_SESSION['shipping'] = '';
$order = new order();
if ($order->content_type == 'virtual' || $order->content_type == 'virtual_weight' || $_SESSION['cart']->count_contents_virtual() == 0) {
    $_SESSION['shipping'] = false;
    $_SESSION['sendto'] = false;
}
// payment
$_SESSION['payment'] = 'paypalcart';
// billto
$_SESSION['billto'] = $_SESSION['customer_default_address_id'];
                } else {
                    $_SESSION['cart']->add_cart($_GET['pid'], $_SESSION['cart']->get_quantity($_GET['pid']) + 1);
                }
            }
            xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params($parameters), 'NONSSL'));
            break;
            // BOF - Tomcraft - 2011-02-01 - Paypal Express Modul
        // BOF - Tomcraft - 2011-02-01 - Paypal Express Modul
        case 'paypal_express_checkout':
            if (defined('MODULE_PAYMENT_PAYPALEXPRESS_STATUS') && MODULE_PAYMENT_PAYPALEXPRESS_STATUS == 'True') {
                if (!is_object($product)) {
                    require_once DIR_WS_CLASSES . 'product.php';
                    $product = new product();
                }
                $o_paypal->paypal_express_auth_call();
                xtc_redirect($o_paypal->payPalURL);
            }
            break;
            // EOF - Tomcraft - 2011-02-01 - Paypal Express Modul
            ## Paypal
        // EOF - Tomcraft - 2011-02-01 - Paypal Express Modul
        ## Paypal
        case 'paypal_cart_checkout':
            if (defined('MODULE_PAYMENT_PAYPALCART_STATUS') && MODULE_PAYMENT_PAYPALCART_STATUS == 'True') {
                require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
                $paypal_cart = new PayPalPayment('paypalcart');
                $paypal_cart->payment_redirect(true);
            }
            break;
    }
}
 function __construct()
 {
     global $order;
     PayPalPayment::__construct('paypalpluslink');
     $this->tmpOrders = false;
 }
chdir('../../');
include 'includes/application_top.php';
// include needed classes
require_once DIR_FS_EXTERNAL . 'paypal/classes/PayPalPayment.php';
if (isset($_GET['oID']) && is_numeric($_GET['oID']) && isset($_GET['key']) && strlen($_GET['key']) == '32') {
    // include needed function
    require_once DIR_FS_INC . 'set_customers_status_by_id.inc.php';
    // include needed classes
    require_once DIR_WS_CLASSES . 'order.php';
    $order = new order((int) $_GET['oID']);
    $hash = md5($order->customer['email_address']);
    if ($_GET['key'] == $hash) {
        if (!isset($_SESSION['customer_id'])) {
            set_customers_status_by_id($order->info['status']);
        }
        $paypal = new PayPalPayment('paypallink');
        include_once DIR_WS_LANGUAGES . $order->info['language'] . '/modules/payment/paypallink.php';
        // confirmed
        if (isset($_GET['PayerID']) && $_GET['PayerID'] != '' && isset($_GET['token']) && $_GET['token'] != '' && isset($_GET['paymentId']) && $_GET['paymentId'] != '' && $_GET['paymentId'] == $_SESSION['paypal']['paymentId']) {
            $_SESSION['paypal']['PayerID'] = $_GET['PayerID'];
            $insert_id = (int) $_GET['oID'];
            $paypal->complete_cart();
            if (isset($_SESSION['customer_id'])) {
                $messageStack->add_session('paypallink', MODULE_PAYMENT_PAYPALLINK_TEXT_COMPLETED);
                xtc_redirect(xtc_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'info=1&order_id=' . (int) $_GET['oID'], 'SSL'));
            } else {
                $messageStack->add_session('logoff', MODULE_PAYMENT_PAYPALLINK_TEXT_COMPLETED);
                xtc_redirect(xtc_href_link(FILENAME_LOGOFF, 'info=1', 'SSL'));
            }
        } else {
            if (!isset($_GET['payment_error'])) {