Carter, who also had an assist, put the Flyers (1-1) ahead 1-0 at 4:05 of the first period with a one-timer from the crease after taking a pass from Mike Richards.
Carter's goal came with a two-man advantage and was the first power-play goal allowed by the Devils in 24 chances in the preseason.
Gagne, who led the Flyers with 47 goals last season, picked up a loose puck near the left circle and flipped it in at 16:10 of the second period.
New Jersey scored on a power play against rookie goaltender Martin Houle with 3:01 left in the third period when David Clarkson scored during a scramble in front of the net.
Philadelphia goaltender Antero Niittymaki, who had two shutouts last season as a rookie, stopped 20 shots in two periods. He thwarted four New Jersey power-play opportunities, including 1:42 of a two-man advantage midway through the first period.
Houle, a rookie, faced seven shots.
Martin Brodeur started in goal for the Devils (1-3) and allowed one goal and 17 shots before being replaced by Frank Doyle midway through the second period. Doyle faced 20 shots.
The Devils almost scored midway through the third period when Peter Vrana hit the left post.
The Flyers had nine power-play opportunities.