I want to get all the active payment methods in custom page as it is checkout page with the place order functionality.Thank You
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
!
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);
}
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).