Table of Contents
Failed payment transactions are a merchant’s worst nightmare. In the short term, they mean lost sales. In the long run, they lead to negative reviews, endless customer complaints, and ultimately lost revenue. As a Magento store owner, you expect your site to handle payments flawlessly. In fact, secure and customer-friendly digital payments are a cornerstone for a winning e-shopping experience.
Are you wondering how to add payments to your Magento 2 store? In this post, Ilia Sokolov, our Head of Magento 2 Department with over a decade of experience, shares valuable insights on the Magento 2 payment gateway integration process. We also list the best payment gateways, their features, pros, and pricing to help you power your Magento store with the best payment options available.
Before we delve into the technical intricacies of Magento payment gateway integration, let's review key terms. You'll encounter these terms when deciding on the best payment solution to integrate into your site or when setting up payments on your Magento site.
These components, though often used interchangeably, play distinct roles in the transaction process and have their own technical characteristics.
Now that you know the essential terminology, let's examine how these components work together in a Magento store's payment process.
Payment processing in any e-commerce store starts at the checkout. For Magento Abode Commerce, its beauty lies in the ultimate flexibility of the checkout experience you can achieve at your store.
If you own a Magento 2 store, you can enable any payment method imaginable, giving your customers complete freedom to choose how they want to pay for their orders. You can also customize the checkout flow — make it a consistent multi-step process or a quick one-page effort.
When a customer is ready to pay for their cart, they share their payment data on the frontend. This includes entering their card or account credentials, selecting a preferred payment method, currency, and other details. Once this is done, the payment processor takes over on the backend. It collects the customer’s data, verifies its accuracy, and if everything is in order, triggers the payment gateway to complete the transaction.
It’s important to note that a payment processor is a third-party component. This means neither you nor Magento are responsible for its performance or ownership.
Usually, payment gateways come bundled with specific payment processors, with Stripe and PayPal being top-of-mind examples. Other payment gateways like Authorize.net let you connect third-party processors depending on your business’s needs.
Integrating the right payment gateways and processors in your Magento store is crucial. It ensures that none of your customers leave without completing their purchase. So, let’s explore what Magento 2 has to offer to help you cater to your customers’ payment preferences.
Magento 2 is a robust e-commerce platform that includes many out-of-the-box payment methods. You can configure them in the admin panel to better address your client's preferences.
Among the Magento 2 payment methods:
While these options are fine for most smaller stores with basic needs, your business might require more advanced features — such as support for multiple currencies, subscription management, or cryptocurrency payments. This is where integrating additional payment gateways comes into play.
So, how can you add a payment gateway to your Magento 2 site? There are three basic ways: built-in payment solutions, third-party extensions, or custom integration.
Magento 2 supports three built-in or out-of-the-box payment gateways: PayPal, Braintree, and Authorize.Net. All of them are highly reputable payment providers with ultimate security features. You can enable and configure them straight away after installing Magento Adobe Commerce — no additional software add-ons are required.
All configurations are intuitive and easy to set up via the admin panel to create a straightforward payment flow in your Magento 2 store.
Best for:
You can purchase payment gateway extensions if you’d like to set up payments for different countries and regions. Examples are Magento payment modules like Stripe and Paya, which are common for the US markets, Barclaycard, Worldpay for the UK, Moneris if you target Canada, or Alipay for China.
Best for:
Many enterprise Magento commerce stores opt for custom payment gateway integration. This involves creating custom code that connects your Magento 2 store with a payment service that is either not natively supported by Magento or requires a unique payment flow.
Sometimes, custom payment gateway integration is a mere necessity, e.g., you are looking for completely tailored functionality that none of the ready-made modules provides. In other cases, it is a strategic choice for stores with complex infrastructure or those overly cluttered with third-party extensions when another add-on can cause instability in the entire Magento payment system.
Best for:
Now, from theory to practice. Let’s see what technical steps you need to go through when adding a payment gateway integration to your Magento 2 store.
Ensure that you have Magento 2 installed on your local development environment and it’s compatible with the required PHP version and extensions. Misconfigured server settings (PHP, MySQL) can cause Magento 2 to crash or run slowly.
Set Magento in developer mode for better error reporting. Developer mode makes debugging easy as errors are displayed instantly and directly.
php bin/magento deploy:mode:set developer
Create the directory structure for your custom module.
app/code/Vendor/PaymentGateway/
Create registration.php, module.xml and composer.json files and enable the module.
If the module isn't properly registered, Magento may throw errors. Check file paths and ensure the module name is consistent across files.
php bin/magento setup:upgrade
Define the payment method in the payment.xml and config.xml files.
Incorrect configuration or missing references in config.xml can lead to issues with payment method visibility. Verify all settings are correctly added.
Implement the logic for the payment method in the model file.
Extending the wrong base class or misconfiguration of the payment method code can prevent the payment method from being listed.
Make the payment method configurable from the Magento admin. Define the settings in system.xml.
Errors in system.xml will cause the payment gateway to not appear in the admin configuration. Always ensure fields are well-formed and placed under the correct section.
Use the payment gateway’s API documentation to create a service that will implement request sending (for example, authorizing a payment). Handle success and failure responses.
Inadequate error handling can lead to incorrect status updates or incomplete transactions. Always handle API response statuses carefully and throw meaningful errors.
Implement a UI component for the payment method in the frontend.
Incorrect implementation of the UI component can lead to the payment method not appearing at checkout. Check the require.js paths and make sure the component is correctly registered.
After implementing all the code, enable the module.
php bin/magento setup:upgrade
php bin/magento cache:clean
Test the payment gateway for different transaction scenarios (e.g., success, failure, refund). Always test edge cases like network failure or incorrect payment details.
When moving to production, ensure you enable caching and switch to production mode for performance.
php bin/magento deploy:mode:set production
Double-check error logs and server configurations post-deployment.
A custom payment gateway integration in Magento 2 involves developing a bespoke solution to connect your Magento store with a payment service provider (PSP) that is not natively supported by Magento or through existing extensions. This type of integration is tailored to meet specific business requirements, offering greater flexibility and control over the payment process.
Magento Adobe Commerce platform supports a variety of payment gateways. It doesn't use just one; rather, it offers integration with numerous payment gateways to give merchants flexibility.
Below, we provide a list of most popular payment gateways compatible with Magento 2. Some of them, like we’ve mentioned earlier, are already available by default. Others you can integrate by purchasing a ready-made module or with Magento payment gateway integration service.
PayPal is one of the most widely used payment gateways globally with 35% market share, and Magento 2 offers pre-built integration with it. With 426 million active accounts worldwide and total payment volume hitting $1.53 trillion in Q4 2023, PayPal is trusted by both businesses and consumers for its secure transactions. It’s ideal for Magento 2 stores looking to serve a broad, international audience.
For Magento 2, PayPal supports features like PayPal Express Checkout, Credit and PayPal Payflow. This ensures that customers can complete their payments quickly without leaving your website. It also offers multi-currency support, making it ideal for businesses that sell to customers in different regions.
Braintree, owned by PayPal, offers a full-stack payment solution that supports digital wallets and even cryptocurrency. Its integration with Magento 2 is also built-in. You can easily configure it to accept credit cards, debit cards, PayPal, and mobile wallets like Apple Pay and Google Pay.
One of Braintree's key benefits is its advanced fraud protection, Dynamic 3D Secure (3DS) authentication and detailed analytics, helping store owners reduce chargebacks and gain insight into customer payment behavior. The gateway operates in 45 countries and supports over 130 currencies, making it an excellent choice for international businesses using Magento 2. Braintree’s scalability also ensures that as your business grows, you won’t need to change your payment processor.
Authorize.Net, a trusted payment solution owned by Visa, has been in the payment processing industry for over 20 years. It’s a reliable option for Magento 2 users, with strong support for secure transactions, fraud prevention tools, and recurring billing. It’s a popular choice for stores with subscription services or those needing extensive fraud protection.
For Magento 2, Authorize.Net provides easy integration via its extension, offering a secure and PCI-compliant payment experience. It supports multiple payment methods, including credit cards, eChecks, and Apple Pay. While its market share is only about 5%, Authorize.Net remains a popular choice for Magento businesses seeking a secure and established payment solution.
Stripe has quickly gained traction as one of the most developer-friendly payment gateways, and its Magento 2 integration is widely used by businesses looking for flexibility and customization. Stripe offers a broad range of payment options, including credit/debit cards, mobile wallets, and local payment methods like SEPA and Alipay.
For Magento 2, Stripe’s integration is available as a third-party extension. It provides a highly customizable checkout experience and supports features like one-click payments and recurring billing. With over 3.1 million websites using Stripe globally, it’s clear that this payment gateway is growing in popularity, particularly for tech-savvy businesses looking for advanced functionality.
Klarna has made a name for itself in the "Buy Now, Pay Later" (BNPL) space. If your business model allows customers to split payments into installments, Klarna can be your go to choice. Magento 2’s integration with Klarna provides store owners with an easy way to offer these flexible payment plans, which can increase conversion rates, especially for high-ticket items.
Klarna is growing in popularity across Europe and North America, with more than 150 million consumers and over 450,000 merchants using the service in 2022. Its Magento 2 extension allows customers to choose from various payment plans, including pay later or pay in installments, directly at checkout. This is especially useful for businesses looking to reduce cart abandonment and increase order values.
Worldpay, now part of FIS, is a global payment gateway that supports more than 120 currencies and offers extensive fraud detection tools. The Magento 2 integration with Worldpay allows store owners to accept a wide range of payment methods, including cards, eWallets, and bank transfers. Worldpay’s global reach and strong fraud protection make it a good fit for Magento 2 merchants with international customers.
The Worldpay Magento 2 extension is easy to set up and offers full PCI compliance, ensuring that customer payment data is handled securely. With Worldpay controlling 40% of the UK’s payment processing market, it’s an excellent choice for businesses looking for a trusted, reliable payment solution.
Adyen is a global payment gateway that has quickly gained traction with major brands due to its unified platform, allowing businesses to process payments both online and in-store. The Magento 2 integration with Adyen is highly flexible, supporting over 250 payment methods and 150 currencies. This makes it ideal for stores with an international customer base.
Magento 2’s Adyen extension supports features like recurring payments, risk management, and multi-currency processing. Its unified commerce solution allows store owners to have a single view of payments across all sales channels, providing better insights and customer experiences. Adyen’s market presence has grown significantly, with clients like eBay, Spotify, and Uber using its platform.
Amazon Pay leverages Amazon's trusted payment system to provide a seamless checkout experience for customers who are already familiar with Amazon's platform. Magento 2 integration with Amazon Pay allows store owners to offer a convenient payment option where customers can use the payment methods stored in their Amazon accounts. This provides a smoother checkout process, as customers don’t need to re-enter their payment details.
With Amazon Pay, Magento 2 stores benefit from Amazon’s security and fraud protection measures, which are robust and well-regarded in the industry. Given that Amazon has a substantial user base, integrating Amazon Pay in your Magento 2 store can also help in attracting customers.
Square, known for its simple and user-friendly point-of-sale solutions, also offers a robust payment gateway that integrates seamlessly with Magento 2. It is particularly popular among small to mid-sized businesses for its ease of use and flat-rate pricing model. Square supports a wide range of payment methods, including credit and debit cards, and integrates with various online and in-person sales channels.
With its commitment to transparency and user experience, Square is a solid choice for Magento 2 businesses looking for an all-in-one payment solution that simplifies both online and offline transactions.
2Checkout, recently rebranded as Verifone, is a versatile payment gateway that offers global payment processing capabilities. It is designed to handle transactions in multiple currencies and support a variety of payment methods. The integration with Magento 2 provides store owners with a reliable solution for managing both one-time and recurring payments, making it suitable for businesses with a diverse customer base.
With 2Checkout, Magento 2 merchants can benefit from features such as advanced fraud protection, customizable checkout options, and comprehensive reporting tools. Its global reach and support for over 45 currencies make it an appealing choice for businesses aiming to expand internationally.
Magento 2 gives you the freedom to choose from a variety of payment gateway integrations. The choice of the right solution depends on things like transaction fees, supported currencies, and where your customers are located — all of which can directly affect your conversion rates and help reduce cart abandonment. In the end, it’s about making payments easy and secure for your customers, which is key to your store's success.
Partnering with a team like NEKLO can take your checkout process to the next level, letting you create a fully customized, smooth, and secure payment experience in your store. Get in touch for a free consultation!