Acts 8:18 & 19

"When Simon saw that the Spirit was given at the laying on of the apostles' hands, he offered them money and said, 'Give me also this ability so that everyone on whom I lay my hands may receive the Holy Spirit.'" NIV translation

Simon the sorcerer had money and after he saw the apostles lay their hands on people, he wanted to buy the gift like some cheap magic trick. He wanted to purchase the ability to give the Holy Spirit and did not realize that it was a gift from God.

The same sort of thing happens in many churches today but it looks a little different. There are those who are willing and able to give the local church much money but do not want to be burdened with the whole following Jesus thing. The relationship with God is not for sale.

Acts 8:20 - 23

"Peter answered: 'May your money perish with you, because you thought you could buy the gift of God with money! You have no part or share in this ministry, because your heart is not right before God. Repent of this wickedness and pray to the Lord. Perhaps he will forgive you for having such a thought in your heart. For I see that you are full of bitterness and captive to sin.'" NIV translation

Simon wanted to buy the gift of being able to lay hands on someone and have them receive the Holy Spirit but he thought that he could buy it. Peter (the apostle) rebuked him and told him to repent of his sin. His whole answer is based on looking at the state of Simon's heart. The same is true of each and every one of us. God also knows and cares about our motives (what's in our heart). We may deceive each other but cannot deceive God. Do good works but do them for the right reason which is to bring glory to God not to yourself.