/** * Combination of functions escapeSql() and convertEncoding() */ function escapeConvert($string, $to) { return HelperFunctions::escapeSql(HelperFunctions::convertEncoding($string, $to)); }
exit; } switch (getDownloadMethod()) { case 'file_get_contents': $agb = file_get_contents($url); break; case 'curl': $agb = handleCurlDownload($url); break; default: $agb = handleSocketDownload($url); break; } $matches = array(); preg_match("/<\\!-- content -->.*<\\!-- \\/content -->/s", $agb, $matches); echo HelperFunctions::convertEncoding($matches[0], 1, 'ISO-8859-15'); function santiyCheck($url) { if (strpos('aaaa' . $url, 'https://documents.sofort.com') == 4) { return true; } return false; } function getDownloadMethod() { if (ini_get('allow_url_fopen')) { $method = 'file_get_contents'; } elseif (function_exists('curl_init')) { $method = 'curl'; } else { $method = 'socket';
/** * send data to SOFORT and check SOFORT-response - overwriten by Rbs-Modul * @return array with paymentUrl, api-errors, trans-id, payment-secret */ function _makeSofortApiCall() { global $order, $xtPrice; $customer_id = $_SESSION['customer_id']; $currency = $_SESSION['currency']; $reasons = $this->_getReasons($this->paymentMethod, $customer_id, $order); $user_variable_0 = ''; $user_variable_1 = $customer_id; /* $session = session_name() . '=' . session_id(); if (ENABLE_SSL == true) $server = HTTPS_SERVER; else $server = HTTP_SERVER; */ $paymentSecret = md5(mt_rand() . microtime()); //important notice: following lines also modify the shippingcosts $orderTotals = array(); if (MODULE_ORDER_TOTAL_INSTALLED) { require_once DIR_WS_CLASSES . 'order_total.php'; $orderTotalModules = new order_total(); //Following function-call manipulates variables (e.g. prices) within $order! Never call more than once! $orderTotals = $orderTotalModules->process(); } $amount = $this->_getShopTotal($orderTotals); //$success_url = $server.DIR_WS_CATALOG.'callback/sofort/ressources/scripts/sofortReturn.php?sofortaction=success&sofortcode='.$this->code; //$cancel_url = $server.DIR_WS_CATALOG.'callback/sofort/ressources/scripts/sofortReturn.php?sofortaction=cancel&sofortcode='.$this->code; //$notification_url = $server . DIR_WS_CATALOG . 'callback/sofort/callback.php?paymentSecret='.$paymentSecret.'&action=multipay'; $success_url = xtc_href_link('callback/sofort/ressources/scripts/sofortReturn.php', 'sofortaction=success&sofortcode=' . $this->code, 'SSL'); $cancel_url = xtc_href_link('callback/sofort/ressources/scripts/sofortReturn.php', 'sofortaction=cancel&sofortcode=' . $this->code, 'SSL'); $notification_url = xtc_href_link('callback/sofort/callback.php', 'paymentSecret=' . $paymentSecret . '&action=multipay', 'SSL'); $this->sofort->setAmount($amount, $currency); $this->sofort->setReason(HelperFunctions::convertEncoding($reasons[0], 3), HelperFunctions::convertEncoding($reasons[1], 3)); $this->sofort->setSuccessUrl(HelperFunctions::convertEncoding($success_url, 4)); $this->sofort->setAbortUrl(HelperFunctions::convertEncoding($cancel_url, 4)); $this->sofort->setTimeoutUrl(HelperFunctions::convertEncoding($cancel_url, 4)); $this->sofort->setNotificationUrl(HelperFunctions::convertEncoding($notification_url, 4)); $this->sofort->addUserVariable(HelperFunctions::convertEncoding($user_variable_0, 3)); $this->sofort->addUserVariable(HelperFunctions::convertEncoding($user_variable_1, 3)); $this->sofort->setEmailCustomer(HelperFunctions::convertEncoding($order->customer['email_address'], 3)); $this->sofort->setPhoneNumberCustomer($order->customer['telephone']); switch ($this->paymentMethod) { case 'SU': $this->sofort->setSofortueberweisung($amount); // see if customer protection is enabled, set it as parameter to sofortlib $this->sofort->setSofortueberweisungCustomerprotection(MODULE_PAYMENT_SOFORT_SU_KS_STATUS == 'True'); break; case 'SL': $this->sofort->setSofortlastschrift(); $this->sofort->setSenderAccount('', '', HelperFunctions::convertEncoding($order->customer['firstname'], 3) . ' ' . HelperFunctions::convertEncoding($order->customer['lastname'], 3)); break; case 'LS': $this->sofort->setLastschrift(); $this->sofort->setSenderAccount(HelperFunctions::convertEncoding($_SESSION['sofort']['ls_bank_code'], 3), HelperFunctions::convertEncoding($_SESSION['sofort']['ls_account_number'], 3), HelperFunctions::convertEncoding($_SESSION['sofort']['ls_sender_holder'], 3)); $billingSalutation = $this->_getGenderFromAddressBook($order->billing['firstname'], $order->billing['lastname'], $order->billing['company'], $order->billing['street_address'], $order->billing['postcode'], $order->billing['city'], $order->billing['country_id'], $order->billing['zone_id']); //split street and number if (!preg_match('#(.+)[ .](.+)#i', trim($order->billing['street_address']), $streetparts)) { $streetparts = array(); $streetparts[1] = trim($order->billing['street_address']); $streetparts[2] = ''; } //if there is an entry in "suburb" (german: "Adresszusatz"), put it in front of the streetname if ($order->billing['suburb']) { $streetparts[1] = $order->billing['suburb'] . ' - ' . $streetparts[1]; } $this->sofort->setLastschriftAddress(HelperFunctions::convertEncoding($order->billing['firstname'], 3), HelperFunctions::convertEncoding($order->billing['lastname'], 3), HelperFunctions::convertEncoding($streetparts[1], 3), HelperFunctions::convertEncoding($streetparts[2], 3), $order->billing['postcode'], HelperFunctions::convertEncoding($order->billing['city'], 3), HelperFunctions::convertEncoding($billingSalutation, 3), HelperFunctions::convertEncoding($order->billing['country']['iso_code_2'], 3)); break; case 'SV': $this->sofort->setSofortvorkasse(); // if this is called a 'test transaction', add a sender account if (getenv('test_sv') == true) { $this->sofort->setSenderAccount('00000', '12345', 'Tester Testaccount'); } $this->sofort->setSofortvorkasseCustomerprotection(MODULE_PAYMENT_SOFORT_SV_KS_STATUS == 'True'); break; } $this->sofort->sendRequest(); $return = array(); $return['apiCallErrors'] = $this->sofort->getErrors(); $return['paymentUrl'] = $this->sofort->getPaymentUrl(); $return['transactionId'] = $this->sofort->getTransactionId(); $return['paymentSecret'] = $paymentSecret; $return['orderTotalModules'] = $orderTotalModules; $return['orderTotals'] = $orderTotals; return $return; }
/** * add discounts or agio (e.g. ot_sofort, loworderfee, discount...) to $this->invoice */ function _addPriceModificatorsToInvoice($customer_id, $orderTotals) { //check optional price-modificators if (is_array($orderTotals)) { foreach ($orderTotals as $totalModule) { $itemId = 'discount|' . substr($totalModule['code'], 0, 22); if ($totalModule['code'] == 'ot_sofort') { $tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_SOFORT_TAX_CLASS); $amountValue = $totalModule['value']; $this->invoice->addItemToInvoice($itemId, '', HelperFunctions::convertEncoding(html_entity_decode($totalModule['title'], ENT_QUOTES, HelperFunctions::getIniValue('shopEncoding')), 3), $amountValue, 2, '', 1, $tax); continue; } if ($totalModule['code'] == 'ot_discount') { $tax = 19; $amountValue = $totalModule['value'] > 0 ? $totalModule['value'] * -1 : $totalModule['value']; $this->invoice->addItemToInvoice($itemId, '', HelperFunctions::convertEncoding(html_entity_decode($totalModule['title'], ENT_QUOTES, HelperFunctions::getIniValue('shopEncoding')), 3), $amountValue, 2, '', 1, $tax); continue; } if ($totalModule['code'] == 'ot_gv') { $tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_GV_TAX_CLASS); $amountValue = $totalModule['value'] > 0 ? $totalModule['value'] * -1 : $totalModule['value']; $this->invoice->addItemToInvoice($itemId, '', HelperFunctions::convertEncoding(html_entity_decode($totalModule['title'], ENT_QUOTES, HelperFunctions::getIniValue('shopEncoding')), 3), $amountValue, 2, '', 1, $tax); continue; } if ($totalModule['code'] == 'ot_coupon') { $tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_COUPON_TAX_CLASS); $amountValue = $totalModule['value'] > 0 ? $totalModule['value'] * -1 : $totalModule['value']; $this->invoice->addItemToInvoice($itemId, '', HelperFunctions::convertEncoding(html_entity_decode($totalModule['title'], ENT_QUOTES, HelperFunctions::getIniValue('shopEncoding')), 3), $amountValue, 2, '', 1, $tax); continue; } $itemId = 'agio|' . substr($totalModule['code'], 0, 26); if ($totalModule['code'] == 'ot_loworderfee') { $tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS); $amountValue = $totalModule['value']; $this->invoice->addItemToInvoice($itemId, '', HelperFunctions::convertEncoding(html_entity_decode($totalModule['title'], ENT_QUOTES, HelperFunctions::getIniValue('shopEncoding')), 3), $amountValue, 2, '', 1, $tax); continue; } } } }
/** * insert article in shop order (e.g. during an undo operation) * @param object $sofortItem * @param int $ordersId * @param string $lng */ protected function _insertShopOrderArticle($sofortItem, $ordersId, $lng) { $itemId = $sofortItem->itemId; $splitItemId = explode('{', $itemId); $productId = $splitItemId[0]; if (count($splitItemId) == '1') { $hasAttributes = false; } else { $hasAttributes = true; for ($i = 1; $i < count($splitItemId); ++$i) { $attrId = explode('}', $splitItemId[$i]); $attributes[] = array('optionsId' => $attrId[0], 'optionsValuesId' => $attrId[1]); } } $data = array('orders_id' => $ordersId, 'products_id' => $productId, 'products_model' => $sofortItem->productNumber, 'products_name' => HelperFunctions::convertEncoding($sofortItem->title, 2), 'products_price' => $sofortItem->unitPrice, 'final_price' => $sofortItem->unitPrice * $sofortItem->quantity, 'products_tax' => $sofortItem->tax, 'products_quantity' => $sofortItem->quantity, 'allow_tax' => '1'); shopDbPerform(TABLE_ORDERS_PRODUCTS, $data); $insertId = xtc_db_insert_id(); shopDbQuery('UPDATE sofort_products SET orders_products_id ="' . $insertId . '" WHERE orders_id = "' . $ordersId . '" AND item_id = "' . $itemId . '"'); if ($hasAttributes) { $lngId = shopDbFetchArray(shopDbQuery("SELECT languages_id FROM " . TABLE_LANGUAGES . " WHERE code = '" . $lng . "'")); foreach ($attributes as $attribute) { $queryTpa = shopDbQuery("SELECT options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id ='" . $productId . "' AND options_id = '" . $attribute['optionsId'] . "' AND options_values_id ='" . $attribute['optionsValuesId'] . "'"); $resultTpa = shopDbFetchArray($queryTpa); $queryTpo = shopDbQuery("SELECT products_options_name FROM " . TABLE_PRODUCTS_OPTIONS . " WHERE products_options_id = '" . $attribute['optionsId'] . "' AND language_id = '" . $lngId['languages_id'] . "'"); $resultTpo = shopDbFetchArray($queryTpo); $queryTpov = shopDbQuery("SELECT products_options_values_name FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " WHERE products_options_values_id = '" . $attribute['optionsValuesId'] . "' AND language_id = '" . $lngId['languages_id'] . "'"); $resultTpov = shopDbFetchArray($queryTpov); $data = array('orders_id' => $ordersId, 'orders_products_id' => $insertId, 'products_options' => $resultTpo['products_options_name'], 'products_options_values' => $resultTpov['products_options_values_name'], 'options_values_price' => $resultTpa['options_values_price'], 'price_prefix' => $resultTpa['price_prefix']); shopDbPerform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $data); } } }