Refund
2 min
It is important to note that refunds are still a work in progress, therefore minor changes to the SDK may be required in future releases.
Starting a refund
Refunds work very similarly to purchases , with a few key differences.
- The TransactionType must be specified as Refund when calling toro.startTransaction()
- There needs to be an existing purchase to refund.
- Some details of the original purchase are required in order to initiate the refund.
- The refund amount cannot be more than the original purchase amount.
- Gratuities are not applicable.
- The refund amount cannot be greater than the original purchase amount.
toro.startTransaction(
amount = 1000,
type = TransactionType.Refund
currencyCode = CurrencyCode.GBP,
metadata = TransactionMetadata(
originalTransactionDetails = originalTransactionDetails
),
onCompleted = { receipt ->
println("Transaction completed: ${receipt.transactionId}")
},
onCancelled = { cancellationType ->
when (cancellationType) {
CancellationType.ATTENDANT -> println("Transaction cancelled in app")
CancellationType.CUSTOMER -> println("Transaction cancelled on Miura device")
}
},
onError = { error ->
when (error) {
is DeviceNotSelected -> handleDeviceError(error)
is DeviceConnectionFailed -> reconnectDevice()
is DeviceDisconnected -> showReconnectionPrompt()
else -> showErrorMessage(error.message)
}
}
)Below is an example OriginalTransactionDetails object which needs to be passed through the TransactionMetadata.
OriginalTransactionDetails(
saleReferenceId = "sale-12345",
amount = 1000,
currency = CurrencyCode.GBP,
dateTime = "2025-01-01T00:00:00.000Z",
transactionReference = "purchase_12345123",
responseCode = ResponseCode.APPROVED,
authCode = "123456",
paymentInterface = PaymentInterface.CONTACT,
terminalSerialNumber = "2110022",
additionalResponseInformation = "01:XZZ022a3a0a9a99f1B5MXJYICT525HCF"
)