public function initContent() { $this->display_column_left = false; $this->display_column_right = false; parent::initContent(); global $smarty; if (isset($_GET['order_id'])) { $cart = Cart::getCartByOrderId($_GET['order_id']); if ($cart == null) { die; } } else { global $cart; } $address = new Address((int) $cart->id_address_invoice); $customer = new Customer((int) $cart->id_customer); $amount = $cart->getOrderTotal(true, Cart::BOTH); $przelewy24 = new Przelewy24(); $currencies = $przelewy24->getCurrency(intval($cart->id_currency)); $currency = $currencies[0]; if (isset($currency['decimals']) && $currency['decimals'] == '0') { if (Configuration::get('PS_PRICE_ROUND_MODE') != null) { switch (Configuration::get('PS_PRICE_ROUND_MODE')) { case 0: $amount = ceil($amount); break; case 1: $amount = floor($amount); break; case 2: $amount = round($amount); break; } } } $amount = number_format($amount, 2, '.', '') * 100; $s_sid = md5(time()); Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'przelewy24_amount` ' . '(`s_sid`,`i_id_order`,`i_amount`) ' . 'VALUES("' . $s_sid . '",' . $cart->id . ',' . $amount . ')'); $s_lang = new Country((int) $address->id_country); $order = Order::getOrderByCartId($cart->id); if ($order == null) { $s_descr = ''; $validationRequired = true; } else { $s_descr = 'Zamówienie: ' . $order; $validationRequired = false; } $url = 'secure.przelewy24.pl'; if (Configuration::get('P24_TEST_MODE') == 1) { if (Configuration::get('P24_TEST_MODE_TRANSACTION') == 1) { $url = 'sandbox.przelewy24.pl'; } else { $url = 'sandbox.przelewy24.pl'; $s_descr = 'TEST_ERR102'; } } $smarty->assign(array('productsNumber' => $cart->nbProducts(), 'ps_version' => _PS_VERSION_, 'p24_url' => $url, 'p24_session_id' => $cart->id . '|' . $s_sid, 'p24_id_sprzedawcy' => Configuration::get('P24_ID_SPRZEDAWCY'), 'p24_kwota' => $amount, 'p24_opis' => $s_descr, 'p24_klient' => $customer->firstname . ' ' . $customer->lastname, 'p24_adres' => $address->address1 . " " . $address->address2, 'p24_kod' => $address->postcode, 'p24_miasto' => $address->city, 'p24_language' => strtolower($s_lang->iso_code), 'p24_kraj' => $s_lang->iso_code, 'p24_email' => $customer->email, 'p24_metoda' => Tools::getValue('payment_method'), 'p24_return_url_ok' => $this->context->link->getModuleLink('przelewy24', 'paymentSuccessful'), 'p24_return_url_error' => $this->context->link->getModuleLink('przelewy24', 'paymentFailed'), 'p24_validationRequired' => $validationRequired)); $this->setTemplate('paymentConfirmation.tpl'); }
public function hookPayment() { global $smarty, $cart; $amount = $cart->getOrderTotal(true, Cart::BOTH); $protocol = Przelewy24::getHttpProtocol(); $smarty->assign('p24_url', $protocol . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__); $smarty->assign('p24_url_payment', $this->context->link->getModuleLink('przelewy24', 'paymentConfirmation')); $smarty->assign('p24_url_installment', $this->context->link->getModuleLink('przelewy24', 'paymentConfirmation', array('payment_method' => '129'))); if ($amount >= 300) { $smarty->assign('p24_installment_show', Configuration::get('P24_INSTALLMENT_SHOW')); } return $this->display(__FILE__, 'payment.tpl'); }
<?php /** * Created by michalz on 14.03.14 */ include dirname(__FILE__) . '/../../../config/config.inc.php'; include dirname(__FILE__) . '/../../../init.php'; include dirname(__FILE__) . '/../przelewy24.php'; if ($_POST['p24_session_id'] != null) { global $cart; $przelewy24 = new Przelewy24(); $sessionID = explode('|', $_POST["p24_session_id"]); $sessionID = preg_replace('/[^a-z0-9]/i', '', $sessionID[1]); $orderPrzelewy24 = Db::getInstance()->getRow('SELECT `i_id_order`,`i_amount` FROM `' . _DB_PREFIX_ . 'przelewy24_amount` WHERE `s_sid`="' . $sessionID . '"'); $amountGrosh = $orderPrzelewy24['i_amount']; // w groszach! $cartID = $orderPrzelewy24['i_id_order']; $orderBeginingState = Configuration::get('P24_ORDER_STATE_1'); $customer = new Customer((int) $cart->id_customer); $result = $przelewy24->validateOrder((int) $cartID, (int) $orderBeginingState, $amountGrosh, 'przelewy24.pl', NULL, array(), NULL, false, $customer->secure_key); $orderID = Order::getOrderByCartId(intval($cartID)); exit('OK' . $orderID); } else { exit('INVALID_SESSION_ID'); }