This is actually against the law. They MUST accept your credit card. If they tell you they won't accept the card, you can report them by calling the city number that is plastered all over the cab. And if the credit card machine is broken, as they may try to claim, the cab must be out of service.
Here's how I deal with it. I tell them I am paying with a credit card and plan to give them a good tip. If they complain about the credit card (and at least half of them do), I reduce or eliminate the tip. And I call the customer service number.