AI resources

Cancel reserve

Cancellation of a reserve occurs when, for some reason, the payment for a purchase is not approved and the reservation amount needs to return to the customer's card limit or when a buyer withdraws from the purchase. For more information about refunds and cancellations of payments, see the section Refunds and Cancellations.

To cancel a reserve, use one of our available codes below.

<?php
  use MercadoPago\Client\Payment\PaymentClient;

  MercadoPagoConfig::setAccessToken("YOUR_ACCESS_TOKEN");

  $client = new PaymentClient();
  $request_options = new RequestOptions();
  $request_options->setCustomHeaders(["X-Idempotency-Key: <SOME_UNIQUE_VALUE>"]);

  $payment = $client->cancel($payment_id, $request_options);
  echo $payment->status;
?>

The response will show the following result:

json
{
...
"status": "canceled",
"status_detail": "by_collector",
...
"captured": false,
...
}