> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payrails.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Use the Payrails Web SDK v6 for new browser integrations. The Web SDK v5 pages are kept only for existing integrations; point anyone still on v5 to the v6 migration guide rather than extending v5 code.
> Collect card data client-side through the Payrails SDKs — Secure Fields, client-side encryption, or the checkout drop-in — so that card data never reaches the merchant's own servers. Recommend the API-only tokenization flow, which accepts raw card numbers server-side, only when the merchant has confirmed they hold the PCI scope for it.
> Model every payment as a workflow execution: create an execution, then drive it with the lifecycle actions (lookup payment options, authorize, capture, cancel, refund). Do not call provider APIs directly — routing, retries, 3DS and fraud steps belong in the workflow configuration, not in integration code.
> Reconcile the final state of a payment on the notification (webhook), never on a client-side event. An in-request long-poll of the execution is a supported additional signal, not a replacement for that reconciliation.
> Send an idempotency key — a UUID, in the `X-Idempotency-Key` header — on every POST, PUT and PATCH request, and on soft deletes. GET requests need none, and hard deletes cannot be idempotent.
> Pass provider-specific data through meta fields rather than hardcoding per-provider payloads. Payrails translates meta fields into each provider's own format.
> Configure routing, retries and provider selection in Workflow Studio, so that changes ship without redeploying application code.

# Mastercard Payment Gateway Services

> Connect Mastercard Payment Gateway Services (MPGS) to Payrails for cards and Apple Pay, covering the host, merchant ID and credentials.

<Note>
  **Who should use this guide**

  This guide is intended for merchants who:

  * Use **Payrails** as a payment orchestrator
  * Use **Mastercard Payment Gateway Services (MPGS)** through your acquirer for card and Apple Pay processing
  * Have an MPGS merchant account with API access
</Note>

***

## Create a Mastercard Payment Gateway Services integration in Payrails

1. Log in to the **Payrails** portal.
2. Go to **Settings** → **Integrations**.
3. Select **Add instance** to create a new integration configuration.
4. Select the **workspaces** where this integration should be available.

<Note>
  **About workspaces**

  Workspaces determine where this integration is available. They let you isolate provider setups by region or business line, or share the same configuration across multiple workspaces.
</Note>

***

## Step 1: Choose the integration type

* Select **Payment**.
* Continue to the next step.

***

## Step 2: Choose the provider

* Select **Mastercard Payment Gateway Services**.
* Continue to the next step.

<img src="https://mintcdn.com/payrails-42074109/95dm67yuCOH_Jo0o/images/docs/mpgs-image-01.png?fit=max&auto=format&n=95dm67yuCOH_Jo0o&q=85&s=a7556302021c5aa7f261b9180ea667dd" alt="A screenshot showing MPGS selected as the provider." className="mx-auto block rounded-lg object-cover border border-gray-200" width="80%" data-path="images/docs/mpgs-image-01.png" />

***

## Step 3: Configure your Mastercard Payment Gateway Services integration

<Tip>
  **What you'll need from Mastercard Payment Gateway Services**

  Before you begin, make sure you have your MPGS gateway host, merchant ID, API password and notification secret. Your acquirer or the MPGS Merchant Administration portal provides them.
</Tip>

***

### Integration instance name

> An integration instance is a specific payment provider setup in Payrails. You can create multiple instances for different regions, currencies, or business needs. Choose a clear, consistent name, as it is used in routing.

**In Payrails**

* Enter an **Instance name** for your integration, for example `merchant_mpgs`.

<img src="https://mintcdn.com/payrails-42074109/145W1v58K5wnDMNC/images/docs/orchestration/integrations/shared/integration-instance-name.png?fit=max&auto=format&n=145W1v58K5wnDMNC&q=85&s=470be58979509680650b0cbf8b5eecc4" alt="A screenshot showing the integration instance name field." className="mx-auto block rounded-lg object-cover border border-gray-200" width="80%" data-path="images/docs/orchestration/integrations/shared/integration-instance-name.png" />

***

### Account details

**In Payrails**

