Refunds and cancellations
The examples on this page use the Payments API, which applies to Checkout Bricks payments. Use the id returned when creating the payment. If your integration uses a different API, check its management operations before running these examples.
Refunds are transactions made when a certain charge is reversed and the amounts paid are returned to the buyer. This means that the customer will receive back the amount paid for the purchase of a certain product or service on their account or credit card statement.
Cancellations end eligible payments that have not yet been completed. To return amounts from an approved and captured payment, issue a refund.
Cancellation availability depends on the payment status and method.
In this documentation, you will find the necessary information to perform a full and partial refund, and cancel a purchase in your store.
Cancellations
Before canceling a purchase, the following factors must be considered:
-
Current status: query the
status,status_detailand, for card authorizations,capturedfields in the response from Get paymentGET before requesting cancellation.pendingandin_processare values ofstatus. -
Eligibility: Payments with
status: pendingorstatus: in_processmay be eligible for cancellation, depending on the payment method. The examples below state the conditions and markets for each cancellation scenario. For payments already approved and captured, request a refund. -
Expiration: check
date_of_expirationand the rules of the payment method you integrated. Do not use a universal 30-day deadline to decide whether to cancel the purchase. After cancellation, confirm the payment status through the API; do not promise same-day credit-limit availability to the buyer. -
Boleto bancário: If the expiry date of a boleto bancário expires, the user can generate it again by entering the transaction ID of their Mercado Pago account. However, if you want to avoid stock retention problems, for example, you can choose not to make a new issue of this slip available. To do this, simply cancel it.
See Update paymentPUT for the cancellation operation parameters.
Refunds
Refunds can be made in two ways: full, when the total sale amount is returned to the buyer, or partial, when only part of the paid amount is returned to the buyer.
Before performing a refund, it is important to consider the factors below.
-
Refund Deadline: it is possible to refund a payment within 180 days of its approval date.
-
Account Balance: you must have sufficient balance available in your account to refund the amount, otherwise the transaction will not be concluded.
-
Payment method: for payments by credit card, the amount will be refunded directly on the invoice. For other payment methods such as Pix, for example, the amount will be returned to the payer's account.
To create a refund, see Create refundPOST. To check a completed operation, use Get specific refundGET from the Payments API.
Run operations with the Payments API
Keep the Access Token on the backend only. Replace PAYMENT_ID with the payment you want to manage. Before running the operation, query the payment to confirm its status and amount.
Choose the instructions for the payment’s current status. Cancellation, total refund and partial refund are alternatives; do not run all three examples in sequence on the same payment. Generate a unique key for each refund operation, such as a UUID v4, to replace the illustrative key in the examples.
To cancel an uncaptured authorization, query the payment and confirm that the response contains status: authorized, status_detail: pending_capture and captured: false. These fields describe the queried payment status; do not send them in the cancellation request body. In the PUT request, send {"status":"cancelled"}, as shown in the example below.
To cancel an eligible Pix payment still awaiting transfer (status: pending and status_detail: pending_waiting_transfer), use the same operation. After the request, query the payment and confirm status: cancelled, as shown in the example below.
To cancel the payment, use the Update paymentPUT operation, sending status: cancelled in the request body:
curlcurl -X PUT 'https://api.mercadopago.com/v1/payments/PAYMENT_ID' \ -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ -H 'Content-Type: application/json' \ -d '{"status":"cancelled"}'
After requesting cancellation, query the payment to confirm the result:
curlcurl 'https://api.mercadopago.com/v1/payments/PAYMENT_ID' \ -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
Example excerpt from that query response after a completed cancellation:
json{ "id": 123456789, "status": "cancelled", "status_detail": "by_collector" }
To refund an eligible approved payment, send a request to /v1/payments/{id}/refundsPOST without amount. Use an idempotency key to identify this refund attempt:
curlcurl -X POST 'https://api.mercadopago.com/v1/payments/PAYMENT_ID/refunds' \ -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ -H 'X-Idempotency-Key: FULL_REFUND_ATTEMPT_ID' \ -H 'Content-Type: application/json' \ -d '{}'
Example excerpt from the response to the refund request:
json{ "id": 987654321, "payment_id": 123456789, "amount": 100, "status": "approved" }
The response contains the refund’s id, which differs from payment_id. Query the payment to check status: refunded and the amount in transaction_amount_refunded.
To return only part of an eligible approved payment’s amount, send amount in the payment’s currency. The example requests a refund of 25 currency units:
curlcurl -X POST 'https://api.mercadopago.com/v1/payments/PAYMENT_ID/refunds' \ -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ -H 'X-Idempotency-Key: PARTIAL_REFUND_ATTEMPT_ID' \ -H 'Content-Type: application/json' \ -d '{"amount":25}'
Example excerpt from the response to the refund request:
json{ "id": 987654321, "payment_id": 123456789, "amount": 25, "status": "approved" }
After the operation, query the payment. For a payment of 100 with only this refund, the expected result is status: approved, status_detail: partially_refunded and transaction_amount_refunded: 25. The refund response’s amount field shows the amount returned in that operation.
Check the operation
To query the payment and the specific refund, use the IDs returned by the API:
curlcurl 'https://api.mercadopago.com/v1/payments/PAYMENT_ID' \ -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
curlcurl 'https://api.mercadopago.com/v1/payments/PAYMENT_ID/refunds/REFUND_ID' \ -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
If a refund request needs to be repeated, reuse the same idempotency key and body. Use a different key for a new refund operation. If the API returns an error, query the payment and existing refunds before starting another operation. An amount greater than the available refundable amount can be rejected; do not consider a refund complete just because the request was sent.