Other payment methods - Integrate payment methods - Mercado Pago Developers

Integrate other payment methods

With Checkout API of Mercado Pago, you can add alternative payment methods for your customers to make their payments.

How does it work?

To receive other payment methods, you should take into account two aspects:

  1. First, you need a frontend to collect data required for payment.

  2. Then, you need a backend that takes the payment data and can confirm and make the payment.

Both for frontend and backend, we recommend our libraries to collect user sensitive data securely.

Check the available payment methods

Payment Methods

In addition to cards and Pix, you can offer other payment choices on your website.

Type of payment methodPayment method
ticketBoleto
ticketPagamento em lotérica

Obtain the available payment methods

You can check the available payment methods whenever you need.

          
<?php

  MercadoPago\SDK::setAccessToken("ENV_ACCESS_TOKEN");

  $payment_methods = MercadoPago::get("/v1/payment_methods");

?>

        
          
var mercadopago = require('mercadopago');
mercadopago.configurations.setAccessToken(config.access_token);

var response = await mercadopago.payment_methods.listAll();
var payment_methods = response.body;

        
          
import com.mercadopago.*;
MercadoPago.SDK.configure("ENV_ACCESS_TOKEN");

new PaymentMethod();
MPResourceArray methods = PaymentMethod.all();


        
          
require 'mercadopago'
sdk = Mercadopago::SDK.new('ENV_ACCESS_TOKEN')

payment_methods_response = sdk.payment_methods.get()
payment_methods = payment_methods_response[:response]


        
          
using MercadoPago.Client.PaymentMethod;
using MercadoPago.Config;
using MercadoPago.Resource;
using MercadoPago.Resource.PaymentMethod;

MercadoPagoConfig.AccessToken = "ENV_ACCESS_TOKEN";

var client = new PaymentMethodClient();
ResourcesList<PaymentMethod> paymentMethods = await client.ListAsync();


        
          
import mercadopago
sdk = mercadopago.SDK("ACCESS_TOKEN")

payment_methods_response = sdk.payment_methods().list_all()
payment_methods = payment_methods_response["response"]

        
          
curl -X GET \
    -H 'accept: application/json' \
    -H 'content-type: application/json' \
    -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
    'https://api.mercadopago.com/v1/payment_methods'

        

The result will be a list of payment methods and their features. For example, payment_type_id payment methods with ticket as value refer to cash payment.

Keep in mind that the answer will return all the payments methods. For this reason, you have to filter the options you want to offer according to the list of available payment methods.

json

[
    {
        "id": "bolbradesco",
        "name": "Boleto",
        "payment_type_id": "ticket",
        "status": "active",
        "secure_thumbnail": "https://www.mercadopago.com/org-img/MP3/API/logos/bolbradesco.gif",
        "thumbnail": "http://img.mlstatic.com/org-img/MP3/API/logos/bolbradesco.gif",
        "deferred_capture": "does_not_apply",
        "settings": [],
        "additional_info_needed": []
    },
    {
        "id": "pec",
        "name": "Pagamento na lotérica sem boleto",
        "payment_type_id": "ticket",
        "status": "active",
        "secure_thumbnail": "https://www.mercadopago.com/org-img/MP3/API/logos/pec.gif",
        "thumbnail": "https://www.mercadopago.com/org-img/MP3/API/logos/pec.gif",
        "deferred_capture": "supported",
        "settings": [],
        "additional_info_needed": []
    },
    {
        "id": "pix",
        "name": "PIX",
        "payment_type_id": "bank_transfer",
        "status": "active",
        "secure_thumbnail": "https://www.mercadopago.com/org-img/MP3/API/logos/pix.gif",
        "thumbnail": "https://www.mercadopago.com/org-img/MP3/API/logos/pix.gif",
        "deferred_capture": "does_not_apply",
        "settings": [],
        "additional_info_needed": []
    },
    {
        "...": "..."
    }
]
For more information, check .

Data capture for payment

Client-Side

