Use this file to discover all available pages before exploring further.
The Mercado Pago Payments API lets you charge buyers, authorize and capture amounts in two steps, cancel pending payments, search your transaction history, and issue full or partial refunds — all through a single PaymentClient instance. After you set your access token on MercadoPagoConfig, every operation is a single method call that returns a typed Payment or PaymentRefund resource.
Build a PaymentCreateRequest with the transaction amount, a card token, the payer’s email, and the payment method. Pass it to client.create() to process the charge immediately.
For POST, PUT, and PATCH requests the SDK generates a unique X-Idempotency-Key automatically. You can override it per request using MPRequestOptions — see the Per-request options section below.
When you create a payment with capture(false), the card is authorized but not charged. Use client.capture() to settle the funds.
// Capture the full authorized amountPayment captured = client.capture(1234567890L);System.out.println("Captured: " + captured.isCaptured());System.out.println("Status : " + captured.getStatus());
Calling capture(id) with no amount always captures the full authorized amount. Passing an explicit BigDecimal amount performs a partial capture for exactly that value.
Use MPSearchRequest to filter payments and paginate through results. Filters map directly to the query parameters accepted by the /v1/payments/search endpoint.
MPRequestOptions lets you override the access token, set custom headers (including an explicit idempotency key), or tune HTTP timeouts for a single call without touching the global MercadoPagoConfig.
import com.mercadopago.core.MPRequestOptions;import java.util.HashMap;import java.util.Map;import java.util.UUID;Map<String, String> headers = new HashMap<>();headers.put("X-Idempotency-Key", UUID.randomUUID().toString());MPRequestOptions options = MPRequestOptions.builder() .accessToken("APP_USR-alternate-access-token") .connectionTimeout(5_000) .socketTimeout(10_000) .customHeaders(headers) .build();// Pass options as the second argument to any client methodPayment payment = client.create(request, options);Payment fetched = client.get(payment.getId(), options);Payment captured = client.capture(payment.getId(), options);
For POST, PUT, and PATCH requests the SDK generates a X-Idempotency-Key automatically if you do not supply one. Supply your own key in customHeaders when you need deterministic replay protection — for example, when retrying a timed-out request.