18 For what you have, even Simon Magus had: the Acts of the Apostles are witness, that canonical book which has to be read in the Church every year. You know that every year, in the season following the Lord's Passion, that book is read, wherein it is written, how the apostle was converted, and from a persecutor became a preacher; also, how on the day of Pentecost the Holy Spirit was sent in cloven tongues as of fire. There we read that in Samaria many believed through the preaching of Philip: and he is understood to have been either one of the apostles or one of the deacons; for we read there that seven deacons were ordained, among whom is the name of Philip.
Well, then, through the preaching of Philip the Samaritans believed; Samaria began to abound in believers. This Simon Magus was there. By his magical arts he had so befooled the people, that they fancied him to be the power of God. Impressed, however, by the signs which were done by Philip, he also believed; but in what manner he believed, the events that followed afterwards proved. And Simon also was baptized. The apostles, who were at Jerusalem, heard this. Peter and John were sent to those in Samaria; they found many baptized; and as none of them had as yet received the Holy Ghost—in like manner as He at that time descended, so as that they on whom the Holy Spirit came should speak with tongues, for a manifest token that the nations would believe—they laid their hands on them, praying for them, and they received the Holy Ghost.
This Simon— who was not a dove but a raven in the Church, because he sought his own things, not the things which are Jesus Christ's; whence he loved the power which was in the Christians more than the righteousness— Simon, I say, saw that the Holy Spirit was given by the laying on of the hands of the apostles (not that it was given by them, but given in answer to their prayers), and he said to them, “How much money will you that I give you, so that by the laying on of my hands also, the Holy Ghost may be given?
And Peter said unto him, Your money perish with you, because you thought that the gift of God was to be bought with money.” To whom said he, “Your money perish with you”? Undoubtedly to one that was baptized. Baptism he had already; but he did not cleave to the bowels of the dove. Understand that he did not; attend to the very words of the Apostle Peter, for he goes on, “You have no part nor lot in this faith: for I see that you are in the gall of bitterness.” The dove has no gall; Simon had, and for that reason he was separated from the bowels of the dove.
What did baptism profit him? Do not therefore boast of your baptism, as if that were of itself enough for your salvation. Be not angry, put away your gall, come to the dove. Here that will profit you, which without not only did not profit you, but even was prejudicial to you.
Source: Tractates on the Gospel of John (New Advent)