Pesachim 8: Tzadik Gamur

One who gives Tzdaka in order to be rewarded is a Tzadik Gamur, how does that fit with the Mishna in Avos?