If you want to implement convenience fee handling in your payment gateway or system, you need to answer some fundamental questions. First you need to define, whether it will be implemented within your system or within some third-party system. Second, you need to decide, whether convenience fee will represent a part of the original transaction, or it will be processed as a separate one (under a separate MID).
If you want both primary payment and convenience fee to be processed as a single transaction, you need to keep in mind that charging of convenience fees is permitted only under certain merchant category codes. If funding of your merchants is handled by some third party, the third-party system is going to handle convenience fees as well.
In the second case you need you have to address several important questions of the following types. Will convenience fees be charged for declined transactions? Will they be charged if the transaction itself is refunded back to the client’s account, or voided? How should you act if the funds on the account are not sufficient for the primary payment, or for convenience fee?
The particular amount of convenience fees is another important aspect of the matter. A convenience fee should be based on the actual cost of transaction processing. It can represent either a fixed amount, or a percentage of the original transaction. Technically you can use unified or blended rate principle, some type tiered pricing, or develop your own mechanism to calculate convenience fee amounts.
More information on handling of convenience fees in payment systems and payment gateways can be found in the respective article on Paylosophy.