1: <?php
2: /**
3: *
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * or OpenGPL v3 license (GNU Public License V3.0)
9: * that is bundled with this package in the file LICENSE.txt.
10: * It is also available through the world-wide-web at this URL:
11: * http://opensource.org/licenses/osl-3.0.php
12: * or
13: * http://www.gnu.org/licenses/gpl-3.0.txt
14: * If you did not receive a copy of the license and are unable to
15: * obtain it through the world-wide-web, please send an email
16: * to info@e-abi.ee so we can send you a copy immediately.
17: *
18: * DISCLAIMER
19: *
20: * Do not edit or add to this file if you wish to upgrade this module to newer
21: * versions in the future.
22: *
23: * @category Eabi
24: * @package Eabi_Dpd
25: * @copyright Copyright (c) 2014 Aktsiamaailm LLC (http://en.e-abi.ee/)
26: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27: * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28: * @author Matis Halmann
29: *
30:
31: */
32:
33:
34: /**
35: * <p>Handles all actions when customer has chosen DPD COD has payment and has confirmed the order</p>
36: */
37: class dpdcodpaymentValidationModuleFrontController extends ModuleFrontController {
38:
39:
40: public function initContent() {
41: $this->display_column_left = true;
42:
43: parent::initContent();
44:
45: }
46:
47: /**
48: *
49: */
50: public function postProcess() {
51: $cart = $this->context->cart;
52: $customer = new Customer($cart->id_customer);
53: if (!Validate::isLoadedObject($customer)) {
54: Tools::redirect('index.php?controller=order&step=1');
55: }
56:
57: $currency = $this->context->currency;
58:
59: if (!$this->module->checkCurrency($cart)) {
60: Tools::redirect('index.php?controller=order');
61: }
62: // $this->context->cart->codFee = 10;
63: $cart->codFee = $this->module->getCodFee($cart);
64:
65:
66: $total = floatval(number_format($cart->getOrderTotal(true, Cart::BOTH), 2, '.', ''));
67:
68: $mailVars = array(
69: '{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'),
70: '{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')),
71: '{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS')),
72: );
73:
74: $bankwire = new dpdcodpayment();
75: $key = dpdcodpayment::CONST_PREFIX . 'ORDER_STATUS';
76:
77: $orderStatus = Configuration::get($key);
78: $bankwire->validateOrder($cart->id, $orderStatus, $total, $bankwire->displayName, NULL, $mailVars, $currency->id, false, $cart->secure_key);
79: // Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
80:
81: $order = new Order(intval($bankwire->currentOrder));
82:
83: // payment successful, send to confirmation page instead
84: Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $order->reference . '&key=' . $cart->secure_key);
85: }
86:
87: }