Magento Custom Checkout – Add Payment Methods

onestepcheckoutpayment-methods

I am working on building a custom checkout page for my new module. Can anyone say how can I include payment methods into my custom checkout page. I need to integrate Paypal and Authorizenet methods currently.

Best Answer

Magento 1.X:

To display currently active payment methods on custom checkout module is to override block Mage_Checkout_Block_Onepage_Payment_Methods with custom one.

In that corresponding phtml file just call $methods = $this->getMethods(); which will give all active payment methods.

Refer following two file:

app\design\frontend\base\default\template\checkout\onepage\payment\methods.phtml
app\code\core\Mage\Checkout\Block\Onepage\Payment\Methods.php

Magento 2: write following in your block file.

public function __construct(
    \Magento\Payment\Helper\Data $paymentHelper,
) {       
    $this->_paymentHelper = $paymentHelper;   
}

/**
 * Get all payment methods
 * 
 * @return array
 */ 
public function getAllPaymentMethods() 
{
    return $this->_paymentHelper->getPaymentMethods();
}

Now you can getAllPaymentMethods() method from your phtml file.

Related Topic