Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mercadopago/sdk-java/llms.txt
Use this file to discover all available pages before exploring further.
PreferenceClient manages Mercado Pago Checkout Pro preferences. A preference is the configuration object that defines the entire payment experience presented to the buyer: which items are being purchased, which payment methods are accepted, shipping options, back-redirect URLs, expiration windows, and more. Once a preference is created, Mercado Pago returns an initPoint URL that you use to redirect your buyer into the hosted checkout flow.
Package: com.mercadopago.client.preference
Constructors
PreferenceClient()
Creates a PreferenceClient using the default HTTP client configured via MercadoPagoConfig.
PreferenceClient(MPHttpClient httpClient)
Creates a PreferenceClient with a custom HTTP client.
The HTTP client implementation used to execute all requests.
Methods
get — Retrieve a preference
The unique identifier of the preference (e.g.
"123456789-abc123de-...").Optional per-request overrides for access token, custom headers, or timeouts. Pass
null to use global defaults.Preference — the requested preference object.
Throws: MPException on transport/SDK errors; MPApiException on non-2xx API responses.
create — Create a preference
initPoint — the production checkout URL — and sandboxInitPoint for testing.
The preference configuration. Key fields:
| Field | Type | Description |
|---|---|---|
items | List<PreferenceItemRequest> | Required. List of items the buyer is purchasing. |
payer | PreferencePayerRequest | Buyer information (email, name, identification). |
backUrls | PreferenceBackUrlsRequest | Redirect URLs for success, pending, and failure outcomes. |
autoReturn | String | Auto-redirect mode after payment: "approved" or "all". |
paymentMethods | PreferencePaymentMethodsRequest | Payment method exclusions and installment configuration. |
shipments | PreferenceShipmentsRequest | Shipping mode, cost, and address details. |
notificationUrl | String | Webhook URL for IPN payment status notifications. |
externalReference | String | Your system’s reference identifier for this preference. |
expires | Boolean | Whether the preference expires. |
expirationDateFrom | OffsetDateTime | Start date for the active window. |
expirationDateTo | OffsetDateTime | End date when the preference expires. |
binaryMode | Boolean | When true, only approved/rejected statuses are used. |
marketplace | String | Marketplace origin identifier. Defaults to NONE. |
marketplaceFee | BigDecimal | Fee charged by the marketplace application. |
statementDescriptor | String | Text shown on the buyer’s card statement. |
purpose | String | Purpose of the preference (e.g. "wallet_purchase"). |
metadata | Map<String, Object> | Arbitrary key-value metadata for merchant use. |
Optional per-request overrides. Pass
null to use global defaults.Preference — the created preference, including id, initPoint, and sandboxInitPoint.
Throws: MPException on transport/SDK errors; MPApiException on non-2xx API responses.
Redirecting buyers: After creating a preference, redirect your buyer topreference.getInitPoint()(production) orpreference.getSandboxInitPoint()(sandbox/testing) to start the hosted checkout flow.
update — Update a preference
PreferenceRequest builder is used; only fields present in the request body are updated.
The unique identifier of the preference to update.
The updated preference attributes. Build only the fields you want to change.
Optional per-request overrides. Pass
null to use global defaults.Preference — the updated preference.
Throws: MPException on transport/SDK errors; MPApiException on non-2xx API responses.
search — Search preferences with pagination
PreferenceSearch summary objects.
Search parameters. Build with
MPSearchRequest.builder().filters(map).offset(0).limit(30).build(). Common filters include external_reference, site_id, sponsor_id.Optional per-request overrides. Pass
null to use global defaults.MPElementsResourcesPage<PreferenceSearch> — contains .getElements() (list of preference summaries) and .getPaging() for pagination metadata.
Throws: MPException on transport/SDK errors; MPApiException on non-2xx API responses.
Resource classes
Preference resource
Key fields returned on the Preference object:
Unique identifier of the preference.
Production checkout URL. Redirect buyers here to start the payment flow. This is the most important field returned after creating a preference.
Sandbox checkout URL. Use this in testing environments to simulate the payment flow without real charges.
The items configured for this checkout.
Buyer information attached to this preference.
Redirect URLs for success, pending, and failure outcomes.
Accepted and excluded payment method configuration.
Your system’s reference ID passed at creation.
Webhook URL for IPN notifications.
Whether this preference has an expiration window.
Start of the active window.
End of the active window (preference expires after this time).
Identifier of the seller receiving the payment.
Timestamp when the preference was created.