I doubt this would be legal as such or has so many side effects that this is not practical to do.
There are things like taxes and a merchant of the record. And a real charity usually has tax benefits.
You would still have to pay taxes for the income you then donate to some charity. And would in turn have tax benefits by deducting your donations from your taxable income.
I believe it would be more straightforward to encourage your users to donate to the charity directly, if you do not want the money on your bank account.