Flapping wings are a bio-inspired method to produce lift and thrust in aerial robots, leading to quiet and efficient motion. The advantages of this technology are safety and maneuverability, and physical interaction with the environment, humans, and animals. However, to enable substantial applications, these robots must perch and land. Despite recent progress in the perching field, flapping-wing vehicles, or ornithopters, are to this day unable to stop their flight on a branch. In this paper, we present a novel method that defines a process to reliably and autonomously land an ornithopter on a branch. This method describes the joint operation of a flapping-flight controller, a close-range correction system and a passive claw appendage. Flight is handled by a triple pitch-yaw-altitude controller and integrated body electronics, permitting perching at 3 m/s. The close-range correction system, with fast optical branch sensing compensates for position misalignment when landing. This is complemented by a passive bistable claw design can lock and hold 2 Nm of torque, grasp within and can re-open thanks to an integrated tendon actuation. The perching method is supplemented by a four-step experimental development process which optimizes for a successful design. We validate this method with a 700 g ornithopter and demonstrate the first autonomous perching flight of a flapping-wing robot on a branch, a result replicated with a second robot. This work paves the way towards the application of flapping-wing robots for long-range missions, bird observation, manipulation, and outdoor flight.