Magento 2 Payment Method not showing in checkout page
app/code/payhere/payhere/registration.php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Payhere_Payhere',
__DIR__
);
app/code/payhere/payhere/etc/config.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd">
<default>
<payment>
<payhere>
<active>1</active>
<title>PayHere</title>
<order_status>pending_payment</order_status>
<instructions>Instruction.</instructions>
<title>PayHere</title>
<payment_action>true</payment_action>
<model>Payhere\Payhere\Model\Payhere</model>
<group>offline</group>
</payhere>
<!-- payment-config -->
</payment>
</default>
</config>
app.code/payhere/payhere/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Payhere_Payhere" setup_version="2.0.0">
</module>
app/code/payhere/payhere/etc/payment.xml
<payment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../Magento/Payment/etc/payment.xsd">
<groups>
<group id="offline">
<label>Offline Payment Methods</label>
</group>
</groups>
<methods>
<method name="payhere">
<allow_multiple_address>1</allow_multiple_address>
</method>
</methods>
</payment>
app/code/payhere/payhere/view/frontend/web/js/view/payment/payhere.js
define(
[
'uiComponent',
'Magento_Checkout/js/model/payment/renderer-list'
],
function (
Component,
rendererList
) {
'use strict';
rendererList.push(
{
type: 'payhere',
component: 'Payhere_Payhere/js/view/payment/method-renderer/payhere-method'
}
);
/** Add view logic here if needed */
return Component.extend({});
}
);
app/code/payhere/payhere/view/frontend/web/js/view/method-renderer/payhere-method.js
define(
[
'Magento_Checkout/js/view/payment/default',
'mage/url'
],
function (Component, url) {
'use strict';
return Component.extend({
defaults: {
template: 'Payhere_Payhere/payment/payhere'
},
redirectAfterPlaceOrder: false,
/** Returns send check to info */
getMailingAddress: function() {
return window.checkoutConfig.payment.checkmo.mailingAddress;
},
afterPlaceOrder: function () {
window.location.replace(url.build('payhere/payment/request'));
},
});
}
);
Best Answer
app/code/Payhere/Payhere/etc/module.xml
app/code/Payhere/Payhere/etc/adminhtml/system.xml
app/code/Payhere/Payhere/etc/config.xml
app/code/Payhere/Payhere/Model/Payhere.php
app/code/Payhere/Payhere/view/frontend/layout/checkout_index_index.xml
app/code/Payhere/Payhere/view/frontend/web/template/payment/payhere.html
app/code/Payhere/Payhere/view/frontend/web/js/view/payment/payhere.js
app/code/Payhere/Payhere/view/frontend/web/js/view/payment/method-renderer/payhere.js