The short answer is, no, a church should not accept money knowing it was obtained in an ungodly manner. However, it is important to define what ungodly means in this context.
For example, a church certainly should not accept money obtained through theft. Doing so condones or accepts an action that is both immoral and illegal. A church or ministry that knowingly accepts illegally obtained funds jeopardizes its character and places itself in a position of legal liability.
An example of a “ministry” refusing funds is found in Matthew 27. When Judas Iscariot attempted to return the 30 pieces of silver he had received to betray Jesus, the chief priests said, “It is against the law to put this into the treasury, since it is blood money” (Matthew 27:6). They knew it was not lawful to accept income knowingly used for illegal purposes. The irony, of course, is that the chief priests themselves had paid Judas in the first place (Matthew 26:14–16). Theirs was a selective scrupulousness.
Some situations involve a level of ambiguity. For example, we would define ungodly as “sinful” or “against God.” But many people work in industries or in ways that at times could be considered sinful. If churches were to investigate every gift to determine whether it was earned in a “godly” manner, it would place an unjust burden on the church, as well as create many complicated situations regarding what is defined as godly or ungodly.
Churches in the New Testament encouraged believers to work hard to earn their money in responsible ways and then to give generously to the work of their local church and other missionary activity. Paul wrote in Acts 20:35, “In everything I did, I showed you that by this kind of hard work we must help the weak, remembering the words the Lord Jesus himself said: ‘It is more blessed to give than to receive.’” In 1 Corinthians 4:12 he added, “We work hard with our own hands” (see also 1 Thessalonians 2:9).
It is likely many of the early believers worked in trades that were secular and involved in activities that could have at times been considered ungodly. However, the emphasis was on honoring God with one’s work (Colossians 3:16–17) and generosity.
Each local church has the opportunity to create its own policies and to distinguish acceptable gifts from unacceptable gifts. A church might draft a policy forbidding financial gifts that are overtly political or directly tied to the sale of alcohol, for example.
In summary, there are certain gifts a church should decline. Some of these are clearly identifiable, while others are less clear. Each congregation should define what gifts would be unacceptable and then help promote a godly work ethic and generosity within the church.