Refund a Payment
The Get Mini Android SDK allows you to return funds to a customer’s card for previously authorized transactions. In this SDK, refunds are typically referential (based on the original transaction identifiers) and processed as a network operation, though a card-present “Refund Without Original” is also supported as a fallback.
Requirements
Before processing a refund, ensure:
- The SDK is initialized and the merchant is logged in.
- You have the Terminal Data (
RedCLSTerminalData) obtained during login. - You have the Original Transaction Data (
identifierRTS,order, etc.).
Step 1: Prepare the Refund Data
To perform a standard refund, you should use the RedCLSTransactionData object received during the original sale or obtained through a query operation.
Whenever possible, use the RedCLSTransactionData object returned by the original sale or by a query operation. Manual instantiation should be used only when the original object is not available.
The amount field in the RedCLSTransactionData passed to the refund manager must contain the specific amount you wish to refund (which can be a partial amount).
import redcls.itpvpc.data.RedCLSTransactionData
import redcls.itpvpc.data.RedCLSRefundData
// 1. Prepare the original transaction data
// PREFERRED: Use the object returned by a previous sale or query.
// FALLBACK: If the original object is not available, instantiate it manually.
val originalTx = RedCLSTransactionData().apply {
order = "12345"
identifierRTS = "012345678901234567890123"
amount = "10.00" // The amount to be refunded
}
// 2. Wrap it in a RefundData object with your terminal configuration
val refundData = RedCLSRefundData(merchantTerminalData, originalTx)Refund from Another Merchant in the Same Group
If the original transaction was processed under a different merchant (within the same group), you must use the alternative RedCLSRefundData constructor which does not require a transaction object:
val interMerchantRefundData = RedCLSRefundData(
merchantTerminalData, // Your current terminal data
"987654321", // originalMerchantFuc
"123456", // originalOrder
"10.00", // amountToRefund
"20231027", // originalDate (yyyyMMdd)
"999999" // originalAutorizationNumber
)Step 2: Execute the Refund
Refunds are handled by the RedCLSRefundManager. This is a network operation and typically does not require a card to be inserted unless performing a “Refund Without Original”.
import redcls.itpvpc.managers.RedCLSRefundManager
Thread {
val response = RedCLSRefundManager.peticionDevolucion(context, refundData)
if (response.status == 0) {
// Refund was successfully processed by the host
Log.d("GetMini", "Refund approved. Identifier: ${response.getIdentificadorRTS()}")
} else {
Log.e("GetMini", "Refund failed: ${response.msgKO}")
}
}.start()Step 3: Refund Without Original (Card-Present)
If you do not have the original transaction identifiers (e.g., for legacy transactions or lost data), you must perform a card-present refund. This requires the customer to present the card at the PIN pad.
// Using the PinPadManager instead of the RefundManager
// NOTE: This method expects a Double for the amount
val response = pinpadManager.devolucionSinOriginal(10.00, "INV-REF-001")
if (response.status == 0) {
Log.d("GetMini", "Card-present refund approved")
}Best Practices
- Partial Refunds: You can perform multiple partial refunds as long as the cumulative total does not exceed the original transaction amount.
- Reference the Original: Always link the refund in your system to the original
orderandidentifierRTSfor cleaner accounting and customer support. - Receipts: The
RedCLSRefundResponseincludes a “Response” XML string. Ensure your receipt logic extracts theResultadoandCodigoRespuestato confirm authorization to the customer.
Next Steps
- Create a Single-Step Payment - Review the base sale operation.
- Create a Pre-authorized Payment - Reserve funds for later capture.
- Create a Payment with Installments - Learn about installments.