# Mercado Pago
source: https://developer.mastercard.com/mastercard-gateway/documentation/payment-methods/alt-pay-methods/a2a/mercado-pago/index.md

Mercado Pago is a processor that provides services in the Latin American region and it offers support for a wide range of acquirers and alternative payment methods. Mercado Pago Checkout is one of the payment options for Mercado Pago. This integration allows you to charge your customers through a web form on any device. The gateway has support for Mercado Pago Checkout, through which payers are redirected to a page that Mercado Pago has provided. Mercado Pago checkout is the payment method that is offered to you when MSO provides the Mercado Pago merchant-acquirer link to you. Once your payment service provider creates and approves the merchant-acquirer link, you can offer this payment method through their ecommerce solution.

## Prerequisites {#prerequisites}

To use the Mercado Pago payment method through the Mastercard Gateway:

* Be registered with your browser payments service provider.
* Your merchant profile on the Mastercard Gateway must be configured using the details of your account with the browser payments service provider.
* You must have a bank account in one of the supported currencies that is registered against your merchant account at your browser payments service provider.
* You must get your access token details from Mercado Pago to get it configured on the gateway before you start offering Mercado Pago as a payment method.

## Mercado Pago transactions {#mercado-pago-transactions}

Mercado Pago supports transactions originating from multiple countries with their corresponding currencies.

|  Country  | Currency |
|-----------|----------|
| Argentina | ARS      |
| Brazil    | BRL      |
| Mexico    | MXN      |

## Mercado Pago integration {#mercado-pago-integration}

### Mercado Pago through Hosted Checkout {#mercado-pago-through-hosted-checkout}

Hosted Checkout integration allows you to collect payment details from your payer through an interaction that the Mastercard Gateway hosts and displays.

From the API version 63 and later, Mercado Pago is automatically available as a payment method once your payment service provider enables and configures you for this payment method. The Mercado Pago payment method on Modern-Hosted Checkout supports the following payment flow.

1. Payers can select Mercado Pago as the payment method on the hosted checkout screen.
2. Once payers select the Mercado Pago payment method, the payer's browser is redirected to the Mercado Pago website for payment initiation.
3. After the payment process is complete on the Mercado Pago website, payers are redirected to your website. The order confirmation receipt displays to payers.

### Mercado Pago through Direct Payment {#mercado-pago-through-direct-payment}

Direct Payment integration allows you to offer the Mercado Pago payment method on your own checkout page.

Alert: Mercado Pago is supported from Mastercard Gateway API version 58 and later.

<br />

Submit the Mastercard Gateway API INITIATE_BROWSER_PAYMENT operation with

* `sourceOfFunds.type`=MERCADO_PAGO_CHECKOUT
* `browserPayment.operation`=PAY

### Sample Code to initiate Mercado Pago Payment {#sample-code-to-initiate-mercado-pago-payment}

```json
{
  "apiOperation": "INITIATE_BROWSER_PAYMENT",
  "browserPayment": {
    "operation": "PAY",
    "returnUrl": "<your_merchant_URL>"
  },
  "customer": {
    "email": "john.smith@example.com"
  },
  "order": {
    "amount": "200",
    "currency": "BRL"
  },
  "sourceOfFunds": {
    "type": "MERCADO_PAGO_CHECKOUT",
    "provided": {
      "Mercado Pago": {
        "bankAccountHolder": "John Smith"
      }
    }
  }
}
```

## How to Interpret the Transaction Result {#how-to-interpret-the-transaction-result}

The table specifies the transaction Response Codes for the possible scenarios that you may encounter after initiating the Mercado Pago payment.

|                      Initiate Browser Payment Response                      |                                                                                                                     What This Means...                                                                                                                      |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `response.gatewayCode=SUBMITTED` `result=SUCCESS`                           | Redirect the payer using the URL provided in the response.                                                                                                                                                                                                  |
| **Retrieve Transaction/Retrieve Order Response**                            | **What This Means...**                                                                                                                                                                                                                                      |
| `response.gatewayCode=APPROVED` `result=SUCCESS`                            | The payment is successful.                                                                                                                                                                                                                                  |
| `response.gatewayCode=PENDING` `result=PENDING`                             | The Mastercard Gateway is waiting for a notification from the acquirer about the payment result. Try `RETRIEVE_TRANSACTION` again later or listen to notifications from the Mastercard Gateway.                                                             |
| `response.gatewayCode=CANCELLED` `result=FAILURE`                           | The payer has canceled the interaction for this payment. Offer the payer the option to try another payment method.                                                                                                                                          |
| `response.gatewayCode=DECLINED` or `ACQUIRER_SYSTEM_ERROR` `result=FAILURE` | The payment was declined. Offer the payer the option to try another payment method. In case of an `ACQUIRER_SYSTEM_ERROR`, you may want to inquire with the acquirer about the reason for the payment failure, or you can try `RETRIEVE_TRANSACTION` again. |
| `response.gatewayCode=TIMED_OUT` `result=FAILURE`                           | Treat this as a declined payment. The Mastercard Gateway will attempt to ensure that the transaction is not successful or will revert the transaction.                                                                                                      |

## Void {#void}

You can cancel the Mercado Pago payment only under the following conditions:

* If the payer is not redirected to Mercado Pago, then the gateway updates the order status to CANCELLED.
* If a payment is created and is in the pending or in progress state, then the payment by default gets updated to the canceled state and the gateway updates the order status to CANCELLED.

## Refunds {#refunds}

You can refund the Mercado Pago payments in installments or in full. Ensure that you are configured for refunds on the Mastercard Gateway on your merchant account at your browser payments service provider. Partial refunds are allowed on the Mercado Pago payments.

## Test your integration with the Sandbox {#test-your-integration-with-the-sandbox}

The Mastercard Gateway provides a browser payments emulator that allows you to \[test your integration with the Mercado Pago Sandbox\].

#### Mercado Pago {#mercado-pago}

You can use test cards of the local payment methods and simulate different payment responses, without using a real card. Use any one card that is provided in the link for [ARS](https://www.mercadopago.com.ar/developers/en/docs/checkout-pro/integration-test/test-purchases), [BRL](https://www.mercadopago.com.br/developers/en/docs/checkout-pro/integration-test/test-purchases), and [MXN](https://www.mercadopago.com.mx/developers/en/docs/checkout-pro/integration-test/test-purchases). Ensure to use these details with the non-test merchants the Mercado Pago Sandbox.

The following table describes the payment results status that you can use to fill against the cardholder's name:

| Payment Status |        Description         | Transaction response gateway code |
|----------------|----------------------------|-----------------------------------|
| APRO           | Approved payment           | APPROVED                          |
| OTHE           | Declined for general error | TIMED_OUT                         |
| CONT           | Pending payment            | PENDING                           |

Warning: As the request is routed to the Mercado Pago Sandbox, you can test these credentials only with the non-test merchants.

The Test Card details might change as Mercado Pago hosts the URL. Use your Mercado Pago Sandbox credentials to test with the Sandbox.
