Armazene os dados dos seus clientes e cartões - Integração avançada - Mercado Pago Developers

Armazene os dados dos seus clientes e cartões

Use nossas APIs para guardar a referência dos cartões dos seus clientes e poder oferecer uma melhor experiência. Dessa maneira, seus clientes não terão que completar seus dados todas as vezes e poderão finalizar seus pagamentos mais rápido.

Crie um cliente e um cartão

Para criar um cliente e associá-lo ao seu cartão, é preciso enviar o campo do e-mail, o tipo de meio de pagamento, o ID do banco emissor e o token gerado. Cada cliente será guardado com o valor customer e cada cartão com o valor card.

          
<?php

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

  $customer = new MercadoPago\Customer();
  $customer->email = "test_payer_12345@testuser.com";
  $customer->save();

  $card = new MercadoPago\Card();
  $card->token = "9b2d63e00d66a8c721607214cedaecda";
  $card->customer_id = $customer->id();
  $card->issuer = array("id" => "3245612");
  $card->payment_method = array("id" => "debit_card");
  $card->save();

?>


        
          
var mercadopago = require('mercadopago');
mercadopago.configure({
    access_token: 'ENV_ACCESS_TOKEN'
});

var customer_data = { "email": "test_payer_12345@testuser.com" }

mercadopago.customers.create(customer_data).then(function (customer) {

  var card_data = {
    "token": "9b2d63e00d66a8c721607214cedaecda",
    "customer_id": customer.id,
    "issuer_id": "23",
    "payment_method_id": "debit_card"
  }

  mercadopago.card.create(card_data).then(function (card) {
    console.log(card);
  });

});


        
          
MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN");

CustomerClient customerClient = new CustomerClient();
CustomerCardClient customerCardClient = new CustomerCardClient();

CustomerRequest customerRequest = CustomerRequest.builder()
   .email("john@test.com")
   .build();
Customer customer = customerClient.create(customerRequest);

CustomerCardIssuer issuer = CustomerCardIssuer.builder()
   .id("3245612")
   .build();

CustomerCardCreateRequest cardCreateRequest = CustomerCardCreateRequest.builder()
   .token("9b2d63e00d66a8c721607214cedaecda")
   .issuer(issuer)
   .paymentMethodId("debit_card")
   .build();

customerCardClient.create(customer.getId(), cardCreateRequest);


        
          
require 'mercadopago'

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

customer_request = {
  email: 'john@yourdomain.com'
}
customer_response = sdk.customer.create(customer_request)
customer = customer_response[:response]

card_request = {
  token: '9b2d63e00d66a8c721607214cedaecda',
  issuer_id: '3245612',
  payment_method_id: 'debit_card'
}
card_response = sdk.card.create(customer['id'], card_request)
card = card_response[:response]


        
          
MercadoPagoConfig.AccessToken = "ENV_ACCESS_TOKEN";

var customerRequest = new CustomerRequest
{
    Email = "test_payer_12345@testuser.com",
};
var customerClient = new CustomerClient();
Customer customer = await customerClient.CreateAsync(customerRequest);

var cardRequest = new CustomerCardCreateRequest
{
    Token = "9b2d63e00d66a8c721607214cedaecda"
};
CustomerCard card = await customerClient.CreateCardAsync(customer.Id, cardRequest);


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

customer_data = {
  "email": "test_payer_12345@testuser.com"
}
customer_response = sdk.customer().create(customer_data)
customer = customer_response["response"]

card_data = {
  "token": "9b2d63e00d66a8c721607214cedaecda",
  "issuer_id": "3245612",
  "payment_method_id": "debit_card"
}
card_response = sdk.card().create(customer["id"], card_data)
card = card_response["response"]


        
          
curl -X POST \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
    'https://api.mercadopago.com/v1/customers' \
    -d '{"email": "test_payer_12345@testuser.com"}'

