Other features - Checkout API - Mercado Pago Developers
Developers
API Reference
Support
Sign in

    Home

    Getting started

    Online Payments

    Checkout Pro

    Checkout API

    Payment Link

    Subscriptions

    Marketplace

    Mobile Checkout

    Web Tokenize Checkout

    In person payments

    QR Code

    Mercado Pago Point

    Plugins and platforms

    WooCommerce

    Prestashop

    Magento 2

    Shopify

    Tiendanube

    VTEX

    SDKs

    Notifications

    Webhooks

    IPN

    Account Management

    Requirements for production environment

    Get payments

    Reports

    Cashback and Cancellations

    Chargeback Management

    Improves approval

    Resources

    Localization

    Changelog

    Status

IN THIS PAGE

Suggest edit
Help us improve the documentation
Did you see wrong information and would you like us to explain something else or improve our manuals? Please leave your suggestions on GitHub.

Payment authorization and capture

Add specific features to your integration based on your business needs.

Offer the possibility of granting an authorization before payment capture. This allows you to make a fund reserve in your buyer's card without making a payment.

For example, to grant an authorization when you reserve a car, or for an estimated purchase price prior to confirmation.

Reserve Funds

For fund reserve authorization, you just need to add the capture=false attribute like this:

  • php
  • java
  • node
  • ruby
          
<?php

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

  $payment = new MercadoPago\Payment();

  $payment->transaction_amount = 100;
  $payment->token = "ff8080814c11e237014c1ff593b57b4d";
  $payment->description = "Title of what you are paying for";
  $payment->installments = 1;
  $payment->payment_method_id = "visa";
  $payment->payer = array(
    "email" => "test_user_19653727@testuser.com"
  );

  $payment->capture=false;

  $payment->save();

?>

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

Payment payment = new Payment();

payment.setTransactionAmount(100f)
      .setToken('ff8080814c11e237014c1ff593b57b4d')
      .setDescription('Title of what you are paying for')
      .setInstallments(1)
      .setPaymentMethodId("visa")
      .setPayer(new Payer("test_user_19653727@testuser.com"))
      .setCapture(false);

payment.save();


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

var payment_data = {
  transaction_amount: 100,
  token: 'ff8080814c11e237014c1ff593b57b4d'
  description: 'Title of what you are paying for',
  installments: 1,
  payment_method_id: 'visa',
  payer: {
    email: 'test_user_3931694@testuser.com'
  },
  capture: false
};

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

}).catch(function (error) {

});


        
          
require 'mercadopago'
MercadoPago::SDK.configure(ACCESS_TOKEN: ENV_ACCESS_TOKEN)

payment = MercadoPago::Payment.new()
payment.transaction_amount = 100
payment.token = 'ff8080814c11e237014c1ff593b57b4d'
payment.description = 'Title of what you are paying for'
payment.installments = 1
payment.payment_method_id = "visa"
payment.payer = {
  email: "test_user_19653727@testuser.com"
}
payment.capture = false
payment.save()

        

The response indicates that the payment is authorized and pending to capture.

json

{
  "id": PAYMENT_ID,
  ...
  "status": "authorized",
  "status_detail": "pending_capture",
  ...
  "captured": false,
  ...
}

It can be rejected or remain pending. Take into account that authorized funds cannot be used by your customer until captured. You need to make the capture as soon as possible.

