require dirname(__FILE__) . '/sofortbanking.php'; $order_state = Configuration::get('SOFORTBANKING_OS_ERROR'); $cart = new Cart((int) Tools::getValue('user_variable_1')); if (class_exists('Context')) { if (empty(Context::getContext()->link)) { Context::getContext()->link = new Link(); } Context::getContext()->language = new Language($cart->id_lang); Context::getContext()->currency = new Currency($cart->id_currency); } $sofortbanking = new Sofortbanking(); /* If valid hash, set order state as accepted */ if (is_object($cart) && Tools::getValue('hash') == sha1(Tools::getValue('user_variable_1') . Configuration::get('SOFORTBANKING_PROJECT_PW'))) { $order_state = Configuration::get('SOFORTBANKING_OS_ACCEPTED'); } $customer = new Customer((int) $cart->id_customer); /* Validate this card in store if needed */ if (!Order::getOrderByCartId($cart->id) && ($order_state == Configuration::get('SOFORTBANKING_OS_ACCEPTED') || $order_state == Configuration::get('SOFORTBANKING_OS_ERROR'))) { $sofortbanking->validateOrder($cart->id, $order_state, (double) number_format($cart->getOrderTotal(true, 3), 2, '.', ''), $sofortbanking->displayName, null, null, null, false, $customer->secure_key, null); Configuration::updateValue('SOFORTBANKING_CONFIGURATION_OK', true); } $order_id = Order::getOrderByCartId($cart->id); $order = new Order($order_id); /* Init Frontend variables for redirect */ $controller = new FrontController(); $controller->init(); if (version_compare(_PS_VERSION_, '1.5', '>=')) { Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $order->id_cart . '&id_module=' . $sofortbanking->id . '&id_order=' . $order_id . '&key=' . $order->secure_key); } else { Tools::redirect('order-confirmation.php?id_cart=' . $order->id_cart . '&id_module=' . $sofortbanking->id . '&id_order=' . $order_id . '&key=' . $order->secure_key); }
if (empty(Context::getContext()->link)) { Context::getContext()->link = new Link(); } Context::getContext()->language = new Language($cart->id_lang); Context::getContext()->currency = new Currency($cart->id_currency); } $sofortbanking = new Sofortbanking(); /* If valid hash, set order state as accepted */ if (is_object($cart) && Tools::getValue('hash') == sha1(implode('|', $request))) { $order_state = Configuration::get('SOFORTBANKING_OS_ACCEPTED'); } $customer = new Customer($cart->id_customer); /* Validate this card in store if needed */ if ($order_state == Configuration::get('SOFORTBANKING_OS_ACCEPTED') && Configuration::get('SOFORTBANKING_OS_ACCEPTED_IGNORE') != 'Y' || $order_state == Configuration::get('SOFORTBANKING_OS_ERROR') && Configuration::get('SOFORTBANKING_OS_ERROR_IGNORE') != 'Y') { if (!Order::getOrderByCartId($cart->id)) { $sofortbanking->validateOrder($cart->id, $order_state, (double) number_format($cart->getOrderTotal(true, 3), 2, '.', ''), $sofortbanking->displayName, $sofortbanking->l('Directebanking transaction id: ') . Tools::getValue('transaction'), null, null, false, $customer->secure_key, null); } else { $order = new Order(Order::getOrderByCartId($cart->id)); if ($order->getCurrentState() != $order_state) { $history = new OrderHistory(); $history->id_order = $order->id; $history->changeIdOrderState($order_state, $order->id); $history->addWithemail(true); /* Add private order message for seller */ $message = new Message(); $message->message = $sofortbanking->l('Change order state by SOFORT notification for transaction id: ') . Tools::getValue('transaction'); $message->private = 1; $message->id_order = $order->id; $message->add(); } }