Creating a Payment Gateway integration in Magento 2
Magento 2 Create Payment Method demonstrates that when your store is built on the Magento 2 platform, you have the ability to create as many payment ways as you need.
You presumably add them to your list of existing payment methods based on the customer’s requirements.
Additional payment methods undoubtedly increase client choice when they proceed to checkout on your site, which can improve their experience and lower abandoned cart rates.
2)Create the registration file “registration.php” where ‘app/code/Hikmadh/Pay”.Use the following code.
3)Enable the module by typing the following command into your terminal.
php bin/magento module:enable Hikmadh_Pay
Step 2: Create The Configuration File.
- Create a configuration file that will allow you to manage payment gateway configuration from Admin -> Stores -> Settings -> Configuration -> Sales -> Payment Methods.
- Create system.xml at app/code/Hikmadh/Pay/etc/adminhtml/system.xml as follows
Magento\Config\Model\Config\Source\Yesno

Step 3: Create config.xml.
- Create config.xml file in app/code/Hikmadh/Pay/etc/ folder as follows :
authorize
Hikmadh\Pay\Model\PaymentMethod
1
Test Payment Method
pending_payment
Step 4: Create a model file.
- Create a model file at app/code/Hikmadh/Pay/Model/PaymentMethod.php which will handle the logic of payment gateway implementation.
As previously stated, there are three functions,“authorise”, “capture”, and “refund”, which are used to authorise a card, take/capture money from the client, and deliver a refund to the customer.
Step 5: Create payment method in checkout page.
- Create a layout file at app/code/Hikmadh/Pay/view/frontend/layout/checkout_index_index.xml.
-
-
-
-
-
-
- uiComponent
-
-
-
-
-
-
- Hikmadh_Pay/js/view/payment/method-renderer
-
-
&titem name="isBillingAddressRequired" xsi:type="boolean">true
-
2)Create a Js file at app/code/Hikmadh/Pay/view/frontend/web/js/view/payment/method-renderer.js so that we can fetch the payment gateway template using knockout in the checkout payment step.
define(
[
'uiComponent',
'Magento_Checkout/js/model/payment/renderer-list'
],
function (
Component,
rendererList
) {
'use strict';
rendererList.push(
{
type: 'testpayment',
component: 'Hikmadh_Pay/js/view/payment/method-renderer/testpayment'
}
);
return Component.extend({});
}
);
3)create the component as declared above in app/code/Hikmadh/Pay/view/frontend/web/js/view/payment
/method-renderer/testpayment.js as follows
define(
[
'Magento_Checkout/js/view/payment/default'
],
function (Component) {
'use strict';
return Component.extend({
defaults: {
template: 'Hikmadh_Pay/payment/testpayment'
}
});
}
);
- The next step will be to create the Knockout template at app/code/Hikmadh/Pay/view/frontend/web/template
/payment/testpayment.html
These steps will create a basic payment gateway that would be visible at the time of checkout.
