Yes! To create a predefined surcharge for Credit Card payment types, start by creating an inventory item (which you could call “Credit Card Surcharge”). Click on Discount-Percent, and then in the Percent Discount field, enter the surcharge percentage amount as a negative number.
To apply the surcharge to an invoice, add the Credit Card Surcharge as a line item.
Then, go ahead and accept payment as usual, via the Payment Form.
Please note that some Payment methods, such as PayPal do not allow surcharges per their usage terms. Please check with your payment provider before adding a surcharge.