We encountered the same thing with our son's Volvo. We bought key fobs on Amazon and took them to the largest and oldest Locksmith in town, after confirming they could do it. One of their machines was not capable of programming the fobs. The other machine would only program the key to start the car. Digging a little deeper, the tech found that the car's Immobilizer system had to be decrypted to get the 4 digit code needed to program the fob to unlock the doors and start the car. Volvo would not provide the locksmith with the 4 digit code, so we made an appointment to come back since the decryption process took several hours. They charged $50 to program the key fobs. It took about 5 hours to get the key fobs programmed.
The only other option for us would have been driving an hour to a Volvo dealer and pay close to $300 per key fob. We bought 2 fobs on Amazon for $70.
-Michael