Skip to content

Refunds

Call startRefund() to process a referenced refund against a previous transaction.

Function signature

fun startRefund(
    idempotencyId: String? = null,
    transactionId: String,
    refundAmount: Long,
    refundCallback: MPOSRefundCallback,
)
ParameterTypeRequiredDescription
idempotencyIdString?NoOptional identifier used to idempotently identify refund requests.
transactionIdStringYesThe ID of the original transaction to refund.
refundAmountLongYesAmount to refund in cents. Cannot exceed the original transaction amount.
refundCallbackMPOSRefundCallbackYesCallback receiving the refund result or error.

Callback

MPOSRefundCallback

interface MPOSRefundCallback {
    fun onSuccess(result: RefundResult?)
    fun onError(errorMessage: String)
}
mpos.startRefund(
    idempotencyId = null,
    transactionId = "TRxxxxxx",
    refundAmount = 500L,
    refundCallback = object : MPOSRefundCallback {
        override fun onSuccess(result: RefundResult?) { }
        override fun onError(errorMessage: String) { }
    }
)

mpos.startRefund(
    idempotencyId = null,
    transactionId = "TRxxxxxx",
    refundAmount = 500L,
    refundCallback = object : MPOSRefundCallback {
        override fun onSuccess(result: RefundResult?) {
            // refund approved
        }
        override fun onError(errorMessage: String) {
            // refund failed
        }
    }
)