public function _beforeToHtml()
 {
     parent::_beforeToHtml();
     $paymentMethod = $this->getOrder()->getPayment()->getMethod();
     if (!$this->getApi()->isBillpayPayment($paymentMethod)) {
         $this->setTemplate('');
     }
 }
Exemple #2
0
 public function _beforeToHtml()
 {
     parent::_beforeToHtml();
     $order = $this->getOrder();
     $paymentMethod = $order->getPayment()->getMethod();
     if ($order && $this->getApi()->isBillpayPayment($paymentMethod) && $order->getBillpayChargedFee() > 0) {
         if ($this->getApi()->isBillpayInvoicePayment($paymentMethod)) {
             $this->setLabel($this->getApi()->__('billpay_rec_step_fee_text'));
         } else {
             $this->setLabel($this->getApi()->__('billpay_elv_step_fee_text'));
         }
         /**
          * Billpay source types:
          * 1: order/invoice (read-only)
          * 2: creditmemo (create)
          * 3: creditmemo (view)
          */
         if ($this->getApi()->getConfigData('fee/display_incl_tax_admin', $order->getStoreId())) {
             switch ($this->_billpaySourceType) {
                 case 1:
                     $this->_chargedFeeDisplayValue = $order->getBillpayChargedFee();
                     $this->_baseChargedFeeDisplayValue = $order->getBaseBillpayChargedFee();
                     break;
                 case 2:
                     $this->_chargedFeeDisplayValue = $order->getBillpayChargedFee() - $order->getBillpayChargedFeeRefunded();
                     $this->_baseChargedFeeDisplayValue = $order->getBaseBillpayChargedFee() - $order->getBaseBillpayChargedFeeRefunded();
                     break;
                 case 3:
                     $creditmemo = $this->getSource();
                     $this->_chargedFeeDisplayValue = $creditmemo->getBillpayChargedFeeRefunded();
                     $this->_baseChargedFeeDisplayValue = $creditmemo->getBaseBillpayChargedFeeRefunded();
                     break;
             }
         } else {
             switch ($this->_billpaySourceType) {
                 case 1:
                     $this->_chargedFeeDisplayValue = $order->getBillpayChargedFeeNet();
                     $this->_baseChargedFeeDisplayValue = $order->getBaseBillpayChargedFeeNet();
                     break;
                 case 2:
                     $this->_chargedFeeDisplayValue = $order->getBillpayChargedFeeNet() - $order->getBillpayChargedFeeRefundedNet();
                     $this->_baseChargedFeeDisplayValue = $order->getBaseBillpayChargedFeeNet() - $order->getBaseBillpayChargedFeeRefundedNet();
                     break;
                 case 3:
                     $creditmemo = $this->getSource();
                     $this->_chargedFeeDisplayValue = $creditmemo->getBillpayChargedFeeRefundedNet();
                     $this->_baseChargedFeeDisplayValue = $creditmemo->getBaseBillpayChargedFeeRefundedNet();
                     break;
             }
         }
         // ensure backward compability beacuse we switched to usage of base value
         if ($this->_baseChargedFeeDisplayValue <= 0 && $this->_chargedFeeDisplayValue && $this->_chargedFeeDisplayValue > 0) {
             $this->_baseChargedFeeDisplayValue = $this->_chargedFeeDisplayValue;
         }
     } else {
         $this->setTemplate('');
     }
     if (is_null($this->_chargedFeeDisplayValue) || $this->_chargedFeeDisplayValue <= 0) {
         $this->setTemplate('');
     }
 }