Important
  • The reserve will be valid for 7 days. If you don't capture it within this term, it will be cancelled.
  • You need to save the payment ID to complete the process.
  • Capture an authorized payment

    To complete the payment, you need to capture the funds reserved for your customer. You can capture the amount, entirely or partially.

          Capture the entire amount

    To capture the full amount, you just need to submit the capture attribute as true.

    • php
    • java
    • node
    • ruby
    • curl
              
    <?php
    
      MercadoPago\SDK::setAccessToken("ENV_ACCESS_TOKEN");
    
      $payment = MercadoPago\Payment::find_by_id($payment_id);
      $payment->capture = true;
      $payment->update();
    ?>
    
            
              
    import com.mercadopago.*;
    MercadoPago.SDK.configure("ENV_ACCESS_TOKEN");
    
    Payment payment = Payment.load(paymentId);
    payment.capture = true;
    payment.update();
    
            
              
    var mercadopago = require('mercadopago');
    mercadopago.configurations.setAccessToken(config.access_token);
    
    let paymentId = 123;
    
    mercadopago.payment.capture(paymentId, mercadopago, (error, response) => {
        if (error){
            console.log(error);
        }else{
            console.log(response)
        }
    });
    
            
              
    require 'mercadopago'
    MercadoPago::SDK.configure(ACCESS_TOKEN: ENV_ACCESS_TOKEN)
    
    payment = MercadoPago::Payment.load(paymentId)
    payment.capture=true
    payment.update()
    
            
              
    curl -X PUT \
      'https://api.mercadopago.com/v1/payments/PAYMENT_ID' \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
      -d '{"capture": true}'
    
            

    The answer will return that the payment is approved and accredited.

    json

    {
      ...
      "status": "approved",
      "status_detail": "accredited",
      ...
      "captured": true,
      ...
    }
    Note
    If you don't add an amount, the total reserved amount will be captured.

    Capture payments for less than the reserved amount

    To capture an amount lower than the reserve, you need to submit the transaction_amount attribute with the new value.

    • php
    • java
    • node
    • ruby
    • curl
              
    <?php
    
      MercadoPago\SDK::setAccessToken("ENV_ACCESS_TOKEN");
    
      $payment = MercadoPago\Payment::find_by_id($payment_id);
      $payment->transaction_amount = 75;
      $payment->capture = true;
      $payment->update();
    ?>
    
            
              
    import com.mercadopago.*;
    MercadoPago.SDK.configure("ENV_ACCESS_TOKEN");
    
    
    Payment payment = Payment.load(paymentId);
    payment.transaction_amount = 75;
    payment.capture = true;
    payment.update();
    
            
              
    var mercadopago = require('mercadopago');
    mercadopago.configurations.setAccessToken(config.access_token);
    
    let captureInfo = {id: 123, transaction_amount: 5}
    
    mercadopago.payment.capturePartial(captureInfo, mercadopago, (error, response) => {
        if (error){
            console.log(error);
        }else{
            console.log(response)
        }
    });
    
            
              
    require 'mercadopago'
    MercadoPago::SDK.configure(ACCESS_TOKEN: ENV_ACCESS_TOKEN)
    
    payment = MercadoPago::Payment.load(paymentId)
    payment.transaction_amount = 75
    payment.capture=true
    payment.update()
    
            
              
    curl -X PUT \
      'https://api.mercadopago.com/v1/payments/PAYMENT_ID' \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
      -d '{
              "transaction_amount": 75,
              "capture": true
    }'
    
            

          Response

    json

    {
      ...
      "status": "approved",
      "status_detail": "accredited",
      ...
      "transaction_amount": 75,
      ...
      "captured": true,
      ...
    }
    Note
    You cannot capture an amount higher than the reserve; to do so, you need to cancel and make a new reserve.

    Cancel a reserve

    If you update payment status to cancelled, you can cancel a reserve and release the card money.

    • php
    • java
    • node
    • ruby
    • curl
              
    <?php
    
      MercadoPago\SDK::setAccessToken("ENV_ACCESS_TOKEN");
    
      $payment = MercadoPago\Payment::find_by_id($payment_id);
      $payment->status = "cancelled";
      $payment->update();
    ?>
    
            
              
    import com.mercadopago.*;
    MercadoPago.SDK.configure("ENV_ACCESS_TOKEN");
    
    
    Payment payment = Payment.load(paymentId);
    payment.status = "canceled";
    payment.update();
    
            
              
    var mercadopago = require('mercadopago');
    mercadopago.configurations.setAccessToken(config.access_token);
    
    let paymentToBeCanceled = 123;
    
    mercadopago.payment.cancel(paymentToBeCanceled, mercadopago, (error, response) => {
        if (error){
            console.log(error);
        }else{
            console.log(response)
        }
    });
    
            
              
    require 'mercadopago'
    MercadoPago::SDK.configure(ACCESS_TOKEN: ENV_ACCESS_TOKEN)
    
    payment = MercadoPago::Payment.load(paymentId)
    payment.status = "canceled"
    payment.update()
    
            
              
    curl -X PUT \
      'https://api.mercadopago.com/v1/payments/PAYMENT_ID' \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
      -d '{"status": "cancelled"}'
    
            

          Response

    json

    {
      ...
      "status": "cancelled",
      "status_detail": "by_collector",
      ...
      "captured": false,
      ...
    }

    Next steps

    REQUIRED

    Requirements for the production environment

    Learn all the requirements needed to start receiving payments.

    RECOMMENDED

    API References

    Find all the information required to interact with our APIs.

    Was this information helpful?

    Copyright © 2021 MercadoLibre S. de R.L. de C.V.

    Terms and conditionsHow we take care of your privacy
    Partners Mercado Pago

    Al navegar en este sitio aceptas las cookies que utilizamos para mejorar tu experiencia. Más información.