Here’s a simple way of looking at it.
Coupons are calculated based on the face value of the bond. Let’s say the bond’s face value is $100. Usually, this is the principal initially invested and also the principal that will eventually be repaid.
In the secondary market, the price can fluctuate. Let’s say you buy in the secondary market when the price is $110. If the bond carries a coupon of 5%pa, you’d expect to be paid $5 each year, regardless of the price on the secondary market. This annual $5 is the income component of the bond, also called coupon payments.
If you hold the bond to maturity, you’d expect to get $100 back (a capital loss of $10). If you sell when the price is $120, you have a capital gain of $10. If you sell when the price is $90, you have a capital loss of $20.
Your total return is made up of the income gains (coupon payments) and capital gain/loss.
So if you paid $110 for a $100 face value bond that pays 5%pa coupons maturing in 3 years, and hold the bond until maturity, your total income gain is 3x$5 = $15 income and your capital loss is $110-$100 = $10.
Some jurisdictions tax these separately, but you can add them up to work out your total 3-year return of $15-$10 = $5, from which you’d deduct fees and taxes to get your actual return.
Note that if the bond paid coupons twice a year ($2.50 each time) and you bought halfway between payments, you’d still get $2.50 at the next coupon payment, but you’d pay the seller $1.25 to account for the accrued ‘interest’.