The team are on an inhospitable planet. They've discovered that Mann was falsifying the data about the conditions on the surface. Mann was attempting to strand them on a planet that they would simply not be able to survive long term.
They didn't have any option but to attempt to dock with the single ship capable of getting them to another survivable space, be that Earth or on to Edmund's planet. Its clear that Cooper realizes that they have no option but to attempt to dock with and save the Endurance:
CASE
Endurance rotation is 67, 68 RPM -
COOPER
Get ready to match it on the retro-thrusters -
CASE
It’s not possible -
COOPER
No. It’s necessary.
So Cooper was attempting what's quite often called a "Hail Mary" in American Football. A late game, extremely unlikely and often unsuccessful play - but the only one available to save the game.
When he succeeds, the "For our next trick" comment is a joke - a tension reliever. They've succeeded in so far as giving themselves a glimmer of hope that they might survive. Until they get into the Endurance and see how damaged it is, whether its capable of being flown they have no idea whether it was worth the docking attempt, but they had to attempt it.
My assumption is that there was 'no plan' other than give themselves the only possible slim option of survival, get onboard the Endurance. In a perfect world, they would have had a good enough ship to return to Earth, but at least they found they had an option to get Brand to Edmund's world.
The alternatives were to die in the Ranger or to return to Mann's planet and go to sleep. However they knew that there was little or no hope for NASA to build another Endurance and follow them there to rescue them.