If you weren't even driving and this happened in the store, the only possible rationale by the cop is drunk and disorderly. Is that what you cited you for? I don't think they do field sobriety tests for people that they're trying to ding for D&D (or do they?).
If so, ask the gas station for their surveillance video footage which most every gas station has. You could use this to file a complaint with the local PD.
FST’s assess physical impairment to accrue evidence for DWI/DUI. The officer may have simply been an asshole, but is there a scenario where this makes sense? Maybe. If you’re a TLDR person, stop reading now.
He sees you drive up and maybe there was something erratic in the way you pulled in. Or maybe, and this is more likely, there was a BOLO for a car similar to yours that went out saying it was driving erratically and the caller was sure the driver was a drunken danger to society. So you pull up and the officer smells some alcohol from the trash or who knows where. It’s supposed to be the odor of “metabolized alcohol” but can most people really tell the difference?
Anyways, officer starts a consensual encounter because he doesn’t have any reasonable suspicion for a detainment other than descriptions. At some point, you consent to FSTs. Those are meant for you to fail and I think half the sober people in the world would fail those at times. Maybe you’re even on a medication that causes problems here. You don’t do them perfectly, he has RS for the detainment, and he thinks he might have PC to make an arrest but he wants to make sure so you blow. Now this is contradictory. But he’s thinking you’re doing something wrong and maybe he can get you to incriminate yourself so he takes some more time and continues the interaction. In the end, he finds nothing and lets you go. You’re pissed but it’s possible they missed a guy (not you), driving a car just like yours, who ended up drunkenly slamming into a mom and her van load of kids. It happens.
As for your case, the consensual encounter can last as long as you both are in the conversation or you end the encounter by walking away. Once he detains you, i.e. takes your license or puts you in cuffs or tells you he’s detaining you, it becomes a Terry Stop. Then there are guidelines tracing back to the Supreme Court for handling these and they are supposed to be as quick as possible to discern whether PC exists for a citation or arrest. 45 minutes is a long time but I’m guessing a lot of that was consensual and some of that may have been a skewed assessment of time in a pressure situation.
FYI, on a traffic stop, officers can end the Terry stop by giving you the license but continue a consensual encounter. Such as executing a traffic stop for something, finishing the stop, handing you back your license, and then asking if they can search your car. You can say no and they can do nothing about it. But most don’t. So, why ask you after they return your license? They can only search the car while you are detained if they have reasonable suspicion that there is something illegal in the vehicle. If not, they can’t search. But once it is a consensual interaction and you’re free to go, then asking to search is fair game. If you submit to the search, that’s on you.
Bottom line is that officers have to jump through many hoops based on existing precedence that make the general public very angry but make sense once you know why they’re doing it.