# Adding a Tip

You can add a tip either through our SDK on **ePOS** or directly on the **card machine**. See the documentation below for more details.

## Adding a Tip on ePOS

As mentioned in [Make Payment section](./make-payment), you can add a tip to `makePayment`.

```tabs
    tab:
      title: Kotlin (callbacks)
      content:
        ```kotlin
        val paymentSubscription = teyaPosLinkSDK.transactionsApi.makePayment(
            transactionId = UUID.randomUUID().toString(),
            amount = amountToPay,
            currency = "GBP",
            tip = 30 // An optional tip amount, in the smallest unit of the currency.
        )
        ```
    tab:
      title: Kotlin (coroutines)
      content:
        ```kotlin
        val paymentHandle = teyaPosLinkSDK.transactions.makePayment(
            transactionId = UUID.randomUUID().toString(),
            amount = amountToPay,
            currency = "GBP",
            tip = 30 // An optional tip amount, in the smallest unit of the currency.
        )
        ```
    tab:
      title: Java
      content:
        ```java
        PaymentStateSubscription paymentSubscription = teyaPosLinkSDK.getTransactionsApi().makePayment(
                UUID.randomUUID().toString(), // transactionId
                amountToPay, // amount
                "GBP", // currency
                30 // An optional tip amount, in the smallest unit of the currency.
        );
        ```
```

The tip parameter allows you to specify an optional tip amount, in the smallest unit of the currency (e.g., pence for GBP, cents for EUR/USD). When you provide a tip, it is treated as included within the total amount you pass.

For example, if you set:
```kotlin
amount = 100
tip = 20
```

In other words, the tip is not added on top of the amount, it is included within it. For example, if the total is **£1.00**, **£0.20** will go toward the tip and **£0.80** will be the purchased goods amount.

```admonition
icon: fas fa-info-circle
content: Please note that the tip cannot exceed the total transaction amount.
```

## Adding a tip on Card Machine

If you don't provide a tip amount in the `makePayment` function and tipping is enabled on the **card machine**, the tip can be selected directly on the card machine.

When a tip is selected this way, the `amount` and `tip` properties in the `PaymentStateDetails` object will be updated accordingly. These updates occur once the payment status changes to `Successful`, allowing you to see the final tip amount selected on the card machine.

```kotlin
public data class PaymentStateDetails(
    val eposTransactionId: String,
    val amount: Int,           // Total amount including tip; updated after a Successful payment with a terminal-side tip
    val tip: Int?,             // Tip amount; updated after a Successful payment with a terminal-side tip
    // ...
)
```
