Posting Payment to Invoices & Merchant Bank Fees

I need help on posting payments to invoices in AR module AND accounting for merchant fees, so my deposits match what cleared the bank. Example: a customer has a $500 invoice. They pay $500 on credit card. Processing fee is $17.65. Total deposited is $482.35.

I need to apply the $500 to the invoice AND record the $17.65 to merchant fees expense account. When doing this through the AR system in Financial Edge I cannot figure out how to get the $17.65 recorded to the merchant fees expense account.

I do this through cash receipts deposits daily. But in this situation I need to apply it to an invoice through AR and I'm stuck. Any advice is greatly appreciated!