payments as well as discounting factors are continuous(i.e. changing by time) so do integrate both together, your method of solving is acceptable wherever discounting rate is constant.