The same thing happened to me, and I managed to find a solution for my case. This is iPhone and Apple-specific.
I made a purchase for the $0.99 Community Day Special Research at the Pokemon Go shop. I haven't made any Apple purchases for some time, and this purchase seemed to have some problems and I got an error, but the special research was still given to me. After that, every time I try to get anything from the Pokemon Go Shop, even if it is a free item like the daily free box, I get that terrible spinning wheel which never returns until I am forced to quit the app. I tried resetting the network, uninstalling and reinstalling the Pokemon Go app, switching my iPhone on and off, and resetting the network, but nothing worked. I tried logging in to another account on the same phone and got the same error. Then, I tried using an old iPhone and everything worked fine, so I figure the problem is specific to my iPhone. I looked at my iPhone payment (Settings/Apple ID/Payment & Shipping) and saw that my payment method was declined. I updated my payment methods to try add money to my account (Settings/Apple ID/Media & Purchases/Add Money to Account) but payment was still declined. So, I contacted Apple Support and they fixed something at their end, and was told to wait 24 hours before trying again. That worked! The next day, I was able to add money to my account, so I tried the Pokemon Go shop again. This time, it went through with no issues, and that spinning ball disappeared.