Adding a Tip
You can add a tip either through your ePOS app (by passing a tip to the SDK) or directly on the card machine. This page explains both options and how the SDK reports the final values.
Adding a tip on ePOS (via SDK)
As mentioned in the Make Payment section, you can pass an optional tip to makePayment.
let transactionId = UUID().uuidString
let amountToPay: Int32 = 100 // total amount INCLUDING any tip, in the smallest currency unit (e.g., cents)
let tipAmount: Int32 = 20 // optional tip, in the smallest currency unit
let currency = "GBP"
let paymentSubscription = teyaPosLinkSDK.transactionsApi.makePayment(
transactionId: transactionId,
amount: amountToPay,
currency: currency,
tip: tipAmount.toKotlinInt()
)
extension Int32 {
func toKotlinInt() -> KotlinInt {
return KotlinInt(int: self)
}
}
Important: the amount parameter represents the total amount charged to the customer, and the optional tip is considered INCLUDED in that amount (not added on top).
For example, if you set:
let amountToPay: Int32 = 100
let tipAmount: Int32 = 20
Then £1.00 (100) is the total charged, where £0.20 (20) is the tip and £0.80 (80) is the goods amount.
Adding a tip on Card Machine
If you don’t provide a tip in the makePayment call and tipping is enabled on the card machine, the customer can select a tip directly on the card machine.
When a card machine-side tip is selected, the amount and tip properties reported by the SDK will be updated to reflect the final values once the payment reaches a final state (e.g., Successful).
The payment state object includes these fields among others: