Crear preferencia/checkout/preferencesGenera una preferencia con la información de un producto o servicio y obtén la URL necesaria para iniciar el flujo de pago.
POST
Productos que lo utilizan:
Parámetros para la solicitud
additional_info
Localización: bodyInformación adicionalstring
auto_return
Localización: bodyEn el caso de estar especificado tu comprador sera redirigido a tu sitio inmediatamente después de la compraString
approved: The redirection takes place only for approved payments.
all: The redirection takes place only for approved payments, forward compatibility only if we change the default behavior
back_urls
Localización: bodyURLs de retorno al sitio del vendedorobject
date_of_expiration
Localización: bodyFecha de vencimiento del medio de pago en efectivostring
Parámetros de respuesta
collector_id
Localización: bodyID único utilizada para identificar al collector. Es el mismo que el Cust ID.number
operation_type
Localización: bodydata_type de la operaciónString
regular_payment: Normal payment.
money_transfer: Money request.
items
Localización: bodyInformación sobre el ítemarray
payer
Localización: bodyInformación del comprador, como nombre, apellido, correo electrónico, teléfono, identificación personal, dirección y fecha de registro.object
Solicitud
curl
curl -X POST \
'https://api.mercadopago.com/checkout/preferences' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"items": [
{
"title": "Dummy Title",
"description": "Dummy description",
"picture_url": "http://www.myapp.com/myimage.jpg",
"category_id": "car_electronics",
"quantity": 1,
"currency_id": "U$",
"unit_price": 10
}
],
"payer": {
"phone": {},
"identification": {},
"address": {}
},
"payment_methods": {
"excluded_payment_methods": [
{}
],
"excluded_payment_types": [
{}
]
},
"shipments": {
"free_methods": [
{}
],
"receiver_address": {}
},
"back_urls": {},
"differential_pricing": {},
"tracks": [
{
"type": "google_ad"
}
],
"metadata": {}
}'
Respuesta
json
{
"collector_id": 202809963,
"items": [
{
"title": "Dummy Item",
"description": "Multicolor Item",
"currency_id": "$",
"quantity": 1,
"unit_price": 10
}
],
"payer": {
"phone": {},
"identification": {},
"address": {}
},
"back_urls": {},
"payment_methods": {
"excluded_payment_methods": [
{}
],
"excluded_payment_types": [
{}
]
},
"client_id": 6295877106812064,
"marketplace": "MP-MKT-6295877106812064",
"marketplace_fee": 0,
"shipments": {
"receiver_address": {}
},
"statement_descriptor": "MERCADOPAGO",
"date_created": "2018-02-02T19:22:23.535Z",
"id": "202809963-920c288b-4ebb-40be-966f-700250fa5370",
"init_point": "https://www.mercadopago.com/mla/checkout/start?pref_id=202809963-920c288b-4ebb-40be-966f-700250fa5370",
"sandbox_init_point": "https://sandbox.mercadopago.com/mla/checkout/pay?pref_id=202809963-920c288b-4ebb-40be-966f-700250fa5370",
"metadata": {}
}
Errores
400bad_request
collector_does_not_comply_with_current_regulation
invalid_collector_idcollector_id invalid.
invalid_sponsor_idsponsor_id is not an active user.
invalid_collector_emailcollector is not collector_email owner
invalid_operation_typeoperation_type invalid.
invalid_expiration_date_toexpiration_date_to invalid.
invalid_dateinvalid date of expiration.
invalid_expiration_date_fromexpiration_date_from invalid.
invalid_itemsunit_price invalid.
invalid_back_urlsback_urls invalid. Wrong format
invalid_payment_methodsinstallments invalid. Should be a number between 1 and 36.
invalid_marketplace_feemarketplace_fee must not be greater than total amount.
invalid_idpreference_id not found.
invalid_access_tokenaccess denied
invalid_shipmentsinvalid type (<type>) for field shipments.cost.
invalid_binary_modebinary_mode must be boolean.