You pay just for the Italian part. Depending on where you start from and go to you either cross at Domodossola or Chiasso.
The best way to go about this is, in my opinion:
- Look up times on sbb-tickets.cc for wherever you are to wherever you want to go to, eg. Luzern to Firenze…
- Look at the train details of the solution you want to use, and not where and when it crosses the border.
Then just buy a ticket Domodossola or Chiasso to your destination on www.trenitalia.com.
You just board the train in Switzerland, show the STP while in Switzerland, and your Italian ticket once in Italy.