Disable/hide Payment Method For Specific Products

Is there a way to block, or hide, a payment method if a certain product is purchased?

For instance, we are looking at digital downloads and don't want to offer the cash on delivery option for them, but we do want to offer cash on delivery for other items.

I know there is probably a way of doing it in the core, but we wanted to avoid that if possible. We also want to avoid 3rd party plug-ins as we don't want support to suddenly disappear later in the sites life.

To be honest, the ability to limit COD for digital purchases seems a bit of a no brainer anyway, but there we go.

I am afraid, it is not possible out of the box. There were solutions from 3rd party developers on the marketplace