It is useful to separate the question of your tax obligations from any other concerns about the legitimacy of the arrangement. It seems the worst-case (for you) position that the IRS could take is that you are being paid as a contractor but have elected to have your customer donate that payment on your behalf.
This would be somewhat similar to elective payroll deductions for charitable donations that many employers offer -- you never see the money directly, but it is treated as paid to you and then donated by you to the third-party charity (normally this is only a small fraction of wages though).
So if you conservatively treat the transaction as (1) your receipt of contractor income and (2) your donation of that same amount, and you pay the consequences of that including full self-employment and income tax on (1) and limited deductibility of (2), then you should be in the clear. And if there is any doubt that the donation has actually happened and has benefited a legitimate third-party charity, you could decline to claim any deduction for (2) to be safe.
You may not like the cost of this approach (working induces negative cash flow), but it may be the best you can do with your "work for donation" setup, unless you can get reliable personal tax advice (which this answer is not) to justify being more aggressive, e.g., not considering the donated payment as income at all.
Apart from the above is any concern about whether, by directly donating your compensation instead of paying it to you, your customer is improperly employing you for less than minimum wage and/or failing to issue a required 1099 or W-2 and/or failing to pay its share of payroll taxes if you are deemed an employee. Any such investigation or enforcement would be directed against your customer/employer and not you, and could only improve your financial position relative to the above.