Preference configurations
You can adapt the Wallet Brick integration to your business model by setting preference attributes.
If you offer high-value purchases, for example, you can accept payments with two credit cards or delete undesired payment methods for your operation.
Example of complete preference
json
{
"items": [
{
"id": "item-ID-1234",
"title": "Mi producto",
"currency_id": "ARS",
"picture_url": "https://www.mercadopago.com/org-img/MP3/home/logomp3.gif",
"description": "Descripción del Item",
"category_id": "art",
"quantity": 1,
"unit_price": 75.76
}
],
"payer": {
"name": "Juan",
"surname": "Lopez",
"email": "user@email.com",
"phone": {
"area_code": "11",
"number": "4444-4444"
},
"identification": {
"type": "DNI",
"number": "12345678"
},
"address": {
"street_name": "Street",
"street_number": 123,
"zip_code": "5700"
}
},
"back_urls": {
"success": "https://www.success.com",
"failure": "http://www.failure.com",
"pending": "http://www.pending.com"
},
"auto_return": "approved",
"payment_methods": {
"excluded_payment_methods": [
{
"id": "master"
}
],
"excluded_payment_types": [
{
"id": "ticket"
}
],
"installments": 12
},
"notification_url": "https://www.your-site.com/ipn",
"statement_descriptor": "MYBUSINESS",
"external_reference": "Reference_1234",
"expires": true,
"expiration_date_from": "2016-02-01T12:00:00.000-04:00",
"expiration_date_to": "2016-02-28T12:00:00.000-04:00"
}
Installment without card
With Mercado Pago it is possible to pay in up to 12 installments without a credit card, this payment option is called Cuotas sin Tarjeta.
By offering this option in your store, your customers will be able to buy a product today and pay later in installments. For your business, approval of the purchase is immediate and guaranteed, with the full amount being credited in advance and your customers paying us later.
The first step to set up payments with Cuotas sin Tarjeta is to create a preference. To do so, send a POST with the purpose
parameter and the onboarding_credits
value to the endpoint /checkout/preferences and execute the request or, if you prefer, use one of our SDKs below.
<?php
// Create a preference object
$preference = new MercadoPago\Preference();
// Create an item in the preference
$item = new MercadoPago\Item();
$item->title = 'My product';
$item->quantity = 1;
$item->unit_price = 75;
$preference->items = array($item);
$preference->purpose = 'onboarding_credits';
$preference->save();
?>
// Create a preference object
let preference = {
items: [
{
title: 'My product',
unit_price: 100,
quantity: 1,
}
],
purpose: 'onboarding_credits'
};
Mercadopago.preferences.create(preference)
.then(function(response){
// This value will replace the string "<%= global.id %>" in your HTML
global.id = response.body.id;
}).catch(function(error){
console.log(error);
});
// Create a preference object
PreferenceClient client = new PreferenceClient();
// Create an item in the preference
PreferenceItemRequest item =
PreferenceItemRequest.builder()
.title("My product")
.quantity(1)
.unitPrice(new BigDecimal("75"))
.build();
List<PreferenceItemRequest> items = new ArrayList<>();
items.add(item);
PreferenceRequest request =
PreferenceRequest.builder().items(items).purpose("onboarding_credits").build();
client.create(request);
sdk = Mercadopago::SDK.new('ENV_ACCESS_TOKEN')
# Create a preference object
preference_data = {
items: [
{
title: 'My product',
unit_price: 100,
quantity: 1
}
],
purpose: 'onboarding_credits'
}
preference_response = sdk.preference.create(preference_data)
preference = preference_response[:response]
# This value will replace the string "<%= @preference_id %>" in your HTML
@preference_id = preference['id']
// Create the preference request object
var request = new PreferenceRequest
{
Items = new List<PreferenceItemRequest>
{
new PreferenceItemRequest
{
Title = "My product,
quantity = 1,
CurrencyId = "ARS",
UnitPrice = 75m,
},
},
Purpose = "onboarding_credits",
};
// Create the preference
var client = new PreferenceClient();
Preference preference = await client.CreateAsync(request);
preference_data = {
"items": [
{
"title": "My product",
"unit_price": 100,
"quantity": 1
}
],
"purpose": "onboarding_credits"
}
preference_response = sdk.preference().create(preference_data)
preference = preference_response["response"]
curl -X POST \
'https://api.mercadopago.com/checkout/preferences' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-H 'Authorization: Bearer **PROD_ACCESS_TOKEN**' \
-d '{
"items": [
{
"title": "Meu produto",
"quantity": 1,
"unit_price": 75
}
],
"purpose": "onboarding_credits"
}'
Define the desired payment methods
Through payment preference, you can configure a default payment method to be rendered, delete unwanted ones, or choose a maximum number of installments to be offered.
Preference attribute | Description |
payment_methods | Class describing Wallet Brick's payment methods and attributes. |
excluded_payment_types | Method that excludes undesired payment methods for your operation, such as credit card, Rapipago, Pago Fácil, etc. |
excluded_payment_methods | Method that excludes specific credit and debit card brands, such as Visa, Mastercard, American Express, etc. |
installments | Method that defines the maximum number of installments to be offered. |
purpose | By indicating the value wallet_purchase in this method, Wallet Brick will only accept payments from registered users in Mercado Pago, with card and account balance. |
For example:
<?php
$preference = new MercadoPago\Preference();
// ...
$preference->payment_methods = array(
"excluded_payment_methods" => array(
array("id" => "master")
),
"excluded_payment_types" => array(
array("id" => "ticket")
),
"installments" => 12
);
// ...
?>
var preference = {}
preference = {
//...
"payment_methods": {
"excluded_payment_methods": [
{
"id": "master"
}
],
"excluded_payment_types": [
{
"id": "ticket"
}
],
"installments": 12
}
//...
}
PreferenceClient client = new PreferenceClient();
//...
List<PreferencePaymentMethodRequest> excludedPaymentMethods = new ArrayList<>();
excludedPaymentMethods.add(PreferencePaymentMethodRequest.builder().id("master").build());
excludedPaymentMethods.add(PreferencePaymentMethodRequest.builder().id("amex").build());
List<PreferencePaymentTypeRequest> excludedPaymentTypes = new ArrayList<>();
excludedPaymentTypes.add(PreferencePaymentTypeRequest.builder().id("ticket").build());
PreferencePaymentMethodsRequest paymentMethods =
PreferencePaymentMethodsRequest.builder()
.excludedPaymentMethods(excludedPaymentMethods)
.excludedPaymentTypes(excludedPaymentTypes)
.installments(12)
.build();
PreferenceRequest request = PreferenceRequest.builder().paymentMethods(paymentMethods).build();
client.create(request);
//...
#...
preference_data = {
# ...
payment_methods: {
excluded_payment_methods: [
{ id: 'master' }
],
excluded_payment_types: [
{ id: 'ticket' }
],
installments: 12
}
# ...
}
#...
var paymentMethods = new PreferencePaymentMethodsRequest
{
ExcludedPaymentMethods = new List<PreferencePaymentMethodRequest>
{
new PreferencePaymentMethodRequest
{
Id = "master",
},
},
ExcludedPaymentTypes = new List<PreferencePaymentTypeRequest>
{
new PreferencePaymentTypeRequest
{
Id = "ticket",
},
},
Installments = 12,
};
var request = new PreferenceRequest
{
// ...
PaymentMethods = paymentMethods,
};
#...
preference_data = {
"excluded_payment_methods": [
{ "id": "master" }
],
"excluded_payment_types": [
{ "id": "ticket" }
],
"installments": 12
}
#...
Accept payments with 2 credit cards
You can activate the option to offer payments with two credit cards from the Mercado Pago account.
To activate this payment option, go to "Business Options" and select the option "Receive payments with 2 credit cards".
Accept payments from registered users only
You can accept payments with the Mercado Pago wallet only from registered users, with a credit card, money in account, or Cuota sin Tarjeta.
This allows your customers to have their account information available instantly at the time of payment, such as their pre saved cards and addresses.
To accept payments only from registered users, add the following attribute to your preferences:
json
"purpose": "wallet_purchase"
Once you complete the action, your preference should have a structure similar to the example below:
json
{
"purpose": "wallet_purchase",
"items": [
{
"title": "My product",
"quantity": 1,
"unit_price": 75.76
}
],
}
Change the due date for cash payments
You can change the default expiration date for cash payments by sending the date_of_expiration
field in the preference creation request. The date set by you must be between 1 day and 30 days from the date the payment is issued.
For example:
"date_of_expiration": "2020-05-30T23:59:59.000-04:00"
Enable binary mode
You can enable the binary mode if the business model requires payment approval to be instantaneous. This way, the payment can only be approved or declined. The payment may be pending (if any action is required by the buyer) or processing (if a manual review is required) when the binary mode is disabled.
To enable it, just set the payment preference's binary_mode
attribute to true
:
json
"binary_mode": true
Set an expiration date for your preferences
Set an expiration period for your payment preferences in the expires
, expiration_date_from
, and expiration_date_to
attributes:
json
"expires": true,
"expiration_date_from": "2017-02-01T12:00:00.000-04:00",
"expiration_date_to": "2017-02-28T12:00:00.000-04:00"
Note that the date must follow the format ISO 8601: yyyy-MM-dd'T'HH:mm:ssz
.
Send description on buyer card invoice
You can add a description for your business via the statement_descriptor
attribute of the payment preferences, as shown in the example below:
json
"statement_descriptor": "MYBUSINESS"
Depending on the card brand, the description (attribute value) will appear on the buyer's card invoice.
Set a preference for multiple items
If you need to create a preference for more than one item, you must add them as a list, as shown in the example below:
<?php
# Create a preference object
$preference = new MercadoPago\Preference();
# Create items in the preference
$item1 = new MercadoPago\Item
$item1->title = "Item de Prueba 1";
$item1->quantity = 2;
$item1->unit_price = 11.96;
$item2= new MercadoPago\Item
$item2->title = "Item de Prueba 2";
$item2->quantity = 1;
$item2->unit_price = 11.96;
$preference->items = array($item1,$item2);
# Save and post the preference
$preference->save();
?>
// Set your preference
var preference = {
items: [
{ title: 'Mi producto',
quantity: 1,
currency_id: 'ARS',
unit_price: 75.56 },
{ title: 'Mi producto 2’,
quantity: 2,
currency_id: 'ARS',
unit_price: 96.56 }
]
};
// Create the preference
mercadopago.preferences.create(preference)
.then(function(preference){
// This value replaces "$init_point$" string in your HTML
global.init_point = preference.body.init_point;
}).catch(function(error){
console.log(error);
});
// Create a preference object
PreferenceClient client = new PreferenceClient();
// Create items in the preference
List<PreferenceItemRequest> items = new ArrayList<>();
PreferenceItemRequest item1 =
PreferenceItemRequest.builder()
.id("1234")
.title("Produto 1")
.quantity(2)
.currencyId("BRL")
.unitPrice(new BigDecimal("100"))
.build();
PreferenceItemRequest item2 =
PreferenceItemRequest.builder()
.id("12")
.title("Produto 2")
.quantity(1)
.currencyId("BRL")
.unitPrice(new BigDecimal("100"))
.build();
items.add(item1);
items.add(item2);
PreferenceRequest request = PreferenceRequest.builder().items(items).build();
// Save and post the preference
client.create(request);
sdk = Mercadopago::SDK.new('ENV_ACCESS_TOKEN')
# Create preference data with items
preference_data = {
items: [
{
title: 'Mi producto 1',
quantity: 1,
currency_id: 'ARS',
unit_price: 75.56
},
{
title: 'Mi producto 2',
quantity: 2,
currency_id: 'ARS',
unit_price: 96.56
}
]
}
preference_response = sdk.preference.create(preference_data)
preference = preference_response[:response]
// Create the request with multiples items
var request = new PreferenceRequest
{
Items = new List<PreferenceItemRequest>
{
new PreferenceItemRequest
{
Title = "My product 1",
Quantity = 1,
CurrencyId = "ARS",
UnitPrice = 75.56m,
},
new PreferenceItemRequest
{
Title = "My product 2",
Quantity = 2,
CurrencyId = "ARS",
UnitPrice = 96.56m,
},
// ...
},
};
// Create a client object
var client = new PreferenceClient();
// Create the preference
Preference preference = await client.CreateAsync(request);
# Create items in the preference
preference_data = {
"items": [
{
"title": "Mi producto",
"quantity": 1,
"unit_price": 75.56
},
{
"title": "Mi producto2",
"quantity": 2,
"unit_price": 96.56
}
]
}
# Create a preference
preference_response = sdk.preference().create(preference_data)
preference = preference_response["response"]
curl -X POST \
'https://api.mercadopago.com/checkout/preferences' \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-H 'Authorization: Bearer PROD_ACCESS_TOKEN' \
-d '{
"items": [
{
"id_product":1,
"quantity":1,
"unit_price": 234.33,
"titulo":"Mi producto"
},
{
"id_product":2,
"quantity":2,
"unit_price": 255.33,
"titulo":"Mi producto 2"
}
]
}'
Keep in mind that the total value of the preference will be the sum of the unit price value of each item listed.
Show shipping cost
If your website already calculates the shipment value, you can display it separately from the total amount at the time of payment.
To configure such a scenario, add the item shipments
with the value you want to charge in the cost
attribute and the value not_specified
in the mode
attribute:
json
{
"shipments":{
"cost": 1000,
"mode": "not_specified",
}
}
Redirect the buyer to your site
At the end of the checkout process, you have the option to redirect the buyer to your site again. To do this, add the back_urls
attribute and define the desired page to redirect your buyer when he clicks on the Return to site
button, according to the payment status.
You can also add the auto_return
attribute with the approved
value if you want the redirect for approved payments to be automatic without rendering a return button.
Attribute | Description |
auto_return | Buyers are automatically redirected to the site when payment is approved. The default value is approved . |
back_urls | Return URL to site. Possible scenarios are:success : Return URL upon payment approved.pending : Return URL upon payment pending.failure : Return URL upon payment payment rejected. |
The back_urls
will return the following parameters:
Parameter | Description |
payment_id | ID (identifier) of the payment from Mercado Pago. |
status | Payment status. Ex.: approved for an approved payment or pending for pending payment. |
external_reference | Amount sent at the time when the payment preference was created. |
merchant_order_id | ID (identifier) of the payment order generated in Mercado Pago. |
For example:
<?php
$preference = new MercadoPago\Preference();
//...
$preference->back_urls = array(
"success" => "https://www.tu-sitio/success",
"failure" => "http://www.tu-sitio/failure",
"pending" => "http://www.tu-sitio/pending"
);
$preference->auto_return = "approved";
// ...
?>
var preference = {}
preference = {
// ...
"back_urls": {
"success": "https://www.tu-sitio/success",
"failure": "http://www.tu-sitio/failure",
"pending": "http://www.tu-sitio/pending"
},
"auto_return": "approved",
// ...
}
PreferenceBackUrlsRequest backUrls =
// ...
PreferenceBackUrlsRequest.builder()
.success("https://www.seu-site/success")
.pending("https://www.seu-site/pending")
.failure("https://www.seu-site/failure")
.build();
PreferenceRequest request = PreferenceRequest.builder().backUrls(backUrls).build();
// ...
# ...
preference_data = {
# ...
back_urls = {
success: 'https://www.tu-sitio/success',
failure: 'https://www.tu-sitio/failure',
pending: 'https://www.tu-sitio/pendings'
},
auto_return: 'approved'
# ...
}
# ...
var request = new PreferenceRequest
{
// ...
BackUrls = new PreferenceBackUrlsRequest
{
Success = "https://www.tu-sitio/success",
Failure = "http://www.tu-sitio/failure",
Pending = "http://www.tu-sitio/pendings",
},
AutoReturn = "approved",
};
preference_data = {
"back_urls": {
"success": "https://www.tu-sitio/success",
"failure": "https://www.tu-sitio/failure",
"pending": "https://www.tu-sitio/pendings"
},
"auto_return": "approved"
}
The date uses the ISO 8601 format: yyyy-MM-dd'T'HH:mm:ssz