# Refund payment

As mentioned in the [Make Payment](./make-payment.md) section, you need to store the `gatewayPaymentId` included in `PaymentStateDetails` to access it later and pass it to the refund function.

```tabs
    tab:
      title: Kotlin
      content:
        ```kotlin
        val refundResultSubscription = teyaIntegration.refundPayment(
            paymentId = paymentId, // The gatewayPaymentId of the payment you want to refund
            amount = amount, // Amount in minor units
            currency = "GBP"
        )
        ```
    tab:
      title: Java
      content:
        ```java
        RefundResultSubscription refundResultSubscription = teyaIntegration.refundPayment(
                paymentId, // paymentId: The gatewayPaymentId of the payment you want to refund
                amount, // amount: Amount in minor units
                "GBP" // currency: The ISO 4217 currency code (e.g., "GBP", "EUR").
        );
        ```
```

```admonition
icon: fas fa-exclamation-triangle
content: |
    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.

```tabs
    tab:
      title: Kotlin
      content:
        ```kotlin
        refundResultSubscription.subscribe(object : RefundResultSubscription.RefundResultListener {
            override fun onRefundResult(refundResult: RefundResultSubscription.ResultDetails) {
                // Handle refund result here
            }
        })
        ```
    tab:
      title: Java
      content:
        ```java
        refundResultSubscription.subscribe(refundResult -> {
            // Handle refund result here
        });
        ```
```
