Welcome! Others will soon give precise information, but meantime: Yes, I would try to book from Barcelona to Pamplona. If your train arrives after the bus has gone to St Jean, you could either enjoy the afternoon in Pamplona and take the bus next day, spending the night then in St Jean, or keep wondering if anyone would be travelling at the same time as you after arriving in Pamplona, to share a taxi to St Jean. If this helps your planning, fine. The trip to St Jean is not that long, and of course much cheaper by bus, but you would need to pay for accommodation overnight in Pamplona, so it is a question of which is preferable for you. All the best, and buen camino.