This flap can only be opened when the ignition key is pressed into the lock. The closing mechanism is then remote controlled by a pull and opens the flap against a spring loaded mechanism to which this catch hook belongs.
It is fixed quite simply with a metal plate, the spring is a little tricky to mount, which is why this mechanism is often defective in third hand vehicles.
Original Piaggio component.