The short answer is ... that depends.
When you say you "realize you have no way to pay", do you mean that you forgot to bring your credit card? Or that you don't have enough money to your name?
And what kind of service?
If it's a matter of, "Oops, I didn't bring enough cash" or "I forgot my credit card", and the service is to produce, modify, or repair some object that you would like to take home, it's usually not a big deal. You say, "Oops, I made a mistake. I've got to run home and get the money." And you leave the product there while you go home and get payment. Then you return, give them the money, pick up the product, and everyone is happy.
If it's the sort of service that by the time they ask for payment, there's no way that you could leave it behind, like a meal at a restaurant, or a haircut, then things are more complicated. If it's a small business and you've done business with them before and are on good terms, you could explain your mistake and say you'll run home to get payment. If they're willing to trust you, no problem.
Auto mechanics and repair places where you leave the item to be repaired at their shop have what's called a "mechanic's lien": they don't have to give you your item back until you pay them. If you take your car for a $40 oil change and then tell them you don't have the money, fine. They keep your car until you come up with the $40. Odds are your car is worth more than $40 (well, I've had cars that weren't ...), so they can be pretty confidant you'll come back.
Once my wife and I ate at a restaurant and I expected to pay with a credit card, but when the time came to pay they said that they only accepted cash. This is pretty unusual these days so I didn't think to ask. But as my wife and I were both there, I said, How about I run out to an ATM and get some cash and my wife will stay here so you know we're not skipping out on you? It was annoying, probably for them as well as me, but not unsolvable.
I've had a couple of times at doctor's office where they've wanted payment and I hadn't brought any money, and they accepted "send me a bill".
Sometimes businesses will ask you to leave your driver's license behind while you get the money. They figure you need your drivers license, replacing the drivers license is probably more trouble than paying, and if you try to skip out anyway, they at least have your name and address.
I've read in older books of people decades ago being asked to leave their coat or something of value like that. I don't know if that's done any more. Maybe it's not even legal.
Beyond that ... Think about it from the store's point of view. What are their choices? They can yell and scream at you, but of itself that's not going to solve anything. If, as I mentioned at the beginning, if they can prevent you from taking the product or service with you when you leave, then they can just hold on to it until you come back with payment. If you were trying to pull a scam, you won't profit from it. Maybe you can make them waste time fixing your toaster or baking your cake or whatever and then never get paid for your time, if your goal is just to harass the business owner, but you can't profit from it. Otherwise, well, they can't keep you a prisoner in the store forever. So really all they can do is hope that you'll pay them, or that they can sue you and get their money.