If you had to pay the 3% on top then you were taken for a ride.
The 3% is supposed to come out of the agreed price. But instead of paying the vendor 100% of the agreed price, you pay 97% to the vendor, and 3% to the tax man. It’s all explained here: Spanish capital gains tax retention on property sales by non-residents
There is also more information on this forum see 3% retention tax