SAN FRANCISCO — Angel Pagan and Marco Scutaro exchanged text messages nearly every day the past month, often discussing details about their ongoing contract negotiations with the Giants and others. The two veterans were hopeful they could return together atop the Giants’ lineup but realistic about the fluctuations of the market.

Pagan was seeking a fourth year on his deal, while Scutaro, likely looking at his final contract, was simply looking for the best deal. During the course of a little over 24 hours earlier this week, the Giants hit both marks. On Friday both players passed physicals, making official a four-year, $40 million deal for Pagan and a three-year, $20 million contract for Scutaro.

“I know how successful it was,” Pagan said of their first partnership together as the Giants’ one and two hitters. “I told him, ‘If you sign, I’ll sign.”‘

The order ended up being reversed. Pagan, a free agent for the first time, said he had a couple of other organizations making good offers, but he was waiting for a team to step up with a fourth year. He was hoping that team would be the Giants, where he became a fan favorite with his all-out style and production out of the leadoff spot and in center field, and where his wife made an immediate connection with the other players’ wives.

Pagan was so fond of his first season in San Francisco that he went out and bought the commemorative World Series DVD before the team could send out copies and said he has watched it five times already. When the Giants became the first team to go to a fourth year, Pagan immediately jumped on the deal.

“I didn’t hesitate,” he said. “I thought we got what we deserved and we would be in the place we want to be.”

Pagan was hoping Scutaro would find the same home, but the second baseman needed to let the market play out and was eager to avoid repeating a mistake he felt he made with his last contract. Scutaro signed a two-year deal with the Boston Red Sox before the 2010 season and said he passed on a higher-paying deal in order to play for a team he considered a winner.

“What I got was a bald head,” he said. “And we didn’t win anything.”

Scutaro confirmed that the Cardinals had offered him a two-year deal with a higher annual salary, but the Giants’ offer ended up being more lucrative when a third year was added. Scutaro, 37, will make $20 million on this deal after making $22.2 million total on all his previous big league deals.

“I know my age,” Scutaro said. “I was looking for the best contract. This might be my last one. When (the Giants) made the best offer, it was very exciting.”

Scutaro will return to his No. 2 spot in the order and is hopeful that he is healthy enough to be a full-time starter through all three years of his deal. He said he is aware that some might have doubts, but he can control only what he can control.

“You work hard to keep yourself in shape and you eat (right),” he said, proving that point by only occasionally picking at a fruit plate while talking to reporters in a Comcast makeup room stocked with sandwiches and chips. “If I stay healthy, I can be a good player the next four years.”