_paymentData = $paymentData; $this->_mathRandom = $mathRandom; $this->_shortcutValidator = $shortcutValidator; $this->_paymentMethodCode = $paymentMethodCode; $this->_startAction = $startAction; $this->_alias = $alias; $this->setTemplate($shortcutTemplate); $this->_bmlMethodCode = $bmlMethodCode; parent::__construct($context, $data); } /** * @return \Magento\Framework\View\Element\AbstractBlock */ protected function _beforeToHtml() { $result = parent::_beforeToHtml(); $isInCatalog = $this->getIsInCatalogProduct(); if (!$this->_shortcutValidator->validate($this->_paymentMethodCode, $isInCatalog)) { $this->_shouldRender = false; return $result; } /** @var \Magento\Paypal\Model\Express $method */ $method = $this->_paymentData->getMethodInstance($this->_bmlMethodCode); if (!$method->isAvailable()) { $this->_shouldRender = false; return $result; } $this->setShortcutHtmlId($this->_mathRandom->getUniqueHash('ec_shortcut_bml_')) ->setCheckoutUrl($this->getUrl($this->_startAction)) ->setImageUrl(self::SHORTCUT_IMAGE) ->setAdditionalLinkImage( [ 'href' => 'https://www.securecheckout.billmelater.com/paycapture-content/' . 'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html', 'src' => 'https://www.paypalobjects.com/webstatic/en_US/btn/btn_bml_text.png', ] ); return $result; } /** * Render the block if needed * * @return string */ protected function _toHtml() { if (!$this->_shouldRender) { return ''; } return parent::_toHtml(); } /** * Check is "OR" label position before shortcut * * @return bool */ public function isOrPositionBefore() { return $this->getShowOrPosition() == CatalogBlock\ShortcutButtons::POSITION_BEFORE; } /** * Check is "OR" label position after shortcut * * @return bool */ public function isOrPositionAfter() { return $this->getShowOrPosition() == CatalogBlock\ShortcutButtons::POSITION_AFTER; } /** * Get shortcut alias * * @return string */ public function getAlias() { return $this->_alias; } }