Credit card interest is calculated daily and charged monthly. So when your balance changes due to purchases or payments, the amount of interest you pay will also change.
Example
Let’s say we have a credit card with a $4000 balance and an interest rate of 18% p.a. at the start of a 30-day statement period. If we made a payment of $2000 halfway through the cycle, we would pay a total of $44.10 in interest, made up of 15 days of interest on the $4000 (totalling $29.40) and 15 days interest on the $2000 balance (totalling $14.70).
If you make different types of transactions using your credit card, any payments will automatically go towards the part of the balance that attracts the highest rate of interest.