Lionel Messi scored two goals and set up another as Barcelona prevailed 3-2 over Sampdoria to lift the Joan Gamper Trophy.