/** * Displays a page with saved credit cards */ public function initContent() { $this->display_column_left = false; parent::initContent(); $this->context->smarty->assign(array('cards' => DotpayCreditCard::getAllCardsForCustomer($this->context->customer->id), 'onRemoveMessage' => $this->module->l('Do you want to deregister a saved card'), 'onDoneMessage' => $this->module->l('The card was deregistered'), 'onFailureMessage' => $this->module->l('An error occurred while deregistering the card'), 'removeUrl' => $this->context->link->getModuleLink($this->module->name, 'ocremove'))); $this->setTemplate("ocmanage.tpl"); }
/** * Returns list of payment channels * @return array */ public function getChannelList() { $oneclickAgreements = $this->parent->module->l('I agree to repeated loading bill my credit card for the payment One-Click by way of purchase of goods or services offered by the store.'); $channelList = array(); $targetUrl = $this->parent->getPreparingUrl(); if ($this->config->isDotpayOneClick() && $this->getChannelData(self::$ocChannel) && $this->parent->isMainChannelEnabled()) { $this->addSeparatedChannel(self::$ocChannel); $creditCards = DotpayCreditCard::getAllCardsForCustomer(Context::getContext()->customer->id); $creditCardsValues = array(); $img = '<img class="dotpay-card-logo" '; foreach ($creditCards as $creditCard) { $creditCardsValues[$creditCard->mask . ' (' . $creditCard->brand . ')'] = $creditCard->id; $img .= 'data-card-' . $creditCard->cc_id . '="' . $creditCard->card_brand->image . '" '; } $img .= '/>'; $ocManageLink = Context::getContext()->link->getModuleLink($this->parent->module->name, 'ocmanage'); $channelList['oneclick'] = array('form' => $this->getFormHeader('oneclick', $targetUrl), 'fields' => array($this->getHiddenField('order_id', Tools::getValue('order_id')), array('type' => 'radio', 'name' => 'dotpay_type', 'id' => 'select_saved_card', 'value' => 'oneclick', 'class' => 'oneclick-margin', 'label' => $this->parent->module->l('Select a registered card') . ' (<a href="' . $ocManageLink . '" target="_blank">' . $this->parent->module->l('Manage your registered cards') . '</a>)', 'required' => true), array('type' => 'select', 'name' => 'credit_card', 'id' => 'saved_credit_cards', 'class' => 'oneclick-margin', 'values' => $creditCardsValues, 'label' => $img), array('type' => 'radio', 'name' => 'dotpay_type', 'value' => 'oneclick_register', 'class' => 'oneclick-margin', 'label' => $this->parent->module->l('Register a new card'), 'required' => true), array('type' => 'checkbox', 'name' => 'oneclick_agreements', 'value' => '1', 'checked' => true, 'label' => $oneclickAgreements, 'required' => true), $this->addBylawField(), $this->addPersonalDataField(), $this->getSubmitField()), 'image' => $this->parent->getDotOneClickLogo(), 'description' => " <strong>" . $this->parent->module->l("Credit Card - One Click") . "</strong> <span>" . $this->parent->module->l("(via Dotpay.pl)") . "</span>"); } $ccChannel = null; $availableCardChannels = array(self::$ocChannel, self::$ccChannel); foreach ($availableCardChannels as $channel) { if ($this->getChannelData($channel)) { $ccChannel = $channel; break; } } if ($this->config->isDotpayCreditCard() && $ccChannel !== null && $this->parent->isMainChannelEnabled()) { $this->addSeparatedChannel($ccChannel); $channelList['cc'] = array('form' => $this->getFormHeader('cc', $targetUrl), 'fields' => array($this->getHiddenField('dotpay_type', 'cc'), $this->getHiddenField('channel', $ccChannel), $this->getHiddenField('order_id', Tools::getValue('order_id')), $this->addBylawField(), $this->addPersonalDataField(), $this->getSubmitField()), 'image' => $this->parent->getDotCreditCardLogo(), 'description' => " " . $this->parent->module->l("Pay with your credit card") . " <span>" . $this->parent->module->l("(via Dotpay.pl)") . "</span>"); } if ($this->parent->isDotpayPVEnabled() && $this->getChannelData(self::$pvChannel, true)) { $this->addSeparatedChannel(self::$pvChannel); $channelList['pv'] = array('form' => $this->getFormHeader('pv', $targetUrl), 'fields' => array($this->getHiddenField('dotpay_type', 'pv'), $this->getHiddenField('order_id', (int) Tools::getValue('order_id')), $this->getHiddenField('id', $this->config->getDotpayPvId()), $this->addBylawField(), $this->addPersonalDataField(), $this->getSubmitField()), 'image' => $this->parent->getDotPVLogo(), 'description' => " " . $this->parent->module->l("Pay with your credit card") . " <span>" . $this->parent->module->l("(via Dotpay.pl)") . "</span>"); } if ($this->config->isDotpayBlik() && $this->getChannelData(self::$blikChannel) && strtoupper($this->parent->getDotCurrency() == 'PLN') && $this->parent->isMainChannelEnabled()) { $this->addSeparatedChannel(self::$blikChannel); $blikText = $this->parent->module->l("BLIK code 6 digits"); $channelList['blik'] = array('form' => $this->getFormHeader('blik', $targetUrl), 'fields' => array($this->getHiddenField('dotpay_type', 'blik'), $this->getHiddenField('order_id', Tools::getValue('order_id')), array('type' => 'text', 'name' => 'blik_code', 'value' => '', 'placeholder' => $blikText, 'required' => true), $this->addBylawField(), $this->addPersonalDataField(), $this->getSubmitField()), 'image' => $this->parent->getDotBlikLogo(), 'description' => " <strong>" . $this->parent->module->l("Blik") . "</strong> <span>" . $this->parent->module->l("(via Dotpay.pl)") . "</span>"); } if ($this->config->isDotpayMasterPass() && $this->getChannelData(self::$mpChannel) && $this->parent->isMainChannelEnabled()) { $this->addSeparatedChannel(self::$mpChannel); $channelList['mp'] = array('form' => $this->getFormHeader('mp', $targetUrl), 'fields' => array($this->getHiddenField('dotpay_type', 'mp'), $this->getHiddenField('order_id', Tools::getValue('order_id')), $this->addBylawField(), $this->addPersonalDataField(), $this->getSubmitField()), 'image' => $this->parent->getDotMasterPassLogo(), 'description' => " " . $this->parent->module->l("MasterPass") . " <span>" . $this->parent->module->l("(via Dotpay.pl)") . "</span>"); } if ($this->parent->isMainChannelEnabled() && !$this->isMainChannelEmpty()) { $extendedWidget = '<div class="selected-channel-message">' . $this->parent->module->l("Selected payment channel") . ': <a href="#" class="channel-selected-change">' . $this->parent->module->l("change channel") . ' »</a></div><div class="selectedChannelContainer channels-wrapper"><hr /></div>' . '<div class="collapsibleWidgetTitle">' . $this->parent->module->l("Available channels") . ':</div>'; $channelList['dotpay'] = array('form' => $this->getFormHeader('dotpay', $targetUrl), 'image' => $this->parent->getDotpayLogo(), 'description' => " <strong>" . $this->parent->module->l(" Dotpay ") . "</strong> <span>" . $this->parent->module->l("(fast and secure internet payment)") . "</span>"); $fields = array($this->getHiddenField('dotpay_type', 'dotpay'), $this->getHiddenField('order_id', Tools::getValue('order_id'))); if ($this->config->isDotpayWidgetMode()) { $fields[] = array('type' => 'hidden', 'name' => 'widget', 'value' => $this->config->isDotpayWidgetMode(), 'label' => $extendedWidget . '<p class="my-form-widget-container"></p>'); $fields[] = $this->addBylawField(); $fields[] = $this->addPersonalDataField(); } $fields[] = $this->getSubmitField(); $channelList['dotpay']['fields'] = $fields; } return $channelList; }