The double-differential cross sections of promptly produced J/psi and psi(2S) mesons are measured in pp collisions at root s = 7 TeV, as a function of transverse momentum p(T) and absolute rapidity \y\. The analysis uses J/psi and psi(2S) dimuon samples collected by the CMS experiment, corresponding to integrated luminosities of 4.55 and 4.90 fb(-1), respectively. The results are based on a two-dimensional analysis of the dimuon invariant mass and decay length, and extend to p(T) = 120 and 100 GeV for the J/psi and psi(2S), respectively, when integrated over the interval \y\ < 1.2. The ratio of the psi(2S) to J/psi cross sections is also reported for \y\ < 1.2, over the range 10 < p(T) < 100 GeV. These are the highest p(T) values for which the cross sections and ratio have been measured.