1. Use MercadoPago.js library

Remember to use our official library to access Mercado Pago API from your application and collect data securely.

html

<script src="https://sdk.mercadopago.com/js/v2"></script>
This documentation uses the new MercadoPago.js V2 version. To see the previous version, go to the .

2. Add payment form

To capture sensitive data from your customer, please use our form with the corresponding attributes, which ensures information security.

Use the list you consulted in Obtain the available payment methods to create the payment options you want to offer.

Add the following form with the styles you want.

html

<form action="/process_payment" method="post" id="paymentForm">
    <h3>Payment method</h3>
    <div>
      <select class="form-control" id="paymentMethod" name="paymentMethod">
        <option>Select a payment form</option>

        <!-- Create an option for each payment method with their name and complete the ID in the attribute 'value'. -->
        <option value="--PaymentId--">--PaymentTypeName--</option>
      </select>
    </div>
    <h3>Buyer Details</h3>
    <div>
    <div>
        <label for="payerFirstName">Name</label>
        <input id="payerFirstName" name="payerFirstName" type="text" value="Nome">
      </div>
      <div>
        <label for="payerLastName">Surname</label>
        <input id="payerLastName" name="payerLastName" type="text" value="Sobrenome">
      </div>
      <div>
        <label for="payerEmail">E-mail</label>
        <input id="payerEmail" name="payerEmail" type="text" value="test@test.com">
      </div>
      <div>
        <label for="docType">Document Type</label>
        <select id="docType" name="docType" data-checkout="docType" type="text"></select>
      </div>
      <div>
        <label for="docNumber">Document Number</label>
        <input id="docNumber" name="docNumber" data-checkout="docNumber" type="text">
      </div>
    </div>

    <div>
      <div>
        <input type="hidden" name="transactionAmount" id="transactionAmount" value="100">
        <input type="hidden" name="productDescription" id="productDescription" value="Product name">
        <br>
        <button type="submit">Pay</button>
        <br>
      </div>
  </div>
</form>

3. Configure your public key

Add your public key like this:

javascript

const mp = new MercadoPago("YOUR_PUBLIC_KEY");
If you still don't have an account to check your credentials, .

4. Get data for your form

Get document types

Document type is one of the mandatory fields. Use the document list to fill out your data.

When you call the next function, MercadoPago.js will automatically fill out the available options, including the select type element with id = docType in the form:

javascript

// Step #getIdentificationTypes

// Helper function to append option elements to a select input
function createSelectOptions(elem, options, labelsAndKeys = { label : "name", value : "id"}){
   const {label, value} = labelsAndKeys;

   elem.options.length = 0;

   const tempOptions = document.createDocumentFragment();

   options.forEach( option => {
       const optValue = option[value];
       const optLabel = option[label];

       const opt = document.createElement('option');
       opt.value = optValue;
       opt.textContent = optLabel;

       tempOptions.appendChild(opt);
   });

   elem.appendChild(tempOptions);
}

// Get Identification Types
(async function getIdentificationTypes () {
   try {
       const identificationTypes = await mp.getIdentificationTypes();
       const docTypeElement = document.getElementById('docType');

       createSelectOptions(docTypeElement, identificationTypes)
   }catch(e) {
       return console.error('Error getting identificationTypes: ', e);
   }
})()
Find more information in the .

Receive payments with boleto or lotérica

Server-Side

After capturing the data for payment with the form, to receive payments with boleto or lotérica, just send your customer's e-mail and document, amount and payment method.

Once the request –with all the collected information– is in your backend, it should be submitted to Mercado Pago through our APIs.

