Hello Magento Friends,

Shopping is no more constrained by geographic borders as online Ecommerce stores are ruling the global market. Whenever online shopping is considered, payment methods prove to be the most vital factor. According to a survey, the lack of a preferred payment method is the most common cause of cart abandonment, which needs to be taken seriously. Hence, E-commerce needs a custom payment method to increase the user experience.

When it comes to Magento 2, being the most popular E-commerce platform, it provides many default payment methods. However, sometimes you may need to create a custom payment method in Magento 2 store to integrate with your choice of payment gateway if it’s not already available.

Steps to Create Custom Payment Method in Magento 2:

Step 1: Create app\code\Vendor\Extension\registration.php to register your payment gateway extension.

Step 2: Create app\code\Vendor\Extension\composer.json

Step 3: Create app\code\Vendor\Extension\etc\module.xml to define your module name.

Step 4: Create app\code\Vendor\Extension\etc\config.xml to define your Extension payment method.

Step 5: Create app\code\Vendor\Extension\etc\adminhtml\system.xml to display the payment method in the admin payment method section.

Step 6: Create app\code\Vendor\Extension\etc\frontend\di.xml for dependency Injection configuration.

Step 7: Create a model file to define payment method app\code\Vendor\Extension\Model\Payment.php

Step 8: Create a model file to define Allowed CC type app\code\Vendor\Extension\Model\Source\Cctype.php

Step 9: Create app\code\Vendor\Extension\view\frontend\web\js\view\payment\Extensionpayments.js to register our template or renderer file.

Step 10: Create app\code\Vendor\Extension\view\frontend\web\js\view\payment\method-renderer\Extensionmethod.js

Step 11: Create app\code\Vendor\Extension\view\frontend\web\template\payment\Extension.html template file.

Step 12: Create app\code\Vendor\Extension\view\frontend\layout\checkout_index_index.xml to define payment method at checkout page.

Run the below commands to install the above extension:

Composer require Extension/Extension-php:3.11.0 and add as below sequence

Utilize our custom payment method service and integrate various payment methods with your Magento 2 store effortlessly.

Conclusion:

If you have followed the steps in a perfect manner, you can see your custom payment method on the checkout page. I hope this guide was helpful to serve your purpose. Comments and queries are always welcomed.

Happy Coding

Payment API

Click to rate this post!
[Total: 28 Average: 4]