Call startRefund() to process a referenced refund against a previous transaction.
Function signature
fun startRefund(
idempotencyId: String? = null,
transactionId: String,
refundAmount: Long,
refundCallback: MPOSRefundCallback,
)| Parameter | Type | Required | Description |
|---|---|---|---|
idempotencyId | String? | No | Optional identifier used to idempotently identify refund requests. |
transactionId | String | Yes | The ID of the original transaction to refund. |
refundAmount | Long | Yes | Amount to refund in cents. Cannot exceed the original transaction amount. |
refundCallback | MPOSRefundCallback | Yes | Callback receiving the refund result or error. |
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
}
}
)