Back URLs
At the end of the payment process, it is possible to redirect the buyer back to your website via the back_urls
attribute. This attribute allows you to define the URLs where the buyer should be redirected according to the payment status.
In the following tables you will find the details of each of the possible request and response parameters.
Attribute | Description |
auto_return | Buyers are automatically redirected to site when payment is approved. The default value is approved . The redirect time is 40 seconds and this cannot be customized. |
back_urls | Return 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. |
Through the back_urls
, the following parameters will be returned:
Parameter | Description |
payment_id | ID (identifier) of the Mercado Pago payment. |
status | Payment status. Eg: approved for an approved payment or pending for a pending payment. |
external_reference | Reference you can synchronize with your payment system. |
merchant_order_id | ID (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.
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"
}