The visitors almost went ahead after just four minutes when Jon Taylor's right-footed shot from the edge of the box was saved.
Marcus Maddison threatened to open the scoring again for Peterborough as his left-footed strike whistled narrowly wide.
McDonald put the hosts ahead after a bullet header from Jake Hessenthaler's cross after 26 minutes.
However, Taylor's right-footed strike levelled the scoring moments before the half-time break to cancel out McDonald's opener.
Posh almost took the lead with 20 minutes remaining when Jack Baldwin struck the left post with a shot outside of the area.
The home side then won the match with just five minutes remaining after McDonald converted a penalty following a Christian Burgess hand-ball in the area.