The Implementation of Payment Gateways in Magento 2

- Magento 2

Magento 2 Payment Gatways Implementation

If you’re developing or deploying a payment gateway in Magento 2, you may face different challenges related to various stages of your project. In the following post, we’ve gathered all major tips, tricks, and tutorials related to the Magento 2 payment gateways implementation, so it can essentially simplify your daily work with the platform. Let’s start with some key aspects that you will probably have to master while deploying a payment system within your Magento 2 website.

First of all, there might be a necessity to change configuration files. Hance, you will have to deal with refreshing “Configuration” cache in order to see the changes. Some specialists recommend to disable this cache type, but this approach has one terrible drawback – it significantly slows down the application.

While trying to implement a payment gateway in Magento 2, you have to work with layouts or templates, therefore, don’t forget to disable “Layouts,” “Blocks HTML output,” and “Page Cache.” It is also important to enable them back, when you are done.

When working with classes, keep all the cache types enabled. At the same time, the deployment of Magento 2 payment gateway requires to clean-up var/di and var/generation, if you change the classes public interface or the DI configuration.

And finally, when you are working with JS, CSS, and LESS files, while trying to implement a payment gateway in Magento 2, you may also want to disable or refresh such cache types as “View files fallback” and “View files pre-processing.” It is necessary in case you add or remove such files. For LESS files, cleanup your pub/static folder or turn on developer mode. Please note that both actions lead to a significant decrease of the application’s performance. Additionally, you may use such CLI command as bin/magento dev:css:deploy for processing specific LESS files.

Magento 2 Payment Gateways Tutorials

Below, you will find some useful materials related to the implementation of payment gateways in Magento 2. There are both official manuals and third party articles.

Payment modules – the official Magento 2 tutorial

This article describes the general functionality and responsibilities of Magento’s payment modules. Besides, it provides recommendations on disabling particular modules.

Thus, the author of this Magento 2 tutorial says that all abstract logic common for all payments methods is located in a separate module. As for the implementations of particular methods, they are located in the corresponding modules and sorted by payment gateway or type. Therefore, it is extremely easy to configure the set of payment methods your Magento  2 website provides – you only have to disable the modules for the solutions you are not going to use.

The only module that is not supposed to be disabled is Magento_Payment, which is responsible for the abstract logic common for all Magento 2 payment methods as well as the implementation of the Zero Subtotal Checkout payment method. Magento_Paypal, Magento_Ogone, Magento_OfflinePayments, and Magento_Authorizenet can be disabled. You can find out more about their functionality by following the below link. The modules are also described in the end of this Magento 2 tutorial.

Magento 2 Payment Gateways

Magento 2 Payment Modules

Implementing payment gateway in Magento 2 – Magento 2 tutorial by Inchoo

This article was originally written in 2014, but got a lot of improvements during 2015, so it is one of the most comprehensive tutorials related to the payment gateways implementation in Magento 2. The guide covers all backend issues and shows how to develop a simple module via the payment gateway API integration process. More precisely, it is focussed on the implementation of the Stripe payment gateway.

Magento 2 Payment gateways

Implementing payment gateway in Magento 2

Magento 2 Payment Gateway API – an important guide by Max Pronko

In this article, Max reviews Command Interfaces and appropriate Service Classes from Payment Service Contracts. As an example, he describes how to configure CommandPool and CaptureGateway command classes in order to handle the Payment Capture command in the Payment class, while the GatewayCommand class continues holding communication logic with Payment Service Providers. Max highly recommends to utilize Payment Gateway API as a core framework for all your payment integrations.

 Payment Gateway API in Magento 2

Magento 2 Payment Gateway API

The basics of creating a Payment Method in Magento 2 – a useful article by Joseph McDermott

Joseph shows how to create a payment method in Magento 2. By describing this process, he illustrates the following ideas:

  • Magento 2 offers a lot more flexible structure when it comes to payment gateways.
  • All payment methods are fully controllable via HTML and JavaScript.
  • Everything is nicely packaged inside the Magento 2 module structure.
  • Debugging is a little more difficult than in 1.X.

Magento 2 payment gateways

The basics of creating a Payment Method in Magento 2

Magento 2 Payment Gateway Extensions

The following extensions illustrate the aforementioned techniques and provide the ability to implement a payment gateway in a Magento 2  project.


This is the Stripe payment gateway extension for Magento 2. The module was designed for educational purposes only, so it is important to use it when you are trying to master the creation or deployment of payment gateways in Magento 2. The aforementioned article (Implementing payment gateway in Magento 2 by Inchoo) describes how to use the extension within an ecommerce project. The installation is described on GitHub.

Magento 2 Payment gateways: magento2-Inchoo_Stripe

Download magento2-Inchoo_Stripe


Tmrobokass is a robokassa test payment gateway for Magento 2. You should also use it for educational purposes. For further information, go to the extension’s page on GitHub.

MAgento 2 payment gateways: magento2-module-payment-tmrobokassa

Download magento2-module-payment-tmrobokassa

Magento 2 Native Payment Modules

Below, we shed light on native payment modules of Magento 2 and provide the examples of payment methods implementation in the Magento 2 core.

  • Magento_Paypal. The Magento\PayPal module implements integration with PayPal. It enables such payment methods as PayPal Express Checkout, PayPal Payments Pro, PayPal Payments Standard, PayPal Credit, and PayFlow Payment Gateway.
  • Magento_Authorizenet. This module implements the integration with the Authorize.Net payment gateway by adding it as a payment method in Magento 2.
  • Magento_OfflinePayments. OfflinePayments is responsible for payment methods which don’t rely on payment gateways: Bank transfer,Cash on delivery,Check / Money Order, and Purchase order.
  • Magento_Payment. The module provides the abstraction class for all payment methods as well as all logic used while adding a new payment method: configuration models, separate models for payment data verification, etc.

That was all the information about the implementation of payment gateways in magento 2 we’d like to share with you. Feel free to ask comments via the question field below.