# MD for: https://www.mercadopago.com.br/developers/pt/docs/automatic-payments/recurring-charges.md \# Create recurring charges With Automatic Payments, you can process payments with stored cards (Card on File) without requesting the CVV on each transaction. To do this, you need to obtain the customer's and card's data, including the security code (CVV), either by processing a payment or just storing them securely. Then, you will need to associate the customer and card in your system. ## Get card data Follow the step-by-step below to learn how to perform this process in both flows: processing a first payment, or just making a validation payment to store the data and use it for a subsequent first charge. :::AccordionComponent{title="Process first payment"} If the registration includes the payment of the first installment, this first payment is processed with \[Checkout Transparente\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-legacy/integration-configuration/card/web-integration) or \[Checkout Bricks\](https://www.mercadopago.com.br/developers/en/docs/checkout-bricks/card-payment-brick/payment-submission) following the payment processes to Mercado Pago. For this, your \_backend\_ must be able to receive the form information with the generated \_token\_ and the provided data. > NOTE > > Note > > For more information, follow the steps for our card payment integration through \[Checkout Transparente\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-legacy/integration-configuration/card/web-integration) or using \[Checkout Bricks\](https://www.mercadopago.com.br/developers/en/docs/checkout-bricks/card-payment-brick/payment-submission). The minimum required fields to send are: \`token\`, \`transaction\_amount\`, \`installments\`, \`payment\_method\_id\` and \`payer.email\`. Remember that the more additional information you send, the higher the probability that the payment will be approved, as the risk assessment will have more data to analyze. \`\`\`curl curl -X POST \\ -H 'accept: application/json' \\ -H 'content-type: application/json' \\ -H 'Authorization: Bearer YOUR\_ACCESS\_TOKEN' \\ -H 'X-Idempotency-Key: SOME\_UNIQUE\_VALUE' \\ 'https://api.mercadopago.com/v1/payments' \\ -d '{ "transaction\_amount": 100, "token": "4cbbee6da93f85e98f51647241b0e51e", "description": "Firstpayment", "installments": 1, "payment\_method\_id": "master", "payer": { "email": "test\_payer@example.com" }, "statement\_descriptor": "First payment", "external\_reference": "9ce0e6cb-205b-4a7b-b156-847eab8cc137", "point\_of\_interaction": { "type": "SUBSCRIPTIONS", "transaction\_data": { "first\_time\_use": true, "subscription\_id": "subscription-gym-1", "subscription\_sequence": { "number": 1, "total": 12 }, "invoice\_period": { "period": 1, "type": "monthly" }, "billing\_date": "2025-11-26", "user\_present": true } }, "additional\_info": { "items": \[ { "description": "First payment", "quantity": 1, "title": "title", "unit\_price": 100 } \] } } \`\`\` > WARNING > > Important > > For more information on how to send recurring payment information to the \[v1/payments\](https://www.mercadopago.com.br/developers/en/reference/online-payments/checkout-api-payments/create-payment/post) endpoint with the aim of increasing the approval rate for this type of payments, visit the \[Automatic payments messaging\](https://www.mercadopago.com.br/developers/en/docs/automatic-payments/recurring-charges/subscription-messaging) documentation. ::: :::::AccordionComponent{title="Store data without first payment"} 1\. In the case where the affiliation includes the payment of the first installment, the first payment is processed with \[Checkout Transparente\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/integration-configuration/card/web-integration) or \[Checkout Bricks\](https://www.mercadopago.com.br/developers/en/docs/checkout-bricks/card-payment-brick/payment-submission) following the payment processes to Mercado Pago. For this, it is necessary that your backend can receive the information from the form with the generated token and the provided data. > NOTE > > Note > > For more information, follow the steps for our card payment integration through the \[Checkout Transparente\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/integration-configuration/card/web-integration) or using the \[Checkout Bricks\](https://www.mercadopago.com.br/developers/en/docs/checkout-bricks/card-payment-brick/payment-submission). To carry out this process, there are two flows: - A first flow for \*\*Visa\*\* and \*\*Master\*\* cards with authentication through \[Zero Dollar Auth\](https://www.mercadopago.com.br/developers/en/docs/zero-dollar-auth/integration). - A second flow for other cards, with the charge of a low amount and the subsequent refund of the money involved. ::::TabsComponent :::TabComponent{title="Zero Dollar Auth"} For \*\*Visa\*\* and \*\*Mastercard\*\* credit and debit cards, authentication is done through the \[Zero Dollar Auth (ZDA)\](https://www.mercadopago.com.br/developers/en/docs/zero-dollar-auth/landing) functionality. Zero Dollar Auth is a feature for validating credit or debit cards, aimed at optimizing the customer experience. With it, it is possible to ensure that there are no actual charges on the card, eliminating the need for cancellations and chargebacks after the transaction authorization. For more information, access the \[ZDA documentation\](https://www.mercadopago.com.br/developers/en/docs/zero-dollar-auth/landing). * [csharp ](#editor%5F5) * [curl ](#editor%5F7) * [java ](#editor%5F3) * [node ](#editor%5F2) * [php ](#editor%5F1) * [python ](#editor%5F6) * [ruby ](#editor%5F4) php node java ruby csharp python curl ``` setCustomHeaders(["X-Card-Validation: card_validation"]); $payment = $client->create([ "token" => $_POST['token'], "payment_method_id" => $_POST['paymentMethodId'], "payer" => [ "id" => $_POST['id'], "type" => $_POST['type'] ], "description" => $_POST['description'], "transaction_amount" => (float) $_POST['transactionAmount'] ], $request_options); echo implode($payment); ?> ``` Copiar ``` import { Payment, MercadoPagoConfig } from 'mercadopago'; const client = new MercadoPagoConfig({ accessToken: '' }); payment.create({ body: { token: req.token, payment_method_id: req.payment_method_id, payer: { id: req.id, type: req.type }, description: req.description, transaction_amount: req.transaction_amount, }, requestOptions: { X-Card-Validation: 'card_validation' } }) .then((result) => console.log(result)) .catch((error) => console.log(error)); ``` Copiar ``` Map customHeaders = new HashMap<>(); customHeaders.put("X-Card-Validation", "card_validation"); MPRequestOptions requestOptions = MPRequestOptions.builder() .customHeaders(customHeaders) .build(); MercadoPagoConfig.setAccessToken("YOUR_ACCESS_TOKEN"); PaymentClient client = new PaymentClient(); PaymentCreateRequest paymentCreateRequest = PaymentCreateRequest.builder() .transactionAmount(request.getTransactionAmount()) .token(request.getToken()) .description(request.getDescription()) .paymentMethodId(request.getPaymentMethodId()) .payer( PaymentPayerRequest.builder() .id(request.getPayer().getId()) .type(request.getPayer().getType()) .build()) .build(); client.create(paymentCreateRequest, requestOptions); ``` Copiar ``` require 'mercadopago' sdk = Mercadopago::SDK.new('YOUR_ACCESS_TOKEN') custom_headers = { 'X-Card-Validation': 'card_validation' } custom_request_options = Mercadopago::RequestOptions.new(custom_headers: custom_headers) payment_data = { transaction_amount: params[:transactionAmount].to_f, token: params[:token], description: params[:description], payment_method_id: params[:paymentMethodId], payer: { id: 'params[:id]', type: params[:type] } } payment_response = sdk.payment.create(payment_data, custom_request_options) payment = payment_response[:response] puts payment ``` Copiar ``` using System; using MercadoPago.Client.Common; using MercadoPago.Client.Payment; using MercadoPago.Config; using MercadoPago.Resource.Payment; MercadoPagoConfig.AccessToken = "YOUR_ACCESS_TOKEN"; var requestOptions = new RequestOptions(); requestOptions.CustomHeaders.Add("X-Card-Validation", "card_validation"); var paymentRequest = new PaymentCreateRequest { TransactionAmount = decimal.Parse(Request["transactionAmount"]), Token = Request["token"], Description = Request["description"], PaymentMethodId = Request["paymentMethodId"], Payer = new PaymentPayerRequest { Id = Request["id"], Type = Request["type"] }, }; var client = new PaymentClient(); Payment payment = await client.CreateAsync(paymentRequest, requestOptions); Console.WriteLine(payment.Status); ``` Copiar ``` import mercadopago sdk = mercadopago.SDK("ACCESS_TOKEN") request_options = mercadopago.config.RequestOptions() request_options.custom_headers = { 'X-Card-Validation': 'card_validation' } payment_data = { "transaction_amount": float(request.POST.get("transaction_amount")), "token": request.POST.get("token"), "description": request.POST.get("description"), "payment_method_id": request.POST.get("payment_method_id"), "payer": { "id": request.POST.get("id"), "type": request.POST.get("type") } } payment_response = sdk.payment().create(payment_data, request_options) payment = payment_response["response"] print(payment) ``` Copiar ``` curl --location --request POST 'https://api.mercadopago.com/v1/payments' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'Content-Type: application/json' \ --header 'X-Card-Validation: card_validation' \ --data-raw '{ "token": "TOKEN", "payment_method_id": "master", "payer": { "id": "{{customer_id}}", "type" : "customer", }, "description": "validação de cartão com valor zero dollar master", "transaction_amount": 0 }' ``` Copiar \> NOTE > > You must store the \`id\` of the payment made, returned in the response to its creation, in order to use it when sending subsequent recurring payments. For more information, see \[Automatic payments messaging\](https://www.mercadopago.com.br/developers/en/docs/automatic-payments/recurring-charges/subscription-messaging). If ZDA is not available, the alternative is to make a \*\*Validation payment\*\*, where a small amount should be charged and the money refunded immediately afterward. ::: :::TabComponent{title="Validation payment"} To validate credit or debit cards from other brands, in order to ensure the security of the transaction, it will be necessary to create a \*\*validation payment\*\* where a small amount should be charged and the money refunded immediately afterward. See below an example of how to send this payment. * [csharp ](#editor%5F12) * [curl ](#editor%5F14) * [java ](#editor%5F10) * [node ](#editor%5F9) * [php ](#editor%5F8) * [python ](#editor%5F13) * [ruby ](#editor%5F11) php node java ruby csharp python curl ``` setCustomHeaders(["X-Idempotency-Key: "]); $payment = $client->create([ "transaction_amount" => (float) $_POST['transactionAmount'], "token" => $_POST['token'], "description" => $_POST['description'], "installments" => $_POST['installments'], "payment_method_id" => $_POST['paymentMethodId'], "issuer_id" => $_POST['issuer'], "payer" => [ "email" => $_POST['email'], "identification" => [ "type" => $_POST['identificationType'], "number" => $_POST['number'] ] ] ], $request_options); echo implode($payment); ?> ``` Copiar ``` import { Payment, MercadoPagoConfig } from 'mercadopago'; const client = new MercadoPagoConfig({ accessToken: '' }); payment.create({ body: { transaction_amount: req.transaction_amount, token: req.token, description: req.description, installments: req.installments, payment_method_id: req.paymentMethodId, issuer_id: req.issuer, payer: { email: req.email, identification: { type: req.identificationType, number: req.number }}}, requestOptions: { idempotencyKey: '' } }) .then((result) => console.log(result)) .catch((error) => console.log(error)); ``` Copiar ``` Map customHeaders = new HashMap<>(); customHeaders.put("x-idempotency-key", ); MPRequestOptions requestOptions = MPRequestOptions.builder() .customHeaders(customHeaders) .build(); MercadoPagoConfig.setAccessToken("YOUR_ACCESS_TOKEN"); PaymentClient client = new PaymentClient(); PaymentCreateRequest paymentCreateRequest = PaymentCreateRequest.builder() .transactionAmount(request.getTransactionAmount()) .token(request.getToken()) .description(request.getDescription()) .installments(request.getInstallments()) .paymentMethodId(request.getPaymentMethodId()) .payer( PaymentPayerRequest.builder() .email(request.getPayer().getEmail()) .firstName(request.getPayer().getFirstName()) .identification( IdentificationRequest.builder() .type(request.getPayer().getIdentification().getType()) .number(request.getPayer().getIdentification().getNumber()) .build()) .build()) .build(); client.create(paymentCreateRequest, requestOptions); ``` Copiar ``` require 'mercadopago' sdk = Mercadopago::SDK.new('YOUR_ACCESS_TOKEN') custom_headers = { 'x-idempotency-key': '' } custom_request_options = Mercadopago::RequestOptions.new(custom_headers: custom_headers) payment_data = { transaction_amount: params[:transactionAmount].to_f, token: params[:token], description: params[:description], installments: params[:installments].to_i, payment_method_id: params[:paymentMethodId], payer: { email: params[:email], identification: { type: params[:identificationType], number: params[:identificationNumber] } } } payment_response = sdk.payment.create(payment_data, custom_request_options) payment = payment_response[:response] puts payment ``` Copiar ``` using System; using MercadoPago.Client.Common; using MercadoPago.Client.Payment; using MercadoPago.Config; using MercadoPago.Resource.Payment; MercadoPagoConfig.AccessToken = "YOUR_ACCESS_TOKEN"; var requestOptions = new RequestOptions(); requestOptions.CustomHeaders.Add("x-idempotency-key", ""); var paymentRequest = new PaymentCreateRequest { TransactionAmount = decimal.Parse(Request["transactionAmount"]), Token = Request["token"], Description = Request["description"], Installments = int.Parse(Request["installments"]), PaymentMethodId = Request["paymentMethodId"], Payer = new PaymentPayerRequest { Email = Request["email"], Identification = new IdentificationRequest { Type = Request["identificationType"], Number = Request["identificationNumber"], }, }, }; var client = new PaymentClient(); Payment payment = await client.CreateAsync(paymentRequest, requestOptions); Console.WriteLine(payment.Status); ``` Copiar ``` import mercadopago sdk = mercadopago.SDK("ACCESS_TOKEN") request_options = mercadopago.config.RequestOptions() request_options.custom_headers = { 'x-idempotency-key': '' } payment_data = { "transaction_amount": float(request.POST.get("transaction_amount")), "token": request.POST.get("token"), "description": request.POST.get("description"), "installments": int(request.POST.get("installments")), "payment_method_id": request.POST.get("payment_method_id"), "payer": { "email": request.POST.get("email"), "identification": { "type": request.POST.get("type"), "number": request.POST.get("number") } } } payment_response = sdk.payment().create(payment_data, request_options) payment = payment_response["response"] print(payment) ``` Copiar ``` curl -X POST \ -H 'accept: application/json' \ -H 'content-type: application/json' \ -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ -H 'X-Idempotency-Key: SOME_UNIQUE_VALUE' \ 'https://api.mercadopago.com/v1/payments' \ -d '{ "transaction_amount": 100, "token": "ff8080814c11e237014c1ff593b57b4d", "description": "Blue shirt", "installments": 1, "payment_method_id": "visa", "issuer_id": 310, "payer": { "email": "PAYER_EMAIL" } }' ``` Copiar \> For more information, follow the steps of our integration for card payments with \[Checkout Transparente\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/integration-configuration/card/web-integrationm) or using the \[Card Payment Brick.\](https://www.mercadopago.com.br/developers/en/docs/checkout-bricks/card-payment-brick/default-rendering) After making this charge, you must execute the refund, according to the example below. \`\`\`curl === Example of refund === curl -X POST \\ 'https://api.mercadopago.com/v1/payments/12345678901/refunds'\\ -H 'Content-Type: application/json' \\ -H 'X-Idempotency-Key: 77e1c83b-7bb0-437b-bc50-a7a58e5660ac' \\ -H 'Authorization: Bearer TEST-4397\*\*\*\*\*\*\*\*912-08011\*\*\*\*\*\*\*\*\*50d74305b\*\*\*\*\*\*\*\*\*a2f9ec0-1\*\*\*\*\*\*\*\*' \\ -d '{ "amount": 5 }' \`\`\` > WARNING > > Important > > It is essential to \*\*wait at least 5 seconds between creating the payment and executing the refund\*\*. Additionally, executing the refund depends on having a minimum available balance equivalent to the refund amount in your bank account within Mercado Pago. For more information, access the documentation for the endpoint \[v1/payments\](https://www.mercadopago.com.br/developers/en/reference/online-payments/checkout-api-payments/create-payment/post) and \[v1/payments/{id}/refunds\](https://www.mercadopago.com.br/developers/en/reference/online-payments/checkout-api-payments/create-refund/post). ::: :::: ::::: \## Associate card with the customer After processing the first payment and ensuring that the card is valid, create a customer and associate it with the card used in the first payment. To create a customer and associate it with your card, you need to send the \`customer\_id\` and \`card\_token\`. Each customer will be stored with the value \`customer\`, and each card with the value \`card\`. Additionally, we recommend storing the card data whenever a payment is successfully completed. This allows the correct data to be stored for future purchases and optimizes the payment process for the buyer. To create a customer and card, use one of the SDKs below. * [csharp ](#editor%5F19) * [curl ](#editor%5F21) * [java ](#editor%5F17) * [node ](#editor%5F16) * [php ](#editor%5F15) * [python ](#editor%5F20) * [ruby ](#editor%5F18) php node java ruby csharp python curl ``` create(["email" => "test_payer@example.com"]); $client = new CustomerCardClient(); $customer_card = $client->create($customer->id, ["token" => "your_card_token"]); ?> ``` Copiar ``` const client = new MercadoPagoConfig({ accessToken: 'YOUR_ACCESS_TOKEN' }); const customer = new Customer(client); const body = { email: "test_payer@example.com" }; customer.create({ body: body }).then((result) => { const customerCard = new CustomerCard(client); const body = { token : result.token, }; customerCard.create({ customerId: 'customer_id', body }) .then((result) => console.log(result)); }) ``` Copiar ``` MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN"); CustomerClient customerClient = new CustomerClient(); CustomerCardClient customerCardClient = new CustomerCardClient(); CustomerRequest customerRequest = CustomerRequest.builder() .email("test_payer@example.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); ``` Copiar ``` 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: 'visa' } card_response = sdk.card.create(customer['id'], card_request) card = card_response[:response] ``` Copiar ``` MercadoPagoConfig.AccessToken = "ENV_ACCESS_TOKEN"; var customerRequest = new CustomerRequest { Email = "test_payer@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); ``` Copiar ``` import mercadopago sdk = mercadopago.SDK("ENV_ACCESS_TOKEN") customer_data = { "email": "test_payer@testuser.com" } customer_response = sdk.customer().create(customer_data) customer = customer_response["response"] card_data = { "token": "9b2d63e00d66a8c721607214cedaecda", "issuer_id": "3245612", "payment_method_id": "visa" } card_response = sdk.card().create(customer["id"], card_data) card = card_response["response"] ``` Copiar ``` 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": "visa"}' ``` Copiar \> For more information, check the section \[Cards and customers management in Checkout Transparente.\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/customer-management) ## Get customer data To obtain customer data such as ID, address or registration date, you can retrieve them through our customer API. To do this, send a \*\*GET\*\* with the customer's email to the endpoint \[/v1/customers/search\](https://www.mercadopago.com.br/developers/en/reference/online-payments/checkout-api-payments/customers/search-customer/get) and execute the request, or if you prefer, use one of the SDKs below. * [csharp ](#editor%5F26) * [curl ](#editor%5F28) * [java ](#editor%5F24) * [node ](#editor%5F23) * [php ](#editor%5F22) * [python ](#editor%5F27) * [ruby ](#editor%5F25) php node java ruby csharp python curl ``` search(1, 0, ["email" => "test_payer@example.com"]); ?> ``` Copiar ``` import { Customer, MercadoPagoConfig } from '@src/index'; const client = new MercadoPagoConfig({ accessToken: '' }); const customer = new Customer(client); customer.search({ options: { email: '' } }).then(console.log).catch(console.log); ``` Copiar ``` CustomerClient client = new CustomerClient(); Map filters = new HashMap<>(); filters.put("email", "test_payer@testuser.com"); MPSearchRequest searchRequest = MPSearchRequest.builder().offset(0).limit(0).filters(filters).build(); client.search(searchRequest); ``` Copiar ``` customers_response = sdk.customer.search(filters: { email: 'test_payer@testuser.com' }) customers = customers_response[:response] ``` Copiar ``` var searchRequest = new SearchRequest { Filters = new Dictionary { ["email"] = "test_payer@testuser.com", }, }; ResultsResourcesPage results = await customerClient.SearchAsync(searchRequest); IList customers = results.Results; ``` Copiar ``` filters = { "email": "test_payer@testuser.com" } customers_response = sdk.customer().search(filters=filters) customers = customers_response["response"] ``` Copiar ``` curl -X GET \ -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \ 'https://api.mercadopago.com/v1/customers/search' \ -d '{ "email": "test_payer@example.com" }' ``` Copiar \> For more information, check the section \[Cards and customers management in Checkout Transparente.\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/customer-management) or the section \[Default rendering in Card Payment Brick.\](https://www.mercadopago.com.br/developers/pt/docs/checkout-bricks/card-payment-brick/default-rendering) ## Get the card associated with the customer Having obtained the customer ID, use it to locate the associated card. * [csharp ](#editor%5F33) * [curl ](#editor%5F35) * [java ](#editor%5F31) * [node ](#editor%5F30) * [php ](#editor%5F29) * [python ](#editor%5F34) * [ruby ](#editor%5F32) php node java ruby csharp python curl ``` list("customer_id"); echo implode ($cards); ?> ``` Copiar ``` const client = new MercadoPagoConfig({ accessToken: 'access_token' }); const customerCard = new CustomerCard(client); customerCard.list({ customerId: '' }).then(console.log).catch(console.log); ``` Copiar ``` MercadoPagoConfig.setAccessToken("ENV_ACCESS_TOKEN"); CustomerCardClient customerCardClient = new CustomerCardClient(); MPResourceList list = customerCardClient.listAll("000000000-abcdEfghiJklM"); List customerCards = list.getResults(); ``` Copiar ``` cards_response = sdk.card.list(customer_id) cards = cards_response[:response] ``` Copiar ``` var customerClient = new CustomerClient(); ResourcesList customerCards = await customerClient.ListCardsAsync("CUSTOMER_ID"); ``` Copiar ``` cards_response = sdk.card().list_all(customer_id) cards = cards_response["response"] ``` Copiar ``` curl -X GET \ -H 'Authorization: Bearer ENV_ACCESS_TOKEN' \ 'https://api.mercadopago.com/v1/customers/CUSTOMER_ID/cards' \ ``` Copiar \> For more information, check the section \[Cards and customers management in Checkout Transparente.\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/customer-management) ## Generate a card token After locating the data of the card associated with the customer, use the snippets below to tokenize the card using its ID (\`card\_id\`). Tokenization provides a more secure digital payment experience by replacing the credit card number with an alternative number, the token. * [curl ](#editor%5F42) * [dotnet ](#editor%5F39) * [java ](#editor%5F38) * [node ](#editor%5F37) * [php ](#editor%5F36) * [python ](#editor%5F41) * [ruby ](#editor%5F40) php node java dotnet ruby python curl ``` "); $client = new CardTokenClient(); try { $request = [ "card_id" => "cardId" ]; $card_token = $client->create($request); var_dump($card_token); } catch (MPApiException $e) { echo "Status code: " . $e->getApiResponse()->getStatusCode() . "\n"; echo "Content: "; var_dump($e->getApiResponse()->getContent()); echo "\n"; } catch (\Exception $e) { echo $e->getMessage(); } ``` Copiar ``` import { MercadoPagoConfig, CardToken } from 'mercadopago'; const client = new MercadoPagoConfig({ accessToken: '' }); const cardToken = new CardToken(client); const body = { card_id : '' }; cardToken.create({ body }).then(console.log).catch(console.log); ``` Copiar ``` import com.mercadopago.client.cardtoken.CardTokenClient; import com.mercadopago.client.cardtoken.CardTokenRequest; import com.mercadopago.exceptions.MPApiException; import com.mercadopago.exceptions.MPException; import com.mercadopago.resources.CardToken; public class App { public static void main(String[] args){ MercadoPagoConfig.setAccessToken(""); CardTokenRequest request = CardTokenRequest.builder().cardId("").build(); CardTokenClient client = new CardTokenClient(); try { CardToken cardToken = client.create(request); System.out.println(cardToken); } catch (MPApiException ex) { System.out.printf( "MercadoPago Error. Status: %s, Content: %s%n", ex.getApiResponse().getStatusCode(), ex.getApiResponse().getContent()); } catch (MPException ex) { ex.printStackTrace(); } } } ``` Copiar ``` using System; using MercadoPago.Config; using MercadoPago.Client.CardToken; using MercadoPago.Resource.CardToken; MercadoPagoConfig.AccessToken = ""; var request = new CardTokenRequest { CardId = "" }; var client = new CardTokenClient(); CardToken cardToken = await client.CreateAsync(request); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(cardToken)); ``` Copiar ``` require_relative '../lib/mercadopago.rb' sdk = Mercadopago::SDK.new('') card_token_request = { card_id: '' } card_token_response = sdk.card_token.create(card_token_request) card_token = card_token_response[:response] puts card_token ``` Copiar ``` import mercadopago sdk = mercadopago.SDK("") card_token_data = { "card_id": "" } result = sdk.card_token().create(card_token_data) card_token = result["response"] print(card_token) ``` Copiar ``` curl --location --request POST 'https://api.mercadopago.com/v1/card_tokens' \ --header 'Authorization: Bearer {{access_token}}' \ --header 'Content-Type: application/json' \ --data-raw '{ "card_id": {{card_id}} }' ``` Copiar \> NOTE > > Important > > Follow the step-by-step guide and prevent fraudulent payments with our recommendations to \[improve the approval of your payments.\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/how-tos/improve-payment-approval) > \> For more information, check the section \[Cards and customers management in Checkout Transparente.\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/customer-management) ## Create charges Use the previously generated token to register the payment, indicating the customer ID associated with the card. * [csharp ](#editor%5F47) * [curl ](#editor%5F49) * [java ](#editor%5F45) * [node ](#editor%5F44) * [php ](#editor%5F43) * [python ](#editor%5F48) * [ruby ](#editor%5F46) php node java ruby csharp python curl ``` list("customer_id"); $client = new PaymentClient(); $request_options = new RequestOptions(); $request_options->setCustomHeaders(["X-Idempotency-Key: "]); $payment = $client->create([ "transaction_amount" => 100.0, "token" => $cards[0]-> token, "description" => "My product", "installments" => 1, "payment_method_id" => "visa", "issuer_id" => "123", "payer" => [ "type" => "customer", "id" => "1234" ] ], $request_options); echo implode($payment); ?> ``` Copiar ``` const client = new MercadoPagoConfig({ accessToken: 'access_token' }); const customerClient = new Customer(client); customerClient.listCards({ customerId: '' }) .then((result) => { const payment = new Payment(client); const body = { transaction_amount: 100, token: result[0].token, description: 'My product', installments: 1, payment_method_id: 'visa', issuer_id: 123, payer: { type: 'customer', id: '123' } }; payment.create({ body: body }).then((result) => console.log(result)); }); ``` Copiar ``` 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); ``` Copiar ``` 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] ``` Copiar ``` 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@testuser.com", }, }; var client = new PaymentClient(); Payment payment = await client.CreateAsync(request); ``` Copiar ``` 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"] ``` Copiar ``` curl --location 'https://api.mercadopago.com/v1/payments' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer ENV_ACCESS_TOKEN' \ --data ' { "transaction_amount": 100, "token": "ff8080814c11e237014c1ff593b57b4d", "installments": 1, "payer": { "type": "customer", "id": "123456789-jxOV430go9fx2e" }, "description": "subscription payment", "notification_url": "https://tu-webhoock.com", "statement_descriptor": "Your store", "external_reference": "49646973", "additional_info": { "items": [ { "id": "FT9200101024", "title": "your product", "quantity": 1, "unit_price": 100 } ], "payer": { "phone": { "area_code": "54", "number": "1234567" }, "first_name": "MARTINEZ", "last_name": "GODOY", "address": { "zip_code": "2804", "street_name": "Mendoza", "street_number": "125" }, "registration_date": null } }, "point_of_interaction": { "type": "SUBSCRIPTIONS", "transaction_data": { "subscription_id": "Tu Comercio_4b4ef2f2-c5d6-4c1d-a492-070630bed20a", "subscription_sequence": { "number": 2, "total":10 }, "invoice_period": { "period": 1, "type": "monthly" }, "billing_date": "2025-09-16" } } }' ``` Copiar \> For more information, check the section \[Cards and customers management in Checkout Transparente.\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/customer-management) or the section \[Default rendering in Card Payment Brick.\](https://www.mercadopago.com.br/developers/pt/docs/checkout-bricks/card-payment-brick/default-rendering) ## Update cards If necessary, it is possible to add new cards to a specific customer. To do this, locate the customer and define the new card details using one of the available codes below. > WARNING > > Important > > If it is necessary to delete a card before adding new cards to a customer, send a \*\*DELETE\*\* to the endpoint \[/v1/customers/{customer\_id}/cards/{id}\](https://www.mercadopago.com.br/developers/en/reference/online-payments/checkout-api-payments/cards/delete-card/delete) providing the \`customer\_id\` and \`id\` of the card you want to delete. After the successful execution of the request, you can add the new card. * [csharp ](#editor%5F54) * [curl ](#editor%5F56) * [java ](#editor%5F52) * [node ](#editor%5F51) * [php ](#editor%5F50) * [python ](#editor%5F55) * [ruby ](#editor%5F53) php node java ruby csharp python curl ``` get("1234"); $card_client = new CustomerCardClient(); $customer_card = $client->create($customer->id, [ "token" => "your_card_token", "issuer_id" => "2345", "payment_method_id" => "debit_card" ]); echo implode($customer_card); ?> ``` Copiar ``` const client = new MercadoPagoConfig({ accessToken: 'access_token' }); const customerClient = new Customer(client); const customer = customerClient.get({ customerId: '' }) .then((result) => { const cardClient = new CustomerCard(client); const body = { token : result.token, issuer_id: '2345', payment_method: 'debit_card' }; cardClient.create({ customerId: customer, body: body }) .then(console.log).catch(console.log); }); ``` Copiar ``` 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); ``` Copiar ``` 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 ``` Copiar ``` 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); ``` Copiar ``` 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) ``` Copiar ``` 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"}' ``` Copiar \> For more information, check the section \[Cards and customers management in Checkout Transparente.\](https://www.mercadopago.com.br/developers/en/docs/checkout-api-payments/customer-management)