Most credit card companies _don't_ want you to do that because charging more to pay with a credit card makes using your credit card a less enticing idea. IIRC, this stuff is usually handled in your contract with the credit card processor.
The last company that I worked for that used a credit card processor other than Stripe, the rules were something like:
* 2-3% of the transaction is the processor's keep
* You are allowed to charge a surcharge, but _only_ if it's a flat fee. You cannot add a 2-3% fee to cover the credit card charges, nor can you have some sort of "flat-fee schedule" where the flat-fee changes based on the amount being charged (e.g. charges of $1 - $100 get a $0.50 fee, but charges $100+ get a $5 fee). You can only do something like $0.50 fee to all charges.
* You cannot charge a different price for products when they are purchased via credit card.