curl -X POST \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
    'https://api.mercadopago.com/v1/customers/CUSTOMER_ID/cards' \
    -d '{"token": "9b2d63e00d66a8c721607214cedaecda", "issuer": {"id": "3245612"}, "payment_method_id":"debit_card"}'


        

Resposta

json

{
    "id": "123456789-jxOV430go9fx2e",
    "email": "test_payer_12345@testuser.com",
    ...
    "default_card": "1490022319978",
    "default_address": null,
    "cards": [{
        "id": "1490022319978",
        "expiration_month": 12,
        "expiration_year": 2020,
        "first_six_digits": "415231",
        "last_four_digits": "0001",
        ...
    }],
    "addresses": [],
    "live_mode": false
}
Nota
Te recomendamos armazenar os dados do cartão assim que realizar um pagamento de forma exitosa para guardar os dados corretos.
Importante
  • Se você receber uma mensagem de erro do tipo "invalid parameter" com código de estado HTTP 400, certifique-se de que está preenchendo corretamente os campos payment_method_id e issuer_id.
  • Quando utilizando usuários de teste, tenha em mente o seguinte formato para o e-mail do cliente: test_payer_[0-9]{1,10}@testuser.com. Por exemplo: test_payer_12345@testuser.com.
  • Adicione novos cartões a um cliente

    Para adicionar novos cartões a um cliente, deve-se criar um token e fazer um HTTP POST ao customer.

              
    <?php  
    
      MercadoPago\SDK::setAccessToken("ENV_ACCESS_TOKEN");
    
      $customer = MercadoPago\Customer::find_by_id("247711297-jxOV430go9fx2e");
    
      $card = new MercadoPago\Card();
      $card->token = "9b2d63e00d66a8c721607214cedaecda";
      $card->customer_id = $customer->id;
      $card->issuer = array("id" => "3245612");
      $card->payment_method = array("id" => "debit_card");
      $card->save();
    
      print_r($card);
    
    ?>
    
    
            
              
    var mercadopago = require('mercadopago');
    mercadopago.configure({
        access_token: 'ENV_ACCESS_TOKEN'
    });
    
    var filters = {
      id: "247711297-jxOV430go9fx2e"
    };
    
    mercadopago.customers.search({
      qs: filters
    }).then(function (customer) {
      card_data = {
        "token": "9b2d63e00d66a8c721607214cedaecda",
        "customer_id": customer.id,
        "issuer_id": "3245612",
        "payment_method_id": "debit_card"
      }
    
      mercadopago.card.create(card_data).then(function (card) {
        console.log(card);
      });
    });
    
    
    
            
              
    MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN");
    
    CustomerClient customerClient = new CustomerClient();
    CustomerCardClient customerCardClient = new CustomerCardClient();
    
    Customer customer = customerClient.get("247711297-jxOV430go9fx2e");
    
    CustomerCardIssuer issuer = CustomerCardIssuer.builder()
       .id("3245612")
       .build();
    
    CustomerCardCreateRequest cardCreateRequest = CustomerCardCreateRequest.builder()
       .token("9b2d63e00d66a8c721607214cedaecda")
       .issuer(issuer)
       .paymentMethodId("debit_card")
       .build();
    
    customerCardClient.create(customer.getId(), cardCreateRequest);
    
    
            
              
    require 'mercadopago'
    
    sdk = Mercadopago::SDK.new('ENV_ACCESS_TOKEN')
    
    customer_response = sdk.customer.get('247711297-jxOV430go9fx2e')
    customer = customer_response[:response]
    
    card_request = {
      token: '9b2d63e00d66a8c721607214cedaecda',
      issuer_id: '3245612',
      payment_method_id: 'debit_card'
    }
    card_response = sdk.card.create(customer['id'], card_request)
    card = card_response[:response]
    
    puts card
    
    
            
              
    MercadoPagoConfig.AccessToken = "ENV_ACCESS_TOKEN";
    
    var customerClient = new CustomerClient();
    Customer customer = await customerClient.GetAsync("247711297-jxOV430go9fx2e");
    
    var cardRequest = new CustomerCardCreateRequest
    {
        Token = "9b2d63e00d66a8c721607214cedaecda",
    };
    CustomerCard card = await customerClient.CreateCardAsync(customer.Id, cardRequest);
    
    Console.WriteLine(card.Id);
    
    
            
              
    import mercadopago
    sdk = mercadopago.SDK("ENV_ACCESS_TOKEN")
    
    customer_response = sdk.customer().get("247711297-jxOV430go9fx2e")
    customer = customer_response["response"]
    
    card_data = {
      "token": "9b2d63e00d66a8c721607214cedaecda",
      "issuer_id": "3245612",
      "payment_method_id": "debit_card"
    }
    card_response = sdk.card().create(customer["id"], card_data)
    card = card_response["response"]
    
    print(card)
    
    
            
              
    curl -X GET \
      -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
      'https://api.mercadopago.com/v1/customers/CUSTOMER_ID/cards' \
    
    curl -X POST \
        -H 'Content-Type: application/json' \
        -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
        'https://api.mercadopago.com/v1/customers/CUSTOMER_ID/cards' \
        -d '{"token": "9b2d63e00d66a8c721607214cedaecda", "issuer": {"id": "3245612"}, "payment_method_id":"debit_card"}'
    
    
            

    Resposta

    json

    {
        "id": "1493990563105",
        "expiration_month": 12,
        "expiration_year": 2020,
        "first_six_digits": "503175",
        "last_four_digits": "0604",
        "payment_method": {
            "id": "master",
            "name": "master",
            "payment_type_id": "credit_card",
            "thumbnail": "http://img.mlstatic.com/org-img/MP3/API/logos/master.gif",
            "secure_thumbnail": "https://www.mercadopago.com/org-img/MP3/API/logos/master.gif"
        },
        "security_code": {
            "length": 3,
            "card_location": "back"
        },
        "issuer": {
            "id": 3,
            "name": "Mastercard"
        },
        "cardholder": {
            "name": "Card holdername",
    
            "identification": {
                "number": "12345678",
                "type": "DNI"
            }
    
        },
        "date_created": "2017-05-05T09:22:30.893-04:00",
        "date_last_updated": "2017-05-05T09:22:30.893-04:00",
        "customer_id": "255276729-yLOTNHQjpDWw1X",
        "user_id": "255276729",
        "live_mode": false
    }

    Use cartões guardados para receber um pagamento

    Para que um cliente possa fazer um pagamento com seus dados guardados, é necessário capturar novamente o código de segurança. Mercado Pago não pode armazenar essa informação por questões de segurança.


    1. Mostre os cartões guardados ao seu cliente

    Primeiro, obtenha a lista de cartões guardados para que seu cliente possa escolher com qual irá pagar:

              
    <?php
        $customer = MercadoPago\Customer::find_by_id($id);
        $cards = $customer->cards();
    ?>
    
    
            
              
      var filters = {
        id: customer_id
      };
    
      mercadopago.customers.search({
        qs: filters
      }).then(function (customer) {
        console.log(customer);
      });
    
    
            
              
    MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN");
    
    CustomerClient customerClient = new CustomerClient();
    
    Customer customer = customerClient.get("247711297-jxOV430go9fx2e");
    customerClient.listCards(customer.getId());
    
    
            
              
    cards_response = sdk.card.list(customer_id)
    cards = cards_response[:response]
    
    
            
              
    var customerClient = new CustomerClient();
    ResourcesList<CustomerCard> customerCards = await customerClient.ListCardsAsync("CUSTOMER_ID");
    
    
            
              
    cards_response = sdk.card().list_all(customer_id)
    cards = cards_response["response"]
    
    
            
              
    curl -X GET \
      -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
      'https://api.mercadopago.com/v1/customers/CUSTOMER_ID/cards' \
    
    
            

    Resposta dos dados de um cartão guardado:

    json

    [{
        "id": "1490022319978",
        "expiration_month": 12,
        "expiration_year": 2020,
        "first_six_digits": "415231",
        "last_four_digits": "0001",
        ...
    }]

    E pode criar um formulário da seguinte maneira:

    html

    <li>
       <label>Payment Method:</label>
       <select id="cardId" name="cardId"></select>
    </li>
    <li id="cvv">
       <label for="cvv">Security code:</label>
       <input type="text" id="cvv" placeholder="123" />
    </li>
    <script>
       const customerCards = [{
           "id": "3502275482333",
           "last_four_digits": "9999",
           "payment_method": {
               "name": "amex",
           },
           "security_code": {
               "length": 4,
           }
       }];
    
       // Append customer cards to select element
       const selectElement = document.getElementById('cardId');
       const tmpFragment = document.createDocumentFragment();
       customerCards.forEach(({id, last_four_digits, payment_method}) => {
           const optionElement = document.createElement('option');
           optionElement.setAttribute('value', id)
           optionElement.textContent = `${payment_method.name} ended in ${last_four_digits}`
           tmpFragment.appendChild(optionElement);
       })
       selectElement.appendChild(tmpFragment)
    </script>

    2. Capture o código de segurança

    O cliente precisa inserir o código se segurança em um fluxo similar ao que realizou para a captura dos dados do cartão. Deve criar um token enviando o formulário com o ID do cartão e o código de segurança.

    javascript

    (async function createToken() {
           try {
               const token = await mp.createCardToken({
                   cardId: document.getElementById('cardId').value,
                   securityCode: document.getElementById('cvv').value,
               })
    
                // Use the received token to make a POST request to your backend
               console.log('token received: ', token.id)
           }catch(e) {
               console.error('error creating token: ', e)
           }
       })()
    Esta documentação utiliza a nova versão de MercadoPago.js V2. Para ver a versão anterior, vá para a .

    3. Crie o pagamento

    Uma vez obtido o token, é possível criar o pagamento com o valor correspondente. Ao ser pago com um cartão guardado, deve-se enviar o ID do cliente junto do token.

              
    <?php
    
      MercadoPago\SDK::setAccessToken("ENV_ACCESS_TOKEN");
    
      $payment = new MercadoPago\Payment();
    
      $payment->transaction_amount = 100;
      $payment->token = "ff8080814c11e237014c1ff593b57b4d";
      $payment->installments = 1;
      $payment->payer = array(
            "type" => "customer",
            "id" => "123456789-jxOV430go9fx2e"
        );
    
      $payment->save();
    
    ?>
    
    
            
              
    var mercadopago = require('mercadopago');
    mercadopago.configurations.setAccessToken(config.access_token);
    
    var payment_data = {
      transaction_amount: 100,
      token: 'ff8080814c11e237014c1ff593b57b4d',
      installments: 1,
      payer: {
        type: "customer"
        id: "123456789-jxOV430go9fx2e"
      }
    };
    
    mercadopago.payment.create(payment_data).then(function (data) {
      console.log(data);
    });
    
    
            
              
    MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN");
    
    PaymentClient client = new PaymentClient();
    
    PaymentCreateRequest request = PaymentCreateRequest.builder()
       .transactionAmount(new BigDecimal("100"))
       .installments(1)
       .token("ff8080814c11e237014c1ff593b57b4d")
       .payer(PaymentPayerRequest.builder()
           .type("customer")
           .id("247711297-jxOV430go9fx2e")
           .build())
       .build();
    
    client.create(request);
    
    
            
              
    require 'mercadopago'
    
    sdk = Mercadopago::SDK.new('ENV_ACCESS_TOKEN')
    
    payment_request = {
      token: 'ff8080814c11e237014c1ff593b57b4d',
      installments: 1,
      transaction_amount: 100,
      payer: {
        type: 'customer',
        id: '123456789-jxOV430go9fx2e'
      }
    }
    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 = 100,
        Token = "ff8080814c11e237014c1ff593b57b4d",
        Installments = 1,
        Payer = new PaymentPayerRequest
        {
            Type = "customer",
            Email = "test_payer_12345@testuser.com",
        },
    };
    
    var client = new PaymentClient();
    Payment payment = await client.CreateAsync(request);
    
    
            
              
    import mercadopago
    sdk = mercadopago.SDK("ENV_ACCESS_TOKEN")
    
    payment_data = {
        "transaction_amount": 100,
        "token": 'ff8080814c11e237014c1ff593b57b4d',
        "installments": 1,
        "payer": {
            "type": "customer",
            "id": "123456789-jxOV430go9fx2e"
        }
    }
    
    payment_response = sdk.payment().create(payment_data)
    payment = payment_response["response"]
    
    
            
              
    curl -X POST \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
      'https://api.mercadopago.com/v1/payments' \
      -d '{
      transaction_amount: 100,
      token: "ff8080814c11e237014c1ff593b57b4d",
      installments: 1,
      payer: {
          type: "customer",
        id: "123456789-jxOV430go9fx2e"
      }
    }'
    
    
            

    Busque um cliente criado

    Busque informação de um cliente caso necessário. Por exemplo, caso não saiba qual é o ID associado. O parâmetro requerido para obtê-lo é o e-mail.

              
    <?php
    
      $filters = array(
        "id"=>"247711297-jxOV430go9fx2e"
      );
    
      $customers = MercadoPago\Customer::search($filters);
    
    ?>
    
    
            
              
      var filters = {
        email: "test_payer_12345@testuser.com"
      };
    
      mercadopago.customers.search({
        qs: filters
      }).then(function (customer) {
        console.log(customer);
      });
    
    
            
              
    CustomerClient client = new CustomerClient();
    
    Map<String, Object> filters = new HashMap<>();
    filters.put("email", "test_payer_12345@testuser.com");
    
    MPSearchRequest searchRequest =
       MPSearchRequest.builder().offset(0).limit(0).filters(filters).build();
    
    client.search(searchRequest);
    
    
    
            
              
    customers_response = sdk.customer.search(filters: { email: 'test_payer_12345@testuser.com' })
    customers = customers_response[:response]
    
    
            
              
    var searchRequest = new SearchRequest
    {
        Filters = new Dictionary<string, object>
        {
            ["email"] = "test_payer_12345@testuser.com",
        },
    };
    ResultsResourcesPage<Customer> results = await customerClient.SearchAsync(searchRequest);
    IList<Customer> customers = results.Results;
    
    
            
              
    filters = {
        "email": "test_payer_12345@testuser.com"
    }
    
    customers_response = sdk.customer().search(filters=filters)
    customers = customers_response["response"]
    
    
            
              
    curl -X GET \
      -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
      'https://api.mercadopago.com/v1/customers/search' \
      -d '{
        "email": "test_user_19653727@testuser.com"
    }'
    
            

    Resposta

    json

    {
        "paging": {
            "limit": 10,
            "offset": 0,
            "total": 1
        },
        "results": [
            {
                "address": {
                    "id": null,
                    "street_name": null,
                    "street_number": null,
                    "zip_code": null
                },
                "addresses": [],
                "cards": [
                    {
                        ...
                    }
                ],
                "date_created": "2017-05-05T00:00:00.000-04:00",
                "date_last_updated": "2017-05-05T09:23:25.021-04:00",
                "date_registered": null,
                "default_address": null,
                "default_card": "1493990563105",
                "description": null,
                "email": "test_payer_12345@testuser.com",
                "first_name": null,
                "id": "123456789-jxOV430go9fx2e",
                "identification": {
                    "number": null,
                    "type": null
                },
                "last_name": null,
                "live_mode": false,
                "metadata": {},
                "phone": {
                    "area_code": null,
                    "number": null
                }
            }
        ]
    }

    Consulte a lista de cartões de um cliente

              
    <?php
        $customer = MercadoPago\Customer::find_by_id($customer_id);
      $cards = $customer->cards();
    ?>
    
    
            
              
      var filters = {
        id: customer_id
      };
    
      mercadopago.customers.search({
        qs: filters
      }).then(function (customer) {
        console.log(customer);
      });
    
    
            
              
    MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN");
    
    CustomerClient customerClient = new CustomerClient();
    
    Customer customer = customerClient.get("247711297-jxOV430go9fx2e");
    customerClient.listCards(customer.getId());
    
    
            
              
    cards_response = sdk.card.list(customer_id)
    cards = cards_response[:response]
    
    
            
              
    var customerClient = new CustomerClient();
    ResourcesList<CustomerCard> customerCards = await customerClient.ListCardsAsync("CUSTOMER_ID");
    
    
            
              
    cards_response = sdk.card().list_all(customer_id)
    cards = cards_response["response"]
      
    
            
              
    curl -X GET \
      -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \
      'https://api.mercadopago.com/v1/customers/CUSTOMER_ID/cards' \
    
    
            

    Resposta

    json

    [{
        "id": "1490022319978",
        "expiration_month": 12,
        "expiration_year": 2020,
        "first_six_digits": "415231",
        "last_four_digits": "0001",
        ...
    }]

    Modificar um cliente

    Para modificar um cliente é necessário enviar o customer_id e os campos a serem atualizados em uma solicitação HTTP PUT.

    Os campos que podem ser modificados de um cliente são:

    AtributoDescrição
    addressEndereço.
    default_addressEndereço padrão.
    default_cardCartão padrão.
    descriptionDescrição.
    emailE-mail da conta.
    first_nameNome.
    last_nameSobrenome.
    phoneTelefone cadastrado.
    identificationTipo e número do documento.
    Nota
    O campo email só pode ser atualizado se o cliente ainda não tiver um e-mail associado.
              
    <?php
    
      MercadoPago\SDK::setAccessToken("ENV_ACCESS_TOKEN");
    
      $customer = new MercadoPago\Customer();
      $customer->email = "user@user.com";
      $customer->first_name = "john";
      $customer->last_name = "wagner";
      $customer->phone = array("area_code" => "11", "number" => "001234567");
      $customer->identification = array("type" => "-", "number" => "12341234");
      $customer->default_address = "Casa";
      $customer->address = array("zip_code" => "52", "street_name" => "Insurgentes Sur", "street_number" => "2");
      $customer->description = "Informações do cliente";
      $customer->default_card = "None";
      $customer->update();
    
    ?>
    
    
            
              
    var mercadopago = require('mercadopago');
    mercadopago.configure({
        access_token: 'ENV_ACCESS_TOKEN'
    });
    
    var customer_data = { 
      "email": "test_payer_12345@testuser.com",
      "first_name": "john" ,
      "last_name": "wagner",
      "phone": {
        "area_code": "11",
        "number": "001234567"
      },
      "identification": {
        "type": "-",
        "number": "12341234"
      }, 
      "default_address": "Casa",
      "address": {
        "zip_code": "52",
        "street_name": "Insurgentes Sur",
        "street_number": "2"
      },
      "description": "Informações do cliente",
      "default_card": "None
     }
    
    mercadopago.customers.update(customer_data).then(function (customer) {
     // code ...
    });
    
    
            
              
    MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN");
    
    CustomerClient client = new CustomerClient();
    
    CustomerRequest request = CustomerRequest.builder()
       .email("user@user.com")
       .firstName("John")
       .lastName("Wagner")
       .defaultAddress("Casa")
       .phone(PhoneRequest.builder()
           .areaCode("11")
           .number("001234567")
           .build())
       .identification(IdentificationRequest.builder()
           .type("CPF")
           .number("12341234")
           .build())
       .description("Informações do cliente")
       .defaultCard("None")
       .address(CustomerAddressRequest.builder()
           .zipCode("52")
           .streetName("Av. das Nações Unidas")
           .streetNumber(2)
           .build())
       .build();
    
    client.update("247711297-jxOV430go9fx2e", request);
    
    
            
              
    require 'mercadopago'
    
    sdk = Mercadopago::SDK.new('ENV_ACCESS_TOKEN')
    
    customer_request = {
      email: 'user@user.com',
      first_name: 'john',
      last_name: 'wagner',
      default_address: 'Casa',
      phone: {
        area_code: '11',
        number: '001234567'
      },
      identification: {
        type: '-',
        number: '12341234'
      },
      address: {
        zip_code: '52',
        street_name: 'Insurgentes Sur',
        street_number: '2'
      },
      description: 'Informações do cliente',
      default_card: 'None'
    }
    customer_response = sdk.customer.update(customer_id ,customer_request)
    customer = customer_response[:response]
    
    
            
              
    MercadoPagoConfig.AccessToken = "ENV_ACCESS_TOKEN";
    var phoneRequest = new PhoneRequest
    {
      AreaCode = "11",
      Number = "001234567"
    };
    
    var identificationRequest = new IdentificationRequest
    {
      Type = "-",
      Number = "12341234"
    };
    
    var addressRequest = new AddressRequest
    {
      ZipCode = "52",
      StreetName = "Insurgentes Sur",
      StreetNumber = "2"
    };
    
    var customerRequest = new CustomerRequest
    {
        Email = "test_payer_12345@testuser.com",
        FirstName = "john",
        LastName = "wagner",
        DefaultAddress = "home",
        Description = "Informações do cliente",
        DefaultCard = "None",
        Phone = phoneRequest,
        Identification = identificationRequest,
        Address = addressRequest
    
    };
    var customerClient = new CustomerClient();
    Customer customer = await customerClient.Update(customerRequest);
    
    
            
              
    import mercadopago
    sdk = mercadopago.SDK("ENV_ACCESS_TOKEN")
    
    customer_data = {
      "email": 'user@user.com',
      "first_name": 'john',
      "last_name": 'wagner',
      "default_address": 'Casa',
      "phone": {
        "area_code": '11',
        "number": '001234567'
      },
      "identification": {
        "type": '-',
        "number": '12341234'
      },
      "address": {
        "zip_code": '52',
        "street_name": 'Insurgentes Sur',
        "street_number": '2'
      },
      "description": 'Informações do cliente',
      "default_card": 'None'
    }
    customer_response = sdk.customer().update(customer_id, customer_data)
    customer = customer_response["response"]
    
    
            
              
    curl -X PUT \
        'https://api.mercadopago.com/v1/customers/{id}' \
        -H 'Authorization: Bearer ACCESS_TOKEN_ENV' \ 
        -d '{
      "email": "user@user.com",
      "first_name": "john",
      "last_name": "wagner",
      "address": {
        "zip_code": "52",
        "street_name": "Insurgentes Sur",
        "street_number": "2"
      },
      "phone": {
        "area_code": "11",
        "number": "001234567"
      },
      "identification": {
        "type": "-",
        "number": "12341234"
      },
      "description": "Informações do cliente" 
    }'
    
    
            

    Exemplo de resposta com o envio do customer_id:

    json

    {
      "id": "xxxxxxxxxxxxxxxxxxxxx",
      "email": "user@user.com",
      "first_name": "john",
      "last_name": "wagner",
      "phone": {
        "area_code": "11",
        "number": 001234567
      },
      "identification": {
        "type": "-",
        "number": 12341234
      },
      "address": {
        "zip_code": "52",
        "street_name": "Insurgentes Sur",
        "street_number": 2
      },
      "description": "Informações do cliente",
      "date_created": "2021-05-25T15:36:23.541Z",
      "metadata": {},
      "cards": [
        {}
      ],
      "addresses": [
        {}
      ]
    }

    Exemplo de resposta sem o parâmetro customer_id:

    json

    {
      "message": "missing customer id"
    }
    Nota
    Se você não tiver o customer_id, e gere uma solicitação HTTP GET usando o parâmetro email para obtê-lo.