Calculate Credit Card Transaction Fee Using Gravity Forms

, , ,

On several occasions I have been commissioned to create an online payment form which also collects additional compensation to cover various administrative fees, such as Credit Card transaction fees. In this article I will cover how to calculate credit card transaction fees using the Gravity Forms WordPress plugin. This will allow you to collect the full original invoiced amount, making book keeping easier on you and your accountant.


Payment gateways, such as Stripe, process payments for about 2.9% of the total plus a .30 cent per transaction fee. The following form setup will allow you to collect an administrative fee to cover the credit card processing fee.

Note: As of this writing I believe it is illegal to charge a fee for credit card payments in these States: Colorado, Connecticut, Kansas, Maine, and Massachusetts. This list may change at any time and it is your responsibility to check your local laws. Another interesting fact, in the State of Maine, government entities may impose credit card surcharges. But not your business!


Gravity Forms Payment Gateway Plugins

This article assumes that you will be using the Stripe for Gravity Forms Add-on Plugin to securely collect and process online payments through your WordPress website. However, the instructions herein should also work well for the Authorize.Net, Square, mollie, 2Checkout and Paypal Gravity Forms Add-on Plugins. Showing you how to install, configure and connect the Stripe for Gravity Forms Add On Plugin, or any other online payment gateway and plugin, is a topic for another article.


Credit Card Transaction Calculation Form

For the sake of brevity, I will assume you already have an online payment form setup with a main Product field inserted.

With that in place, you will want to add another Product field under the Pricing Fields section.


Gravity Forms Pricing Fields Product Field


Click on this newly added Product field (in preview area on left) to configure the field options (in the sidebar area to the right).

Under the General section change the Field Type to Calculation and checkmark the Disable quantity field checkbox. Below that checkbox should be a new Formula option, dropdown and text area. Click on the “Insert Merge Tag” drop box and select your previous Product field which will populate the Formula text area box with the proper merge tag.

In my case, my Product field merge tag was {Invoice Total:14} where Invoice Total is the name of the Product field and 14 is the ID of the Product field. Hopefully it is obvious that the Product field name and ID will be different for your form.


Gravity Forms Product Field Calculation Formula Options


The magic happens within the Formula text area box. In order to collect the full original invoiced amount, the following formula needs to be used:

({Invoice Total:14} + .3) / (1 – .029)

That should cover it. Now, if someone makes an online payment for $100, the payee will be charged $103.30. That is 2.9% multiplied by $103.30 plus $.30 is $3.30. Subtract $3.30 from $103.30 and you’re left with the original invoiced amount of $100.

You will want to structure your online payment form and credit card transaction fee calculation to be as clear, upfront and user friendly as possible. This article simply demonstrated a quick break down of the needed calculation in order to collect the full invoiced amount from your online payment form.

Consider using the Conditional Logic field option to enhance your online payment form or make the credit card transaction fee optional using a simple checkbox.



I welcome your thoughts, questions or suggestions on my article on how to calculate and collect the credit card transaction fee using Gravity Forms.

You may support my work by sending me a tip using your Brave browser or by sending me a one time donation using your credit card.

Let me know if you found any errors within my article or if I may further assist you by answering any additional questions you may have.