Refund payment

As mentioned in the Make Payment section, you need to store the gatewayPaymentId included in PaymentStateDetails to access it later and pass it to the refund function.

Kotlin

val refundResultSubscription = teyaIntegration.refundPayment(
    paymentId = paymentId, // The gatewayPaymentId of the payment you want to refund
    amount = amount, // Amount in minor units
    currency = "GBP"
)

You need to specify the 'amount' because partial refunds are supported. For example, if the original payment was £2.99, you don't have to refund the full amount, you can refund a portion of it, such as £1.00.
Please note that the amount cannot exceed the total transaction amount.

Refund result

To receive the refund result, you need to subscribe to the RefundResultSubscription object returned by the refundPayment function. The listener will receive the final ResultDetails, which contains the outcome of the refund process.

Kotlin

refundResultSubscription.subscribe(object : RefundResultSubscription.RefundResultListener {
    override fun onRefundResult(refundResult: RefundResultSubscription.ResultDetails) {
        // Handle refund result here
    }
})