/** * Display payment instruction for cash or transfer payments */ public function initContent() { $this->display_column_left = false; parent::initContent(); $errorMessage = NULL; if (Tools::getValue('order_id')) { $this->context->cart = Cart::getCartByOrderId(Tools::getValue('order_id')); $this->initPersonalData(); } $channel = $this->context->cookie->dotpay_channel; unset($this->context->cookie->dotpay_channel); DotpayRegisterOrder::init($this); $payment = DotpayRegisterOrder::create($channel); if ($payment === NULL) { $instruction = DotpayInstruction::getByOrderId(Tools::getValue('order_id')); if (!empty($instruction) && $instruction->id == NULL) { $this->context->smarty->assign(array('isOk' => false)); } } else { if (isset($payment['instruction']) && isset($payment['operation'])) { if ($this->api->isChannelInGroup($payment['operation']['payment_method']['channel_id'], array(DotpayApi::cashGroup))) { $isCash = true; } else { $isCash = false; } $instruction = new DotpayInstruction(); $instruction->amount = $payment['instruction']['amount']; $instruction->currency = $payment['instruction']['currency']; $instruction->number = $payment['operation']['number']; $instruction->hash = DotpayInstruction::gethashFromPayment($payment); $instruction->is_cash = $isCash; $instruction->order_id = Tools::getValue('order_id'); $instruction->channel = $payment['operation']['payment_method']['channel_id']; if (isset($payment['instruction']['recipient'])) { $instruction->bank_account = $payment['instruction']['recipient']['bank_account_number']; } try { $instruction->save(); } catch (Exception $e) { $this->context->smarty->assign(array('errorMessage' => $this->module->l("Unable to save instructions." . $e->getMessage()))); } } } if (!empty($instruction) && $instruction->id != NULL) { if ($instruction->is_cash) { $template = 'cash.tpl'; $address = $instruction->getPdfUrl($this->config->getDotpayTargetUrl()); $bankImage = ''; } else { $template = 'transfer.tpl'; $address = $instruction->getBankPage($this->config->getDotpayTargetUrl()); } $chData = $this->api->getChannelData($instruction->channel); $channelImage = $chData['logo']; $this->context->smarty->assign(array('meta_title' => $this->module->l('Complete payment'), 'isOk' => true, 'amount' => $instruction->amount, 'currency' => $instruction->currency, 'title' => $instruction->number, 'address' => $address, 'bankAccount' => $instruction->bank_account, 'recipient' => DotpayInstruction::DOTPAY_NAME, 'street' => DotpayInstruction::DOTPAY_STREET, 'city' => DotpayInstruction::DOTPAY_CITY, 'template' => './confirm/' . $template, 'channelImage' => $channelImage)); } $this->setTemplate("confirm.tpl"); }
/** * Initialize Register Order mechanism * @param DotpayController $parent Owner of the object API. */ public static function init(DotpayController $parent = NULL) { self::$parent = $parent; self::$config = new DotpayConfig(); }