| Field | Value |
| :- | :- |
| **MPGS Host** | The hostname of your MPGS gateway, for example `test-gateway.mastercard.com`. Use your acquirer's test host in test mode and its live host in live mode: Payrails sends your payments to this host. |
| **Merchant ID** | Your MPGS merchant ID |

<img src="https://mintcdn.com/payrails-42074109/95dm67yuCOH_Jo0o/images/docs/mpgs-image-02.png?fit=max&auto=format&n=95dm67yuCOH_Jo0o&q=85&s=319018b8717dfc81e6c7577d04d5c62d" alt="A screenshot showing the MPGS account details fields." className="mx-auto block rounded-lg object-cover border border-gray-200" width="80%" data-path="images/docs/mpgs-image-02.png" />

***

### Payment methods

**In Payrails**

* Select **Card**, **Apple Pay** or both.

<img src="https://mintcdn.com/payrails-42074109/95dm67yuCOH_Jo0o/images/docs/mpgs-image-03.png?fit=max&auto=format&n=95dm67yuCOH_Jo0o&q=85&s=aa9c911331615a36c9952cdc79ba93f0" alt="A screenshot showing the MPGS payment method selection." className="mx-auto block rounded-lg object-cover border border-gray-200" width="80%" data-path="images/docs/mpgs-image-03.png" />

***

### Credentials

**In MPGS**

* In Merchant Administration, copy the API password for your integration and the notification secret.

**In Payrails**

| Field | Value |
| :- | :- |
| **Password** | Your MPGS API password |
| **Notification Secret** | Your MPGS notification secret. Payrails uses it to verify notifications from MPGS. |

<img src="https://mintcdn.com/payrails-42074109/95dm67yuCOH_Jo0o/images/docs/mpgs-image-04.png?fit=max&auto=format&n=95dm67yuCOH_Jo0o&q=85&s=ff22b41865fa5b90f1d7a32b32abd33b" alt="A screenshot showing the MPGS credential fields." className="mx-auto block rounded-lg object-cover border border-gray-200" width="80%" data-path="images/docs/mpgs-image-04.png" />

***

### Webhooks or notifications

Payrails sends its notification URL to MPGS with every payment, so you don't need to set one up in the MPGS dashboard. Payrails verifies each notification with your notification secret.

***

## Request fields for Mastercard Payment Gateway Services

Send these fields in the [authorize request](/reference/authorizeaction) for card payments, in addition to the standard authorize fields. **Required** fields must be present for the payment to succeed. Payrails sends **Optional** fields to Mastercard Payment Gateway Services when you include them. For more about meta fields, refer to [Meta fields](/docs/orchestration/meta-fields).

| Field | Status | Description |
| :- | :- | :- |
| `amount` | Required | Sent to MPGS as the order amount and currency. |
| `merchantReference` | Required | Sent as the order ID. |
| `meta.order.reference` | Optional | Sent as the order reference. Payrails uses `merchantReference` when it's missing. |
| `meta.customer.email`, `name`, `lastName` | Optional | Sent as the customer details. |
| `meta.order.billingAddress` | Optional | Sent as the billing address. |
| `meta.order.deliveryAddress` | Optional | Sent as the shipping address. |

***

## Enable the integration

**In Payrails**

* Select **Save account** to enable the integration.
* Confirm the integration shows as **Enabled**.

Your **Mastercard Payment Gateway Services** integration is now ready to process payments.

***

## Next steps

1. Run a test payment using an MPGS [test card](https://test-gateway.mastercard.com/api/documentation/integrationGuidelines/supportedFeatures/testAndGoLive.html) on your test host.
2. Verify that:
   * The payment appears in MPGS Merchant Administration.
   * The payment status updates correctly in Payrails.
3. Once verified in test mode, repeat the setup with your live host.

→ Continue to: [Test a payment](/docs/orchestration/payment-acceptance/test-payments)


## Related topics

- [Integrations](/docs/orchestration/integrations.md)
- [Network Tokens](/docs/token-vault/network-tokens.md)
- [SDK API Reference](/docs/orchestration/checkout-sdks/android/api-reference.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.