public function fetch(Mage_Sales_Model_Quote_Address $address)
 {
     if ($address->getBasePaymentCharge() != 0) {
         $address->addTotal(array('code' => $this->getCode(), 'title' => Mage::helper('sales')->__('Payment Charge'), 'full_info' => array(), 'value' => $address->getPaymentCharge(), 'base_value' => $address->getBasePaymentCharge()));
     }
     return $address->getBasePaymentCharge();
 }
Beispiel #2
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $address->setPaymentCharge(0);
     $address->setBasePaymentCharge(0);
     $storeId = Mage::app()->getStore()->getId();
     $items = $address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $paymentMethod = $address->getQuote()->getPayment()->getMethod();
     $quote = $address->getQuote();
     if ($paymentMethod && substr($paymentMethod, 0, 11) == 'pay_payment') {
         $baseAmount = Mage::helper('pay_payment')->getPaymentCharge($paymentMethod, $address->getQuote());
         $amount = Mage::helper('directory')->currencyConvert($baseAmount, Mage::app()->getWebsite()->getConfig('currency/options/default'), Mage::app()->getStore()->getCurrentCurrencyCode());
         $address->setPaymentCharge($amount);
         $address->setBasePaymentCharge($baseAmount);
         $taxClass = Mage::helper('pay_payment')->getPaymentChargeTaxClass($paymentMethod);
         $taxCalculationModel = Mage::getSingleton('tax/calculation');
         $request = $taxCalculationModel->getRateRequest($quote->getShippingAddress(), $quote->getBillingAddress(), null, $storeId);
         $request->setStore(Mage::app()->getStore());
         $rate = $taxCalculationModel->getRate($request->setProductClassId($taxClass));
         //$rate = 21;
         if ($rate > 0) {
             //                $includesTax = Mage::getStoreConfig('tax/calculation/price_includes_tax');
             $baseChargeTax = round($address->getBasePaymentCharge() / (1 + $rate / 100) * ($rate / 100), 2);
             $chargeTax = round($address->getPaymentCharge() / (1 + $rate / 100) * ($rate / 100), 2);
         } else {
             $baseChargeTax = 0;
             $chargeTax = 0;
         }
         $rates = array();
         $applied = false;
         foreach ($address->getAppliedTaxes() as $arrRate) {
             // maximaal 1 keer de btw voor de extra kosten toevoegen
             if ($arrRate['percent'] == $rate && !$applied) {
                 $applied = true;
                 $arrRate['amount'] = $arrRate['amount'] + $chargeTax;
                 $arrRate['base_amount'] = $arrRate['base_amount'] + $baseChargeTax;
             }
             $rates[] = $arrRate;
         }
         $address->setAppliedTaxes($rates);
         $address->setBaseTaxAmount($address->getBaseTaxAmount() + $baseChargeTax);
         $address->setTaxAmount($address->getTaxAmount() + $chargeTax);
         $address->setGrandTotal($address->getGrandTotal() + $address->getPaymentCharge());
         $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentCharge());
     }
     return $this;
 }
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $address->setPaymentCharge(0);
     $address->setBasePaymentCharge(0);
     $items = $address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $paymentMethod = $address->getQuote()->getPayment()->getMethod();
     if (Mage::getStoreConfig('tax/calculation/price_includes_tax') != 1) {
         $tax = $address->getTaxAmount();
     }
     if ($paymentMethod) {
         $amount = Mage::helper('paymentcharge')->getPaymentCharge($paymentMethod, $address->getQuote());
         if (Mage::getStoreConfig('payment/paypal_payment_solutions/charge_type') != "percentage") {
             //$amount1 = Mage::helper('directory')->currencyConvert( $amount, 'USD', Mage::app()->getStore()->getCurrentCurrencyCode());
             $address->setPaymentCharge($amount);
             $address->setBasePaymentCharge($amount);
         } else {
             $subTotal = $address->getBaseSubtotal();
             $amount12 = $subTotal * (Mage::getStoreConfig('payment/paypal_payment_solutions/charge_value') / 100);
             $address->setBasePaymentCharge($amount12);
             $address->setPaymentCharge($amount12);
         }
     }
     //$address->setSubtotal($address->getSubtotal() + $tax  + $address->getPaymentCharge());
     //$address->setBaseSubtotal($address->getBaseSubtotal()+ $address->getBasePaymentCharge());
     $address->setGrandTotal($address->getGrandTotal() + $address->getPaymentCharge());
     $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentCharge());
     return $this;
 }
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $address->setPaymentCharge(0);
     $address->setBasePaymentCharge(0);
     $items = $address->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $paymentMethod = $address->getQuote()->getPayment()->getMethod();
     if ($paymentMethod) {
         $amount = Mage::helper('paymentcharge')->getPaymentCharge($paymentMethod, $address->getQuote());
         $address->setPaymentCharge($amount['amount']);
         $address->setBasePaymentCharge($amount['base_amount']);
     }
     $address->setGrandTotal($address->getGrandTotal() + $address->getPaymentCharge());
     $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentCharge());
     return $this;
 }