Example #1
0
 /**
  * Constructor
  * @global object $objTemplate
  */
 function __construct($pageContent)
 {
     $this->pageContent = $pageContent;
     $this->_objTpl = new \Cx\Core\Html\Sigma('.');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
     $this->_objTpl->setErrorHandling(PEAR_ERROR_DIE);
     $this->mediaPath = ASCMS_MARKET_MEDIA_PATH . '/';
     $this->mediaWebPath = ASCMS_MARKET_MEDIA_WEB_PATH . '/';
     //get settings
     $this->settings = $this->getSettings();
     //check community modul
     $objModulManager = new \Cx\Core\ComponentManager\Controller\ComponentManager();
     $arrInstalledModules = $objModulManager->getModules();
     if (in_array(23, $arrInstalledModules)) {
         $this->communityModul = true;
     } else {
         $this->communityModul = false;
     }
     //ipn Check
     if (isset($_GET['act'])) {
         switch ($_GET['act']) {
             case "paypalIpnCheck":
                 $objPaypal = new \PayPal();
                 $objPaypal->ipnCheck();
                 exit;
                 break;
             default:
                 //nothging
                 break;
         }
     }
 }
Example #2
0
 /**
  * Returns the Shop page for the present parameters
  * @param   string  $template     The page template
  * @return  string                The page content
  */
 static function getPage($template)
 {
     //\DBG::activate(DBG_ERROR_FIREPHP);
     //\DBG::activate(DBG_LOG_FILE);
     self::init();
     self::registerJavascriptCode();
     // PEAR Sigma template
     self::$objTemplate = new \Cx\Core\Html\Sigma('.');
     self::$objTemplate->setErrorHandling(PEAR_ERROR_DIE);
     self::$objTemplate->setTemplate($template);
     // Global module index for clones
     self::$objTemplate->setGlobalVariable('MODULE_INDEX', MODULE_INDEX);
     // Do this *before* calling our friends, especially Customer methods!
     // Pick the default Country for delivery
     if (empty($_SESSION['shop']['countryId2'])) {
         $_SESSION['shop']['countryId2'] = isset($_POST['countryId2']) ? intval($_POST['countryId2']) : \Cx\Core\Setting\Controller\Setting::getValue('country_id', 'Shop');
     }
     // TODO: This should be set up in a more elegant way
     Vat::is_reseller(self::$objCustomer && self::$objCustomer->is_reseller());
     // The coupon code may be set when entering the Shop already
     if (isset($_REQUEST['coupon_code'])) {
         global $sessionObj;
         if (!$sessionObj) {
             $sessionObj = \cmsSession::getInstance();
         }
         $_SESSION['shop']['coupon_code'] = trim(strip_tags(contrexx_input2raw($_REQUEST['coupon_code'])));
         //\DBG::log("Coupon Code: Set to ".$_SESSION['shop']['coupon_code']);
     }
     //\DBG::log("Shop::getPage(): Entered");
     // Global placeholders that are used on (almost) all pages.
     // Add more as desired.
     self::$objTemplate->setGlobalVariable(array('SHOP_CURRENCY_CODE' => Currency::getActiveCurrencyCode(), 'SHOP_CURRENCY_SYMBOL' => Currency::getActiveCurrencySymbol()));
     if (!isset($_GET['cmd'])) {
         $_GET['cmd'] = '';
     }
     if (!isset($_GET['act'])) {
         $_GET['act'] = $_GET['cmd'];
     }
     switch ($_GET['act']) {
         case 'shipment':
             self::showShipmentTerms();
             break;
         case 'success':
             self::success();
             break;
         case 'confirm':
             self::confirm();
             break;
         case 'lsv':
         case 'lsv_form':
             self::view_lsv_form();
             break;
         case 'payment':
             self::payment();
             break;
         case 'account':
             self::view_account();
             break;
         case 'cart':
             self::cart();
             break;
         case 'discounts':
             self::discounts();
             break;
         case 'login':
             self::login();
             break;
         case 'paypalIpnCheck':
             // OBSOLETE -- Handled by PaymentProcessing::checkIn() now
             $objPaypal = new \PayPal();
             $objPaypal->ipnCheck();
             exit;
         case 'sendpass':
             self::view_sendpass();
             break;
         case 'changepass':
             self::_changepass();
             break;
             // Test for PayPal IPN.
             // *DO NOT* remove this!  Needed for site testing.
         // Test for PayPal IPN.
         // *DO NOT* remove this!  Needed for site testing.
         case 'testIpn':
             \PayPal::testIpn();
             // die()s!
             // Test for PayPal IPN validation
             // *DO NOT* remove this!  Needed for site testing.
         // die()s!
         // Test for PayPal IPN validation
         // *DO NOT* remove this!  Needed for site testing.
         case 'testIpnValidate':
             \PayPal::testIpnValidate();
             // die()s!
             // Test mail body generation
             // *DO NOT* remove this!  Needed for site testing.
         // die()s!
         // Test mail body generation
         // *DO NOT* remove this!  Needed for site testing.
         case 'testMail':
             // Test with
             // http://localhost/contrexx_300/de/index.php?section=Shop&act=testMail&key=&order_id=5
             //MailTemplate::errorHandler();die();
             $order_id = !empty($_GET['order_id']) ? $_GET['order_id'] : 10;
             $key = !empty($_GET['key']) ? $_GET['key'] : 'order_confirmation';
             $arrSubstitution = Orders::getSubstitutionArray($order_id);
             $customer_id = $arrSubstitution['CUSTOMER_ID'];
             $objCustomer = Customer::getById($customer_id);
             if (!$objCustomer) {
                 die("Failed to get Customer for ID {$customer_id}");
                 return false;
             }
             $arrSubstitution += $objCustomer->getSubstitutionArray($customer_id) + self::getSubstitutionArray();
             $arrMailTemplate = array('section' => 'Shop', 'key' => $key, 'lang_id' => $arrSubstitution['LANG_ID'], 'substitution' => &$arrSubstitution, 'to' => '*****@*****.**');
             \DBG::activate(DBG_LOG_FIREPHP);
             //                DBG::activate(DBG_LOG_FILE);
             die(nl2br(contrexx_raw2xhtml(var_export($arrMailTemplate, true))));
             //                DBG::log(MailTemplate::send($arrMailTemplate) ? "Sent successfully" : "Sending FAILED!");
             //                DBG::deactivate(DBG_LOG_FILE);
             break;
         case 'testAttachment':
             \Cx\Core\MailTemplate\Controller\MailTemplate::send(array('from' => '*****@*****.**', 'to' => '*****@*****.**', 'subject' => 'Test Attachment', 'message' => 'Test', 'attachments' => array(0 => 'images/content/banner/qualidator.gif', 'images/content/banner/itnews.gif' => 'Sch�nes Bild')));
             die("Done!");
         case 'pricelist':
             self::send_pricelist();
             break;
         case 'terms':
             // Static content only (fttb)
             break;
             // TODO: Add Order history view (see History.class.php)
             //            case 'history':
             //                self::view_history();
             //                break;
         // TODO: Add Order history view (see History.class.php)
         //            case 'history':
         //                self::view_history();
         //                break;
         case 'destroy':
             self::destroyCart();
             // TODO: Experimental
             //                self::destroyCart(true);
             // No break on purpose
         // TODO: Experimental
         //                self::destroyCart(true);
         // No break on purpose
         case 'lastFive':
         case 'products':
         default:
             self::view_product_overview();
     }
     // Note that the Shop Navbar *MUST* be set up *after* the request
     // has been processed, otherwise the cart info won't be up to date!
     self::setNavbar();
     // TODO: Set the Messages in the global template instead when that's ready
     \Message::show(self::$objTemplate);
     //\DBG::deactivate();
     return self::$objTemplate->get();
 }
 /**
  * Check in the payment processor after the payment is complete.
  * @return  mixed   For external payment methods:
  *                  The integer order ID, if known, upon success
  *                  For internal payment methods:
  *                  Boolean true, in order to make these skip the order
  *                  status update, as this has already been done.
  *                  If the order ID is unknown or upon failure:
  *                  Boolean false
  */
 static function checkIn()
 {
     //DBG::log("PaymentProcessing::checkIn(): Entered");
     //DBG::log("POST: ".var_export($_POST, true));
     //DBG::log("GET: ".var_export($_GET, true));
     $result = NULL;
     if (isset($_GET['result'])) {
         $result = abs(intval($_GET['result']));
         if ($result == 0 || $result == 2) {
             return false;
         }
     }
     if (empty($_REQUEST['handler'])) {
         return false;
     }
     switch ($_REQUEST['handler']) {
         case 'paymill_cc':
         case 'paymill_elv':
         case 'paymill_iban':
             $arrShopOrder = array('order_id' => $_SESSION['shop']['order_id'], 'amount' => intval(bcmul($_SESSION['shop']['grand_total_price'], 100, 0)), 'currency' => Currency::getActiveCurrencyCode(), 'note' => $_SESSION['shop']['note']);
             $response = \PaymillHandler::processRequest($_REQUEST['paymillToken'], $arrShopOrder);
             \DBG::log(var_export($response, true));
             if ($response['status'] === 'success') {
                 return true;
             } else {
                 \DBG::log("PaymentProcessing::checkIn(): WARNING: paymill: Payment verification failed; errors: " . var_export($response, true));
                 return false;
             }
         case 'saferpay':
             $arrShopOrder = array('ACCOUNTID' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_id', 'Shop'));
             $id = \Saferpay::payConfirm();
             if (\Cx\Core\Setting\Controller\Setting::getValue('saferpay_finalize_payment', 'Shop')) {
                 $arrShopOrder['ID'] = $id;
                 $id = \Saferpay::payComplete($arrShopOrder);
             }
             //DBG::log("Transaction: ".var_export($transaction, true));
             return (bool) $id;
         case 'paypal':
             if (empty($_POST['custom'])) {
                 //DBG::log("PaymentProcessing::checkIn(): No custom parameter, returning NULL");
                 return NULL;
             }
             $order_id = \PayPal::getOrderId();
             //                    if (!$order_id) {
             //                        $order_id = (isset($_SESSION['shop']['order_id'])
             //                            ? $_SESSION['shop']['order_id']
             //                            : (isset ($_SESSION['shop']['order_id_checkin'])
             //                                ? $_SESSION['shop']['order_id_checkin']
             //                                : NULL));
             //                    }
             $order = Order::getById($order_id);
             $amount = $currency_id = $customer_email = NULL;
             if ($order) {
                 $amount = $order->sum();
                 $currency_id = $order->currency_id();
                 $customer_id = $order->customer_id();
                 $customer = Customer::getById($customer_id);
                 if ($customer) {
                     $customer_email = $customer->email();
                 }
             }
             $currency_code = Currency::getCodeById($currency_id);
             return \PayPal::ipnCheck($amount, $currency_code, $order_id, $customer_email, \Cx\Core\Setting\Controller\Setting::getValue('paypal_account_email', 'Shop'));
         case 'yellowpay':
             $passphrase = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_hash_signature_out', 'Shop');
             return \Yellowpay::checkIn($passphrase);
             //                    if (\Yellowpay::$arrError || \Yellowpay::$arrWarning) {
             //                        global $_ARRAYLANG;
             //                        echo('<font color="red"><b>'.
             //                        $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_YELLOWPAY'].
             //                        '</b><br />'.
             //                        'Errors:<br />'.
             //                        join('<br />', \Yellowpay::$arrError).
             //                        'Warnings:<br />'.
             //                        join('<br />', \Yellowpay::$arrWarning).
             //                        '</font>');
             //                    }
         //                    if (\Yellowpay::$arrError || \Yellowpay::$arrWarning) {
         //                        global $_ARRAYLANG;
         //                        echo('<font color="red"><b>'.
         //                        $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_YELLOWPAY'].
         //                        '</b><br />'.
         //                        'Errors:<br />'.
         //                        join('<br />', \Yellowpay::$arrError).
         //                        'Warnings:<br />'.
         //                        join('<br />', \Yellowpay::$arrWarning).
         //                        '</font>');
         //                    }
         case 'payrexx':
             return \PayrexxProcessor::checkIn();
             // Added 20100222 -- Reto Kohli
         // Added 20100222 -- Reto Kohli
         case 'mobilesolutions':
             // A return value of null means:  Do not change the order status
             if (empty($_POST['state'])) {
                 return null;
             }
             $result = \PostfinanceMobile::validateSign();
             if ($result) {
                 //DBG::log("PaymentProcessing::checkIn(): mobilesolutions: Payment verification successful!");
             } else {
                 DBG::log("PaymentProcessing::checkIn(): WARNING: mobilesolutions: Payment verification failed; errors: " . var_export(\PostfinanceMobile::getErrors(), true));
             }
             return $result;
             // Added 20081117 -- Reto Kohli
         // Added 20081117 -- Reto Kohli
         case 'datatrans':
             return \Datatrans::validateReturn() && \Datatrans::getPaymentResult() == 1;
             // For the remaining types, there's no need to check in, so we
             // return true and jump over the validation of the order ID
             // directly to success!
             // Note: A backup of the order ID is kept in the session
             // for payment methods that do not return it. This is used
             // to cancel orders in all cases where false is returned.
         // For the remaining types, there's no need to check in, so we
         // return true and jump over the validation of the order ID
         // directly to success!
         // Note: A backup of the order ID is kept in the session
         // for payment methods that do not return it. This is used
         // to cancel orders in all cases where false is returned.
         case 'internal':
         case 'internal_creditcard':
         case 'internal_debit':
         case 'internal_lsv':
             return true;
             // Dummy payment.
         // Dummy payment.
         case 'dummy':
             $result = '';
             if (isset($_REQUEST['result'])) {
                 $result = $_REQUEST['result'];
             }
             // Returns the order ID on success, false otherwise
             return \Dummy::commit($result);
         default:
             break;
     }
     // Anything else is wrong.
     return false;
 }