Mastercard Payment Gateway Services (MPGS) provides a secure payment infrastructure that allows online merchants to accept card payments through Mastercard's global payment network.
For Magento 2 merchants, integrating MPGS enables a reliable payment solution with support for essential payment operations such as authorization, capture, refund, and transaction management.
MPGS Hosted Checkout is one of the most common integration approaches because the payment page is hosted securely by Mastercard. Customers enter their payment information on the Mastercard-hosted page instead of directly on the merchant website.
This approach simplifies payment integration, reduces PCI DSS compliance complexity, and provides customers with a secure checkout experience.
This guide explains how to integrate MPGS Hosted Checkout with Magento 2, including the payment workflow, configuration requirements, and important implementation considerations.
What is MPGS Hosted Checkout?
MPGS Hosted Checkout is a payment integration method where customers are redirected from the Magento 2 checkout page to a secure Mastercard-hosted payment page to complete their transaction.
During the payment process:
- The customer selects MPGS Hosted Checkout at Magento checkout.
- Magento sends transaction information to Mastercard Payment Gateway Services.
- The customer is redirected to the secure hosted payment page.
- The customer enters card details and completes the payment.
- MPGS processes the transaction and returns the payment result to Magento.
Because sensitive card information is handled within the Mastercard payment environment, merchants can reduce the complexity of managing payment security requirements.
Benefits of MPGS Hosted Checkout
Using MPGS Hosted Checkout provides several advantages for Magento 2 merchants:
- Reduced PCI DSS complexity: Card information is entered on a Mastercard-hosted payment page instead of being handled directly by the merchant website.
- Secure payment processing: Transactions are processed through Mastercard Payment Gateway Services.
- Simplified integration: Merchants can implement a secure payment flow without building a complete card payment interface.
- Consistent payment experience: Customers use a trusted payment environment during checkout.
How MPGS Hosted Checkout Works with Magento 2
The general payment workflow between Magento 2 and MPGS Hosted Checkout can be described as follows:
Customer
|
Magento 2 Checkout
|
Create MPGS Payment Request
|
Redirect to MPGS Hosted Checkout Page
|
Customer Completes Payment
|
MPGS Processes Transaction
|
Return Payment Result to Magento 2
|
Update Order Status
The integration process includes several important stages:
1. Customer Starts Checkout
The customer adds products to the cart and proceeds to the Magento 2 checkout page. After selecting MPGS Hosted Checkout as the payment method, Magento prepares the required transaction information.
2. Magento Sends Payment Request to MPGS
Magento communicates with Mastercard Payment Gateway Services using the configured merchant credentials and transaction details.
The payment request usually contains information such as:
- Order reference
- Transaction amount
- Currency
- Customer information
- Payment configuration details
3. Customer Is Redirected to Hosted Payment Page
After the payment request is accepted, the customer is redirected to the MPGS Hosted Checkout page.
On this secure page, customers complete their payment using their preferred card payment method.
4. MPGS Returns Transaction Result
After the payment process is completed, MPGS returns the transaction result to Magento 2.
Magento then updates the order status based on the response received from the gateway.
Requirements Before Integrating MPGS Hosted Checkout with Magento 2
Before implementing MPGS Hosted Checkout, merchants need to prepare the following requirements:
MPGS Merchant Account
A valid Mastercard Payment Gateway Services merchant account is required to process online payments.
The merchant account normally provides:
- Merchant ID
- API username
- API password
- Gateway environment information
Magento 2 Store
The integration requires a working Magento 2 installation with a properly configured store environment.
Recommended requirements include:
- Magento 2.x
- Supported PHP version according to Magento requirements
- HTTPS enabled website
Configuring MPGS Hosted Checkout in Magento 2
After installing an MPGS payment integration module, merchants can configure the payment method from the Magento 2 Admin Panel.
The configuration location is usually:
Stores
→ Configuration
→ Sales
→ Payment Methods
→ Mastercard Payment Gateway Services
Common configuration options include:
- Enable or disable the payment method
- Merchant ID configuration
- API credentials
- Sandbox or production environment
- Accepted currencies
- Payment action settings
Before enabling live transactions, merchants should test the integration using the MPGS test environment to verify the complete payment workflow.
Implementing MPGS Hosted Checkout Flow in Magento 2
A Magento 2 MPGS Hosted Checkout integration typically consists of several technical components, including payment method configuration, API communication, transaction processing, and order status management.
Step 1: Prepare Transaction Information
When a customer places an order, Magento collects the required transaction information and prepares a payment request for MPGS.
The transaction data may include:
- Order ID
- Order amount
- Currency
- Customer details
- Billing and shipping information
Magento then sends the payment request to Mastercard Payment Gateway Services using the configured API credentials.
Step 2: Redirect Customer to MPGS Hosted Checkout
After receiving a valid payment request, MPGS provides the information required to redirect the customer to the hosted payment page.
The customer completes the payment process in the Mastercard secure environment.
The merchant website does not directly handle sensitive card information during this process.
Step 3: Handle Payment Response
After the customer completes the transaction, MPGS returns the payment result to Magento 2.
Magento should process the response and update the order status according to the transaction result.
Common transaction results include:
- Successful payment: The order can be invoiced and processed.
- Failed payment: The order remains unpaid and the customer can try again.
- Cancelled payment: The customer returns to checkout or the order status is updated according to configuration.
Managing MPGS Transaction Status in Magento 2
A reliable payment integration should correctly handle different transaction scenarios throughout the order lifecycle.
Successful Transactions
When MPGS confirms a successful payment, Magento can:
- Create an invoice
- Update order status
- Send order confirmation emails
- Allow order processing
Failed Transactions
When a payment fails, Magento should:
- Keep the order unpaid
- Display an appropriate message to customers
- Allow customers to retry payment when applicable
- Record transaction information for troubleshooting
Refund and Transaction Management
A complete MPGS Magento 2 integration should also support transaction management after the initial payment, including operations such as refunds and payment status checks.
MPGS Hosted Checkout vs Direct Payment
Magento 2 merchants can choose different payment integration approaches depending on their business requirements.
| Feature | Hosted Checkout | Direct Payment |
|---|---|---|
| Payment page | Hosted by Mastercard | Integrated into Magento checkout |
| Card information handling | Processed in Mastercard environment | Handled through direct gateway integration |
| PCI DSS complexity | Lower | Higher |
| Checkout customization | Limited | More control |
| Implementation effort | Easier | More complex |
MPGS Hosted Checkout is suitable for merchants who want a secure and simpler payment integration approach.
Direct Payment can be a better choice for businesses that require more control over the payment experience and checkout flow.
Security Considerations for MPGS Hosted Checkout Integration
Security is one of the main advantages of using a hosted payment solution.
Magento 2 merchants should consider the following best practices:
Use HTTPS
The Magento store should use HTTPS to protect communication between customers, Magento, and the payment gateway.
Protect API Credentials
MPGS API credentials should be stored securely and should never be exposed on the frontend.
Validate Transaction Responses
Magento should verify payment responses before updating order status to prevent incorrect transaction processing.
Test Before Going Live
Merchants should test different payment scenarios before enabling production payments, including:
- Successful transactions
- Failed payments
- Cancelled payments
- Refund operations
Using an MPGS Magento 2 Extension
Developing a payment gateway integration from scratch requires handling multiple Magento 2 components, including payment methods, API communication, transaction processing, and order management.
An MPGS Magento 2 extension provides a ready-made solution that helps merchants connect their Magento store with Mastercard Payment Gateway Services without building the entire payment workflow manually.
With a properly implemented extension, merchants can configure MPGS credentials, enable Hosted Checkout, and manage payment transactions directly from their Magento 2 store.