For this to work, you should configure your private key.

          
<?php

 require_once 'vendor/autoload.php';

 MercadoPago\SDK::setAccessToken("ENV_ACCESS_TOKEN");

 $payment = new MercadoPago\Payment();
 $payment->transaction_amount = 100;
 $payment->description = "Product Title";
 $payment->payment_method_id = "bolbradesco";
 $payment->payer = array(
     "email" => "test@test.com",
     "first_name" => "Test",
     "last_name" => "User",
     "identification" => array(
         "type" => "CPF",
         "number" => "19119119100"
      ),
     "address"=>  array(
         "zip_code" => "06233200",
         "street_name" => "Av. das Nações Unidas",
         "street_number" => "3003",
         "neighborhood" => "Bonfim",
         "city" => "Osasco",
         "federal_unit" => "SP"
      )
   );

 $payment->save();

?>

        
          
var mercadopago = require('mercadopago');
mercadopago.configurations.setAccessToken(config.access_token);

var payment_data = {
  transaction_amount: 100,
  description: 'Product Title',
  payment_method_id: 'bolbradesco',
  payer: {
    email: 'test@test.com',
    first_name: 'Test',
    last_name: 'User',
    identification: {
        type: 'CPF',
        number: '19119119100'
    },
    address:  {
        zip_code: '06233200',
        street_name: 'Av. das Nações Unidas',
        street_number: '3003',
        neighborhood: 'Bonfim',
        city: 'Osasco',
        federal_unit: 'SP'
    }
  }
};

mercadopago.payment.create(payment_data).then(function (data) {

}).catch(function (error) {

});


        
          
PaymentClient client = new PaymentClient();

PaymentCreateRequest paymentCreateRequest =
   PaymentCreateRequest.builder()
       .transactionAmount(new BigDecimal("100"))
       .description("Título do produto")
       .paymentMethodId("bolbradesco")
       .dateOfExpiration(OffsetDateTime.of(2023, 1, 10, 10, 10, 10, 0, ZoneOffset.UTC))
       .payer(
           PaymentPayerRequest.builder()
               .email("test@test.com")
               .firstName("Test")
               .lastName("User")
               .identification(
                   IdentificationRequest.builder().type("CPF").number("19119119100").build())
               .build())
       .build();

client.create(paymentCreateRequest);

        
          
require 'mercadopago'
sdk = Mercadopago::SDK.new('ENV_ACCESS_TOKEN')

payment_request = {
  transaction_amount: 100,
  description: 'Product Title',
  payment_method_id: 'bolbradesco',
  payer: {
    email: 'test@test.com',
    first_name: 'Test',
    last_name: 'User',
    identification: {
      type: 'CPF',
      number: '19119119100',
    },
    address: {
      zip_code: '06233200',
      street_name: 'Av. das Nações Unidas',
      street_number: '3003',
      neighborhood: 'Bonfim',
      city: 'Osasco',
      federal_unit: 'SP'
    }
  }
}

payment_response = sdk.payment.create(payment_request)
payment = payment_response[:response]


        
          
using MercadoPago.Config;
using MercadoPago.Client.Common;
using MercadoPago.Client.Payment;
using MercadoPago.Resource.Payment;

MercadoPagoConfig.AccessToken = "ENV_ACCESS_TOKEN";

var request = new PaymentCreateRequest
{
    TransactionAmount = 105,
    Description = "Product Title",
    PaymentMethodId = "bolbradesco",
    Payer = new PaymentPayerRequest
    {
        Email = "test@test.com",
        FirstName = "Test",
        LastName = "User",
        Identification = new IdentificationRequest
        {
            Type = "CPF",
            Number = "191191191-00",
        },
    },
};

var client = new PaymentClient();
Payment payment = await client.CreateAsync(request);


        
          
import mercadopago
sdk = mercadopago.SDK("ENV_ACCESS_TOKEN")

payment_data = {
    "transaction_amount": 100,
    "description": "Product Title",
    "payment_method_id": "bolbradesco",
    "payer": {
        "email": "test@test.com",
        "first_name": "Test",
        "last_name": "User",
        "identification": {
            "type": "CPF",
            "number": "191191191-00"
        },
        "address": {
            "zip_code": "06233-200",
            "street_name": "Av. das Nações Unidas",
            "street_number": "3003",
            "neighborhood": "Bonfim",
            "city": "Osasco",
            "federal_unit": "SP"
        }
    }
}

