Further to Grehan’s points, which are completely correct:
This practise has always been illegal but widely practised at the same time. It looks like it is getting less common and the authorities are doing more to tackle it. However for the time being it is still something that many buyers will have to deal with, especially when buying resales from Spaniards. Buyers should do everything to resist or minimise undeclared payments as they benefit little and may one day have to pay the taxes avoided by the vendor. It also means having to handle a lot of cash during the process, which presents it’s own problems.
In short, don’t do it if you can avoid it (and never buy from a developer who asks for undeclared payments, or B-money as it is known in Spain). But if the vendor insists, and you want the property, your options are limited.