# MD for: https://www.mercadopago.com.br/developers/en/docs/checkout-bricks/wallet-brick/advanced-features/preferences.md \# Preference configurations You can adapt the Wallet Brick integration to your business model by setting \[preference attributes\](https://www.mercadopago.com.br/developers/en/reference/online-payments/checkout-pro/preferences/create-preference/post). If you offer high-value purchases, for example, you can accept \[payments with two credit cards\](#bookmark\_accept\_payments\_with\_2\_credit\_cards) or \[delete undesired payment methods\](#bookmark\_define\_the\_desired\_payment\_methods) for your operation. ## Example of complete preference \`\`\`json { "items": \[ { "id": "item-ID-1234", "title": "Mi producto", "currency\_id": "BRL", "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": "test@testuser.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 \*\*Linha de Crédito\*\*. 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 Linha de Crédito 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\](https://www.mercadopago.com.br/developers/en/reference/online-payments/checkout-pro/preferences/create-preference/post) and execute the request or, if you prefer, use one of our SDKs below. * [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 ``` title = 'My product'; $item->quantity = 1; $item->unit_price = 75; $preference->items = array($item); $preference->purpose = 'onboarding_credits'; $preference->save(); ?> ``` Copiar ``` // 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); }); ``` Copiar ``` // 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 items = new ArrayList<>(); items.add(item); PreferenceRequest request = PreferenceRequest.builder().items(items).purpose("onboarding_credits").build(); client.create(request); ``` Copiar ``` 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'] ``` Copiar ``` // Create the preference request object var request = new PreferenceRequest { Items = new List { new PreferenceItemRequest { Title = "My product, quantity = 1, CurrencyId = "BRL", UnitPrice = 75m, }, }, Purpose = "onboarding_credits", }; // Create the preference var client = new PreferenceClient(); Preference preference = await client.CreateAsync(request); ``` Copiar ``` 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"] ``` Copiar ``` 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" }' ``` Copiar \## 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, ticket (boleto or payment in lottery), 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: * [csharp ](#editor%5F12) * [java ](#editor%5F10) * [node ](#editor%5F9) * [php ](#editor%5F8) * [python ](#editor%5F13) * [ruby ](#editor%5F11) php node java ruby csharp python ``` payment_methods = array( "excluded_payment_methods" => array( array("id" => "master") ), "excluded_payment_types" => array( array("id" => "ticket") ), "installments" => 12 ); // ... ?> ``` Copiar ``` var preference = {} preference = { //... "payment_methods": { "excluded_payment_methods": [ { "id": "master" } ], "excluded_payment_types": [ { "id": "ticket" } ], "installments": 12 } //... } ``` Copiar ``` PreferenceClient client = new PreferenceClient(); //... List excludedPaymentMethods = new ArrayList<>(); excludedPaymentMethods.add(PreferencePaymentMethodRequest.builder().id("master").build()); excludedPaymentMethods.add(PreferencePaymentMethodRequest.builder().id("amex").build()); List 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); //... ``` Copiar ``` #... preference_data = { # ... payment_methods: { excluded_payment_methods: [ { id: 'master' } ], excluded_payment_types: [ { id: 'ticket' } ], installments: 12 } # ... } #... ``` Copiar ``` var paymentMethods = new PreferencePaymentMethodsRequest { ExcludedPaymentMethods = new List { new PreferencePaymentMethodRequest { Id = "master", }, }, ExcludedPaymentTypes = new List { new PreferencePaymentTypeRequest { Id = "ticket", }, }, Installments = 12, }; var request = new PreferenceRequest { // ... PaymentMethods = paymentMethods, }; ``` Copiar ``` #... preference_data = { "excluded_payment_methods": [ { "id": "master" } ], "excluded_payment_types": [ { "id": "ticket" } ], "installments": 12 } #... ``` Copiar \## 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\](https://www.mercadopago.com.ar/settings/my-business)" 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 Linha de Crédito. This allows your customers to have their account information available instantly at the time of payment, such as their pre saved cards and addresses. > WARNING > > Important > > By adding this option, you will not be able to receive payments from users who do not have a Mercado Pago or Mercado Livre account, as well as you will not be able to receive payments via cash or transfer. 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: * [json ](#editor%5F14) json The date uses the ISO 8601 format: yyyy-MM-dd'T'HH:mm:ssz ``` "date_of_expiration": "2020-05-30T23:59:59.000-04:00" ``` Copiar \> NOTE > > Note > > The crediting period is between one day and two working days, depending on the chosen payment method. Therefore, we recommend setting the expiration date at least three days apart to ensure that payment is made. > \> If the payment is made after the expiration date, the amount will be refunded in the payer's Mercado Pago account. ## 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 \`\`\` > WARNING > > Important > > Activating the binary mode simplifies the integration with Wallet Brick, but it can cause a decrease in the percentage rate of approved payments. That is because pending and in-processing payments will automatically be rejected by default. ## 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: * [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 ``` 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(); ?> ``` Copiar ``` // Set your preference var preference = { items: [ { title: 'Mi producto', quantity: 1, currency_id: 'BRL', unit_price: 75.56 }, { title: 'Mi producto 2’, quantity: 2, currency_id: 'BRL', 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); }); ``` Copiar ``` // Create a preference object PreferenceClient client = new PreferenceClient(); // Create items in the preference List 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); ``` Copiar ``` sdk = Mercadopago::SDK.new('ENV_ACCESS_TOKEN') # Create preference data with items preference_data = { items: [ { title: 'Mi producto 1', quantity: 1, currency_id: 'BRL', unit_price: 75.56 }, { title: 'Mi producto 2', quantity: 2, currency_id: 'BRL', unit_price: 96.56 } ] } preference_response = sdk.preference.create(preference_data) preference = preference_response[:response] ``` Copiar ``` // Create the request with multiples items var request = new PreferenceRequest { Items = new List { new PreferenceItemRequest { Title = "My product 1", Quantity = 1, CurrencyId = "BRL", UnitPrice = 75.56m, }, new PreferenceItemRequest { Title = "My product 2", Quantity = 2, CurrencyId = "BRL", UnitPrice = 96.56m, }, // ... }, }; // Create a client object var client = new PreferenceClient(); // Create the preference Preference preference = await client.CreateAsync(request); ``` Copiar ``` # 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"] ``` Copiar ``` 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" } ] }' ``` Copiar 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. > WARNING > > Do not use local domains in the \`back\_urls\` value, such as 'localhost/' or '127.0.0.1' with or without a specified port. We recommend using a server with a named domain (DNS) or development IPs to be able to return to the site after payment. Otherwise, the "Something went wrong" message will appear when the purchase process is completed. 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. | > NOTE > > Note > > Some parameters hold purchase information only if the buyer has completed the entire payment in Wallet Brick and has not abandoned the flow before returning to your site via the \`failure\` \`back\_urls\`. For example: * [csharp ](#editor%5F26) * [java ](#editor%5F24) * [node ](#editor%5F23) * [php ](#editor%5F22) * [python ](#editor%5F27) * [ruby ](#editor%5F25) php node java ruby csharp python ``` 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"; // ... ?> ``` Copiar ``` 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", // ... } ``` Copiar ``` 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(); // ... ``` Copiar ``` # ... 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' # ... } # ... ``` Copiar ``` 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", }; ``` Copiar ``` 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" } ``` Copiar