Global Payment Integration And Its Common Issues In Magento 2 – Steps To Resolve Issues

The success of an e-commerce store depends on how satisfied the users are with their shopping experience. A smooth checkout process makes the customers happy and encourages
them to shop from your store. While planning the customer journey, one should provide a superior and enjoyable checkout experience to the users. You need a proper payment gateway to provide a seamless experience for online shoppers.
What Is A Payment Gateway And How Does It Works?
When a customer purchases an item from a Magento e-commerce site by filling in their credit card information, the Magento payment gateway receives the information
related to the transaction. It encodes the payment details and payment is transferred to the payment processor. The transaction is directed to the issuing bank and may be approved or declined. If the transaction request is approved, the payment processor
will get notified. The payment gateway sends the money to the merchant account. This process may take a few minutes to some days. Magento web store owners need to choose the right payment gateway to provide an optimal checkout experience to their customers.
The payment gateway you pick should ensure security and convenience to the e-commerce site owners as well as the shoppers. Global payment is used to accept payment in Magento 2 stores. The payment method connects your e-commerce store with the global payment
gateway. This payment method provides Realex Gateway API Which provides full control to the customers as well as merchants. The Global payment method provides two different ways to
use payment. They are mainly as
- HPP (Hosted Payment Page)
- Remote Integration (API)
The payment gateway represents merchant-customer relationships. Before configuring and using it for Magento, you need to follow some additional steps below:
Additional Steps
Step-1: Create a Merchant Account from Global Payment Gateway. You can create an account by using the given link: https://developer.globalpay.com/. You can also create a Sandbox account
for testing purposes.
Step-2: Once your account has been activated, you need to have the following two credentials from the account.
- Merchant ID
- Shared Secret.
You can manage these credentials from My Apps -> Click on the Merchant ID
After clicking on the merchant ID, you will be redirected to the credentials page.
Steps to Configure In Magento 2
Step-1: Enable the extension from the backend after installing and configuring the global payment gateway merchant credentials.
Title: Description of the payment method that your customer will see during checkout.
- Merchant ID: The Merchant ID (or Client ID) as supplied by your Global Payment Merchant account.
- Sub-Account: Global Payments account manager will provide you with the sub-account names which are configured under your Merchant ID.
- Shared Secret Key: The key value has been supplied by your Global Payment Merchant Account.
- Rebate Secret Key: The rebate key has been supplied by your Global Payment Merchant Account.
- Environment: You can switch between a sandbox and a live environment.
Step-2: Configure the Advanced Settings
These settings will define your order status, how to show payment method in I frame, or want to be redirected
to the Hosted Payment page. If you are using a Hosted payment method, then you need to use these APIs
Production URL: https://pay.realexpayments.com/pay
Sandbox URL: https://pay.sandbox.realexpayments.com/pay If you are using the Remote integration method, then you need to use these APIs
Production URL: https://api.realexpayments.com/epage-remote.cgi
Sandbox URL: https://api.sandbox.realexpayments.com/epage-remote.cgi But don’t worry these APIs Global Payment Account Manager will provide you at the time of account
activation.
Step-3: After configuring these details, you need to whitelist your server IP and also provide a response merchant URL to the Global Payment Account Manager.
- Response URL:
‘merchant_response_url’ => http://demo.example.com/realex/redirect/response/ Once all these settings are configured properly, you will be able to use the Global Payment method
in your Magento store. But still, some people are getting issues when the configuration is proper. The most common issue of the Global Payment Gateway is
“Your transaction has been successful but there was a problem connecting back to the merchant’s website. Please contact the merchant and advise them that you received this error message.”
Solution For The Most Common Issue
This is the most common issue that has been faced by many people. Even if you have done a successful payment through Global Payment Gateway, you may not see any success page for the orders that others may be getting using other payment methods. But don’t
worry as we’ve come up with the solution that will help you. Here is the solution to get the success page after the successful payment and avoid the given error message on the screen.
- Override the controller file of the Realex Payment method in the app/code/etc/di.xml file and add the below code to override the controller
<config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:ObjectManager/etc/config.xsd”>
<preference for=”RealexPayments\HPP\Controller\Process\Result\Base” type=”Vendor\ModuleName\Controller\Process\Result\Base” />
<preference for=”RealexPayments\HPP\Controller\Process\Result” type=”Vendor\ModuleName\Controller\Process\Result” />
</config>
- Add the updated code in Vendor\ModuleName\Controller\Process\Result\Base in the execute method to redirect to the success page.
public function execute() { try { $response = $this->getRequest()->getParams(); //the default $params[‘returnUrl’] = $this->_url->getUrl(‘checkout/cart’); if ($response) { $result
= $this->_handleResponse($response); $params[‘returnUrl’] = $this->_url ->getUrl(‘realexpayments_hpp/process/sessionresult’, $this->_buildSessionParams($result)); } } catch (\Exception $e) { $this->_logger->critical($e);
} $this->coreRegistry->register(\RealexPayments\HPP\Block\Process\Result::REGISTRY_KEY, $params); $this->_view->loadLayout(); $this->_view->getLayout()->initMessages(); $this->_view->renderLayout();
$this->_view->getLayout()->createBlock(‘\RealexPayments\HPP\Block\Process\Result’, ‘rp.hpp’);$resp = ‘<div>Your payment has been successfully processed by website….</div>’;
if (isset($params[‘returnUrl’])) {
$resp .= ‘
<script>
window.setTimeout(() => {
window.top.location = “‘ . $params[‘returnUrl’] . ‘”;
}, 1000);
</script>
‘;
} $this->getResponse()->setBody($resp); return; } Add the updated code in Vendor\ModuleName\Controller\Process\Result <?php namespace Vendor\ModuleName\Controller\Process; use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Request\InvalidRequestException; /** * Result implementation for Magento versions greater than or equal to 2.3.0 */ class Result extends Result\Base implements CsrfAwareActionInterface
{ public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException { return null; } public function validateForCsrf(RequestInterface $request): ?bool { return true; } }
By doing this, you will get a success page after the successful transaction.
Final Takeaway
We hope you have understood the configuration for the Global Payment in Magento 2. We have provided as much information that helps to integrate easily with proper settings and also provided solutions to the most common issues that people usually face,
If you have any questions, feel free to contact ZealousWeb and we will provide you with all answers to your queries.