cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all the active payment methods in custom page

How to get all the active payment methods in custom page

I want to get all the active payment methods in custom page as it is checkout page with the place order functionality.Thank You

3 REPLIES 3

Re: How to get all the active payment methods in custom page

Hello @raju_a 

 

Hope you are doing great!

 

You can follow the steps shown in below link. It may help you.

http://blog.chapagain.com.np/magento-2-get-payment-methods-all-active-used/

 

Thanks

Cheers Coding Smiley Happy !

Magento Developer
Ankita Biswas

Re: How to get all the active payment methods in custom page

In block file

public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Sales\Model\ResourceModel\Order\Payment\Collection $orderPayment,
\Magento\Payment\Helper\Data $paymentHelper,
\Magento\Payment\Model\Config $paymentConfig,
array $data = []
) {
$this->_orderPayment = $orderPayment;
$this->_paymentHelper = $paymentHelper;
$this->_paymentConfig = $paymentConfig;
parent::__construct($context, $data);
}


public function getActivePaymentMethods()
{
return $this->_paymentConfig->getActiveMethods();
}

Call list of active methods in phtml

<?php
$payments = $block->getActivePaymentMethods();
foreach($payments as $paymentCode => $payment) {
echo "<pre>";print_r($payments);
}

 

Re: How to get all the active payment methods in custom page

Thank you for your answer,

But I need to create a checkout in the custom page, that is a custom checkout in the custom page if you have any idea, Please help me

Example: If hello.phtml is a page, I need to bring the checkout here,(Clone of checkout for payment).