I have one payment method Ccavenuepay & I want the same module to do two tasks one to accept card payment & second for Zero Cost EMI. I followed this How to add multiple payment method under single payment module in Magento 2 and https://devdocs.magento.com/guides/v2.3/howdoi/checkout/checkout_payment.html#create for this but it didn't worked. I'm attaching code snippets for your reference.
config.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<payment>
<ccavenuepay>
<debug>1</debug>
<active>1</active>
<model>CcavenuepayFacade</model>
<merchant_gateway_key backend_model="Magento\Config\Model\Config\Backend\Encrypted" />
<order_status>pending</order_status>
<payment_action>authorize</payment_action>
<title>CCAvenue MCPG</title>
<currency>INR</currency>
<can_authorize>1</can_authorize>
<can_capture>0</can_capture>
<can_void>1</can_void>
<can_use_checkout>1</can_use_checkout>
<can_use_internal>1</can_use_internal>
<is_gateway>0</is_gateway>
<sort_order>1</sort_order>
</ccavenuepay>
<ccavenuepayemi>
<debug>1</debug>
<active>1</active>
<model>CcavenuepayFacade</model>
<merchant_gateway_key backend_model="Magento\Config\Model\Config\Backend\Encrypted" />
<order_status>pending_payment</order_status>
<payment_action>authorize</payment_action>
<title>Payment method (CcavenuepayCard)</title>
<currency>USD</currency>
<can_authorize>1</can_authorize>
<can_capture>0</can_capture>
<can_void>1</can_void>
<can_use_checkout>1</can_use_checkout>
<is_gateway>0</is_gateway>
<sort_order>10</sort_order>
</ccavenuepayemi>
</payment>
</default>
</config>
class CcavenuepayCard extends \Magento\Payment\Model\Method\AbstractMethod
{
const METHOD_CODE= 'ccavenuepayemi';
var $_code='ccavenuepayemi';
checkout_index_index.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Magento_CcavenuepayCard::css/styles.css"/>
</head>
<body>
<referenceBlock name="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="checkout" xsi:type="array">
<item name="children" xsi:type="array">
<item name="steps" xsi:type="array">
<item name="children" xsi:type="array">
<item name="billing-step" xsi:type="array">
<item name="component" xsi:type="string">uiComponent</item>
<item name="children" xsi:type="array">
<item name="payment" xsi:type="array">
<item name="children" xsi:type="array">
<item name="renders" xsi:type="array">
<!-- merge payment method renders here -->
<item name="children" xsi:type="array">
<item name="ccavenuepay_payment_methods" xsi:type="array">
<item name="component" xsi:type="string">Magento_CcavenuepayCard/js/view/payment/ccavenuepay</item>
<item name="methods" xsi:type="array">
<item name="ccavenuepayemi" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
<item name="ccavenuepay" xsi:type="array">
<item name="isBillingAddressRequired" xsi:type="boolean">true</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
ccavenuepay.js
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/*browser:true*/
/*global define*/
define(
[
'uiComponent',
'Magento_Checkout/js/model/payment/renderer-list'
],
function (
Component,
rendererList,
setPaymentInformationAction,
additionalValidators,
fullScreenLoader
) {
'use strict';
rendererList.push(
{
type: 'ccavenuepayemi',
component: 'Magento_CcavenuepayCard/js/view/payment/method-renderer/ccavenuepay'
},
{
type: 'ccavenuepay',
component: 'Magento_Ccavenuepay/js/view/payment/method-renderer/ccavenuepay'
}
);
//console.log('========== '+ rendererList);
/** Add view logic here if needed */
return Component.extend({});
}
);