MercadoPago provides an API to make refunds. There are two types of refund: Full Refund (the payment is completely refunded), or Partial Refund (part of the payment is refunded).
See the Web Panel RefundsBasic under Sample folder for more details about the following code.
To make a full refund, you will need the Collection's Id.
Event 'FullRefund'
MercadoPago.PaymentBasicCheckout.FullRefund(&PaymentId,&CollectionInfoSDT,&Message,&ErrorCode)
&ResponsePaymentInfo = &CollectionInfoSDT.ToXml()
if &ErrorCode = 0
//Success
else
Msg(&Message.Description)
endif
Endevent
&CollectionInfoSDT is CollectionInfoSDT data type, which is used to receive information about the refund.
&Message contains a description in case an error occurs.
To make a partial refund, you will need the Collection's Id and the amount that is going to be refunded.
Note: That amount cannot be greater than the payment's total cost.
Event 'PartialRefund'
MercadoPago.PaymentBasicCheckout.PartialRefund(&PaymentId,&refundAmount,&RefundBasicSDT,&Message,&ErrorCode)
&ResponsePaymentInfo = &RefundBasicSDT.ToXml()
if &ErrorCode = 0
//Success
else
Msg(&Message.Description)
endif
EndEvent
&RefundBasicSDT is RefundBasicSDT data type, which is used to receive information about the refund.
&Message contains a description in case an error occurs.
&refundAmount is the amount to be refunded.
To cancel a payment, you will need the Payment's Id.
Event 'CancelPayment'
MercadoPago.PaymentBasicCheckout.CancelPayment(&PaymentId,&CollectionInfoSDT,&Message,&ErrorCode)
&ResponsePaymentInfo = &CollectionInfoSDT.ToXml()
if &ErrorCode = 0
//Success
msg(Format('-Cancelation operation status:%1', &CollectionInfoSDT.status))
else
Msg(&Message.Description)
endif
Endevent
&CollectionInfoSDT is used to receive the payment's new status, where you can confirm the cancellation was made successfully.
- Only
pending
or in_process
payments can be canceled.
- Cancelled coupon payments, deposits, and transfers will be deposited in the buyer’s MercadoPago account.