I need to create a simple custom payment method like "cash on delivery" but with extra fee when customer selects it. I implemented payment method, but can't find how to make part with extra fee. Can anybody give me a hint?

  • explain in more detail.. what do you mean by extra fee ? if you want this payment method along or with existing one ? Oct 17, 2016 at 9:52

1 Answer 1


I found this article how to add custom fee and only added couple changes to collect() function, like this:

public function collect(Mage_Sales_Model_Quote_Address $address)
        $quote = $address->getQuote();
        $code = $quote->getPayment()->getMethodInstance()->getCode();
        if($code == 'my_payment'){
                $items = $this->_getAddressItems($address);
                if (!count($items)) {
                    return $this; 

                $exist_amount = $quote->getFeeAmount();
                //$fee = Excellence_Fee_Model_Fee::getFee(); 
                $balance = $fee - $exist_amount;
                $address->setGrandTotal($address->getGrandTotal() + $address->getFeeAmount());
                $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount());
    } catch(Exception $e){}

Now only when user selects my payment method this fee would be added to totals

  • This is answer is for Magento1, Do you have the full code for Magento2 ?
    – Jsparo30
    Feb 13, 2018 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.