0

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.

2

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.

| improve this answer | |
  • How Do I do this with magento 2 – Jaisa Apr 23 '18 at 6:55
  • I have updated my answer with Magento 2 code. – Keyur Patel May 13 '18 at 8:04

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.