Home
Documentation
Resources
Partners
Community

Partners

Discover our program for agencies or developers that offer integration services and sellers who want to hire them.

Community

Get the latest news, ask others for help and share your knowledge.

Back URLs - User interface - Mercado Pago Developers

Intelligent search powered by OpenAI 

Back URLs

At the end of the payment process with credit card, it is possible to redirect the buyer back to your website via the back_urls attribute. This attribute allows you to define the URLs to which the buyer will be redirected, either automatically (auto_return) or through the "Return to site" button, depending on the payment status.

Automatic redirection
If you want the redirection for approved payments to be automatic, you must also add the auto_return attribute with the value approved. By default, a "Return to site" button will also be displayed. The redirection time will be up to 40 seconds.

Payments with other payment methods do not have automatic redirection for approved payments, but the back_urls attribute can be configured and used through the "Return to site" button.

In the following tables you will find the details of each of the possible request and response parameters.

AttributeDescription
auto_returnBuyers are automatically redirected to site when payment is approved. The default value is approved. The redirection time will be up to 40 seconds and cannot be customized.
back_urlsReturn URL to the site. Possible scenarios are:

success: Return URL when payment is approved.

pending: Return URL when payment is pending.

failure: Return URL when payment is rejected.
Important
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.

Through the back_urls, the following parameters will be returned:

ParameterDescription
payment_idID (identifier) of the Mercado Pago payment.
statusPayment status. Eg: approved for an approved payment or pending for a pending payment.
external_referenceReference you can synchronize with your payment system.
merchant_order_idID (identifier) of the payment order generated in Mercado Pago.

To define the back_urls, use one of the SDKs below informing the URLs where the buyer should be directed when finalizing the payment.

In addition to the SDKs, it is also possible to set the back_urls through the preferences API. To do so, send a POST with the back_urls attribute informing the URLs where the buyer should be directed when finalizing the payment to the endpoint /checkout/preferences and execute the request.
          
<?php
$preference = new MercadoPago\Preference();
//...
$preference->back_urls = array(
    "success" => "https://www.seu-site/success",
    "failure" => "http://www.seu-site/failure",
    "pending" => "http://www.seu-site/pending"
);
$preference->auto_return = "approved";
// ...
?>

        
          
var preference = {}
preference = {
  // ...
  "back_urls": {
        "success": "https://www.seu-site/success",
        "failure": "http://www.seu-site/failure",
        "pending": "http://www.seu-site/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"
}