Peg and I booked tickets ahead of time (but really didn't need to.) Renfe train from Barcelona to Pamplona and Alsa/Conda bus from Pamplona to SJPdP (also an overnight stay in Pamplona at a place I won't recommend but not so bad that I'll warn you away from it so it will remain unnamed.) This was in 2015 and to get the Renfee ticket from the US I had to use Paypal, they wouldn't accept a credit card. Perhaps this changed since. Anyway, here is the Renfe site and two others that could book the ticket for you and may take a credit card.
http://www.renfe.com/
https://www.seat61.com/
https://loco2.com/
Here's a caution on booking online. When you use a calendar widget to pick a date note whether the weeks shown start on a Monday or a Sunday. Otherwise if you book by the the day of the week instead of the date you could get a ticket for the wrong day. For example, you may think you are booking for the first Sunday of the month but in reality getting a booking for the Monday that follows. That mistake cost us an extra (but wonderful) night in Barcelona.
The bus service between Pamplona to St. Jean Pied de Port is proved by CONDA, a bus company serving Navarra. CONDA is partially owned by ALSA, a larger Spanish bus company. The CONDA schedules are incorporated on the ALSA website and CONDA tickets can be bought online ahead of time from the ALSA website as well. When using the ALSA website to find transportation to St. Jean Pied de Port you must spell out
St. in full as
Saint or the town will not be found. The ALSA website in English is at URL
https://www.alsa.es/en/
While in Barcelona you must visit
La Sagrada Família. Tears came to my eyes when I went in. I wish that before walking that I had seen the Romanesque art collection at
the National Museum of Art of Catalonia in Barcelona.
Finally, here is a link to an interactive map of Pamplona to help you get between the city's train and bus station:
Link