Other payment methods - Integration configuration - Mercado Pago Developers

Other payment methods

With Mercado Pago's Checkout API, it is also possible to offer payments through PagoEfectivo.

To get a detailed list of all payment methods available for integration, send a GET with your Access token to the endpoint /v1/payment_methods and run the request or, if you prefer, make the request using the SDKs below.

          
<?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;

        
          
MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN");

PaymentMethodClient client = new PaymentMethodClient();
client.list();


        
          
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 market
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' \

        

To offer PagoEfectivo payments, please follow the steps below.

Import MercadoPago.js

To perform the Checkout API integration, you need to capture the necessary data to process the payment.

This capture is made by including the MercadoPago.js library in your project, followed by the payment form. Use the code below to import the library before adding the payment form.

          
<body>
<script src="https://sdk.mercadopago.com/js/v2"></script>
</body>

        

Configure credentials

Credentials are unique passwords with which we identify an integration in your account. They are made to capture payments in virtual stores and other applications securely.

This is the first step of a complete code structure that must be followed for the correct integration of the payment flow. Pay attention to the blocks below to add to the codes as indicated.

          
const mp = new MercadoPago('YOUR_PUBLIC_KEY');

        

Add payment form

With the MercadoPago.js library included, add the payment form below to your project to ensure the secure capture of buyer data. In this step, it is important to use the list you consulted to obtain the available payment methods to create the payment options you want to offer.

[

          
  <form id="form-checkout" action="/process_payment" method="post">
    <div>
      <div>
        <label for="payerFirstName">Name</label>
        <input id="form-checkout__payerFirstName" name="payerFirstName" type="text">
      </div>
      <div>
        <label for="payerLastName">Last name</label>
        <input id="form-checkout__payerLastName" name="payerLastName" type="text">
      </div>
      <div>
        <label for="email">E-mail</label>
        <input id="form-checkout__email" name="email" type="text">
      </div>
      <div>
        <label for="identificationType">Type of document</label>
        <select id="form-checkout__identificationType" name="identificationType" type="text"></select>
      </div>
      <div>
        <label for="identificationNumber">Document number</label>
        <input id="form-checkout__identificationNumber" name="identificationNumber" type="text">
      </div>
    </div>

    <div>
      <div>
        <input type="hidden" name="transactionAmount" id="transactionAmount" value="100">
        <input type="hidden" name="description" id="description" value="Nome do Produto">
        <br>
        <button type="submit">Pay</button>
      </div>
    </div>
  </form>

        

Get document types

After configuring the credential, it is necessary to obtain the types of documents that will be part of filling out the payment form.

By including the element of type select with the id: id = docType that is on the form, it will be possible to automatically fill in the available options when calling the following function:

          
(async function getIdentificationTypes() {
try {
const identificationTypes = await mp.getIdentificationTypes();
const identificationTypeElement = document.getElementById('form-checkout__identificationType');

createSelectOptions(identificationTypeElement, identificationTypes);
} catch (e) {
return console.error('Error getting identificationTypes: ', e);
}
})();

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);
}

        

Send payment

When finalizing the inclusion of the payment form and obtaining the types of documents, it is necessary to forward the buyer's email, type and document number, the payment method used and the details of the amount to be paid using our Payments API or one of our SDKs.

To configure payments with PagoEfectivo, send a POST with the required parameters to the endpoint /v1/payments and execute the request or, if you prefer, use one of our SDKs below.

Important
For this step, when making the request via API or SDKs, it is necessary to send your Private Key - Access token.
          
<?php

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

$payment = new MercadoPago\Payment();
$payment->transaction_amount = 100;
$payment->description = "Product title";
$payment->payment_method_id = "payment_atm";
$payment->payer = array(
"email" => "test_user_42972582@testuser.com"
);

$payment->save();
?>

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

var payment_data = {
transaction_amount: 100,
description: 'Product title',
payment_method_id: 'pagoefectivo_atm',
payer: {
email: 'test_user_42972582@testuser.com'
}
};

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

}).catch(function(error) {

});


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

Payment payment = new Payment();

payment.setTransactionAmount(100f)
.setDescription("Product Title")
.setPaymentMethodId("pagoefectivo_atm")
.setPayer(new Payer("test_user_42972582@testuser.com"));

payment.save();

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

payment_request = {
transaction_amount: 100,
description: 'Product title',
payment_method_id: 'pagoefectivo_atm',
payer: {
email: 'test_user_42972582@testuser.com'
}
}

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

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

MercadoPagoConfig.AccessToken = "ENV_ACCESS_TOKEN";

var request = new PaymentCreateRequest
{
TransactionAmount = 5000,
Description = "Product Title",
PaymentMethodId = "paypayment_atm",
Payer = new PaymentPayerRequest
{
Email = "test_user_42972582@testuser.com",
},
};

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


        
          
import market
sdk = Mercadopago.SDK("ENV_ACCESS_TOKEN")

payment_data = {
"transaction_amount": 100,
"description": "Product title",
"payment_method_id": "payment_atm",
"payer": {
"email": "test_user_42972582@testuser.com"
}
}

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

        
          
curl -X POST \
'https://api.mercadopago.com/v1/payments' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
-d '{
transaction_amount: 100,
description: "Product Title",
payment_method_id: "paypayment_atm",
payer: { email: "test_user_42972582@testuser.com" }
}'

        

The response will show the pending status until the buyer completes the payment. Also, in the response to the request, the external_resource_url parameter will return a URL that contains instructions for the buyer to make the payment. You can redirect to this same link to complete the payment flow.

json

[
{
...,
"id": 5466310457,
"status": "pending",
"status_detail": "pending_waiting_payment",
...,

"order": {},
"external_reference": null,
"transaction_amount": 100,
"transaction_amount_refunded": 0,
"coupon_amount": 0,
"differential_pricing_id": null,
"deduction_schema": null,
"transaction_details": {
"payment_method_reference_id": "123457986",
"verification_code": "24308767",
"net_received_amount": 0,
"total_paid_amount": 100,
"overpaid_amount": 0,
"external_resource_url": "https://www.mercadopago.com/mpe/payments/sandbox/atm/helper?payment_id=24308766&payment_method_reference_id=24308767&caller_id=537490079&hash=c96a61b0-10f4-40f6-afff-82fc0f0923da",
"installment_amount": 0,
"financial_institution": "PagoEfectivo",
"payable_deferral_period": null,
"acquirer_reference": null
}
}
]

Cancel payment

To avoid billing issues, it is important to cancel overdue payments. Also, keep in mind that it is possible to cancel only payments that are pending or in process.

If a payment expires within 30 days, the cancellation is automatic and the final status of the payment will be canceled or expired. For more information, see the Refunds and Cancellations section.