payment_response = sdk.payment().create(payment_data)
payment = payment_response["response"]

        
          
curl -X POST \
    -H 'accept: application/json' \
    -H 'content-type: application/json' \
    -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
    'https://api.mercadopago.com/v1/payments' \
    -d '{
      "transaction_amount": 100,
      "description": "Product Title",
      "payment_method_id": "bolbradesco",
      "payer": {
        "email": "test@test.com",
        "first_name": "Test",
        "last_name": "User",
        "identification": {
            "type": "CPF",
            "number": "19119119100"
        },
        "address": {
            "zip_code": "06233200",
            "street_name": "Av. das Nações Unidas",
            "street_number": "3003",
            "neighborhood": "Bonfim",
            "city": "Osasco",
            "federal_unit": "SP"
        }
      }
    }'

        

The response will show pending status until the buyer makes the payment. The payment voucher ID is the same as the Mercado Pago transaction ID.

json

[
{
    ...,
    "id": 5466310457,
    "status": "pending",
    "status_detail": "pending_waiting_payment",
    ...,
    "transaction_details": {
        "net_received_amount": 0,
        "total_paid_amount": 100,
        "overpaid_amount": 0,
        "external_resource_url": "https://www.mercadopago.com/mlb/payments/ticket/helper?payment_id=123456789&payment_method_reference_id= 123456789&caller_id=123456",
        "installment_amount": 0,
        "financial_institution": null,
        "payment_method_reference_id": "1234567890"
    }
}
]

In the external_resource_url field you will find an address with payment instructions for your buyer. You can redirect or send him/her the link.

Note
Customers have 3 to 5 days to pay, depending on the payment method. After that, you should cancel it.

Payments date of expiration

Boleto payments

The default expiration date for boleto payments is 3 days. If you want, you can change this date by sending the date_of_expiration field in the payment creation request. The configured date must be between 1 and 30 days from the issue date.

The date uses the ISO 8601 format: yyyy-MM-dd'T'HH:mm:ssz

          
$payment->date_of_expiration = "2020-05-30T23:59:59.000-04:00";

        

The date uses the ISO 8601 format: yyyy-MM-dd'T'HH:mm:ssz

          
date_of_expiration: "2020-05-30T23:59:59.000-04:00",

        

The date uses the ISO 8601 format: yyyy-MM-dd'T'HH:mm:ssz

          
payment.setDateOfExpiration("2020-05-30T23:59:59.000-04:00")

        

The date uses the ISO 8601 format: yyyy-MM-dd'T'HH:mm:ssz

          
date_of_expiration: '2020-05-30T23:59:59.000-04:00',

        

The date uses the ISO 8601 format: yyyy-MM-dd'T'HH:mm:ssz

          
paymentCreateRequest.DateOfExpiration = DateTime.Parse("2020-05-30T23:59:59.000-04:00");

        

The date uses the ISO 8601 format: yyyy-MM-dd'T'HH:mm:ssz

          

"date_of_expiration": "2020-05-30T23:59:59.000-04:00"

        

The date uses the ISO 8601 format: yyyy-MM-dd'T'HH:mm:ssz

          
"date_of_expiration": "2020-05-30T23:59:59.000-04:00",

        

The deadline for approval of the boleto is up to 48 working hours. Therefore, we recommend that you set the due date with at least 3 days to ensure that payment is made.

Important
If the boleto is paid after the expiration date, the amount will be refunded to the payer's Mercado Pago account.

Cancel payments

To avoid collection issues, you need to cancel expired payments. Cash payments should be paid within 3 to 5 business days, based on their relevant term.

Take into account that you can only cancel payments in process or pending status. If a payment expires after 30 days, the cancellation is automatic and the final status will be cancelled or expired.

For more information, check the Refunds and Cancellations section.

Payment credit times

Check credit times by payment method whenever you need to.