How to Pass Payment Transaction Fees to the Customer

This article was originally posted on June 13, 2016.

(Disclaimer: Any links with an * is an affiliate link. Although prices are the same, Mr. Technique, Inc. earns a commission on any purchases made using the link. Read more in our privacy policy)

Gravity Forms - Passing Paypal/Stripe Transaction Fees Back to the Customer

Stripe and PayPal they take their fees off the top when processing payments. In the US, these are fees for Stripe and PayPal in the US:

  • Stripe Processing Fee: 2.9% + $.30 per transaction
  • PayPal Processing Fee: 3.49% + $.49 per transaction

That’s only $3.20 (using Stripe) or $3.98 (using PayPal) off of a $100 transaction, but what if you process payments of $7500 or more? The processing fees would then be over $200. I don’t mind the fees, but some of our clients do. A client once asked me to make their online payment form pass their PayPal fee back to the customer to pay. I used Gravity Forms* on this client’s website because it’s one of my preferred WordPress form plugins.

I’m assuming that you have the Stripe or PayPal Gravity Form Add-On activated and configured to process payments. Showing you how to set up these payment processors with Gravity Forms is a topic for another blog post. You should know how to add pricing fields as well.

Let’s get started. First, add a Number field from the Standard Fields section. Name it something like Payment Amount and make it required. Set the Number Format to Currency. Your settings for this field should look like this:

Setting the number format to currency allows its value to be used as a merge tag. Next, add a Product field. Name it something like Total Payment (with transaction fees). Check the Disable quantity field and select Calculation for the Field Type.

Once you select Calculation, you’ll see a formula field pop up. Select the number field that you created as your merge tag. In this blog post, Payment Amount is the name of the number field.

Here’s where the magic happens. If Stripe is the payment processor, you can’t use {Payment Amount:5} * .029 + .3 to account for the transaction fees because all of the transaction fees still won’t be passed to the customer. If someone makes a $100 payment on your website, and you have the formula set to the above, the customer will be charged $103.20 ($100 + $2.90 + $.30) if Stripe is processing the payment. Stripe will take their fees off of $103.20 (not $100). 2.9% multiplied by $103.20 plus $.30 is $3.29. Subtract $3.29 from $103.20, and you are left with $99.91 which is still less than $100 (the original amount). In this form’s case, to account for the transaction fees, this formula needs to be used:

({Payment Amount:17} + .3) / (1 – .029)

The 17 right next to Payment Amount is the form ID, so that number will be different for you. Now if someone makes a payment for $100 on your website, the customer will be charged $103.30. 2.9% multiplied by $103.30 plus $.30 is $3.30. Subtract $3.30 from $103.30, and you’re left with $100.

PayPal’s fees are now different from Stripe’s fees. If you’re in the US, this is the formula that needs to be used:

({Payment Amount:5} + .49) / (1 – .0349)

Make Adding the Transaction Fees Optional

In the comments section, someone asked me if this was possible. She had found the answer in Joe Winter’s Gravity Forms blog post before I had a chance to answer, but I’m posting an answer of my own anyway. To make the transaction fee optional, you would add a checkbox field like the one below:

Next, add a Number field from the Standard Fields section. Name it something like Payment Amount and make it required. Set the Number Format to Currency. Your settings for this field should look like this:

Setting the number format to currency allows its value to be used as a merge tag.

Next, you’ll create two product fields to show the total amount that the visitor will pay. Name them both something like Total Payment. Check the Disable quantity field and select Calculation for the Field Type on both of the product fields. For the Total Payment product field that doesn’t include payment transaction fees, you would just select the merge tag for the Payment Amount number field. For the Total Payment product field that includes payment transaction fees, you would use the formula that I specified above for whatever payment processor you are using. If you’re using Stripe, the field settings would look like the following (your field id would be different):

Without Transaction Fees

With Transaction Fees

Enable Conditional Logic on both of the product fields. Select the transaction fee question with the checkbox that you had just created. For the product field that will only show the payment amount, select the Empty (no choices selected) option. For the product that will show the payment amount with the transaction fees, select the Yes, I would like to cover the payment transaction fees option. Your conditional logic settings for both product fields should look like the following:

Without Transaction Fees

With Transaction Fees

Update your form and go to Gravity Forms’ Settings -> Stripe (or PayPal) and create a feed. Under Products & Services Settings -> Payment Amount, select Form Total.

Gravity Forms Paypal Feeds

See it in Action

Here’s a dummy form that I created which adds the amount needed to cover the Stripe processing fees.

Here’s a dummy form that I created (with product quantity fields) which adds the amount needed to cover the Stripe processing fees.

And here is the formula that I used:

({Running Shoes (Price):18.2}{Running Shoes (Quantity):18.3}+{Shirt (Price):19.2}{Shirt (Quantity):19.3}+ .3) / (1 – .029)

If you found this blog post useful or if you have any questions, please comment below.

39 Comments

  1. Caitlyn on January 23, 2017 at 9:46 am

    Is there a way to make adding the fee optional?



  2. Caitlyn on January 23, 2017 at 10:02 am


  3. Jarrod Skeggs on March 2, 2017 at 9:43 am

    A quick tip on this… I recommend using a Single Line Text Field for the “Invoice Amount” or “Payment Amount” instead of a product field. The reason is that Gravity Forms will calculate the total of all product fields and pass that on to Stripe or Paypal. So if a customer enters $50.00 in the Payment Amount field and then the amount with processing fees shows $51.80, then the customer will be charged $101.80. Using the Single Line Text field type will still enable customer to enter amount of payment and also allows the “Calculation” field to do it’s job. Thusly, customer is only charged the amount in the “Amount (with processing fees)” field.



  4. Tom Nguyen on March 6, 2017 at 12:49 pm

    Thanks for addressing that, Caitlyn. I’ll update this blog post to show how to make the fees optional.



  5. Tom Nguyen on March 6, 2017 at 1:02 pm

    Jarrod, thanks for commenting. On this form, the customer is only charged the $51.80 in Paypal if they if they enter $50.00 in the Amount product field. I had set up Paypal (on test mode) with this dummy form, so visitors can see.



  6. Lew Harrison on May 4, 2017 at 3:56 pm

    I also tried this in a test mode and I have the problem of when I submit offering to pay the transaction fee, it doubles when it goes into paypal. I also tried Jarrod’s suggestion and it only seemed to add in only the paypal cost, not the donation plus paypal cost. Any suggestions?



  7. Tom Nguyen on May 13, 2017 at 3:08 am

    Thanks for commenting, Lew. I would need to see your form to figure out the problem. Next week, I’ll offer the sample form as a download, so you can see the settings on your own site.



  8. Er on July 13, 2017 at 7:18 pm

    Great tutorial.

    I have a question, my client use Stripe + Gravity, figuring out calculation isn’t hard, but if Stripe been given amount+ fee wouldn’t it take it’s precentage from total?

    so $30 cost sent to stripe will cost $30 + 2.6% If I add 2.6% in the form
    making it $30.52 and pass it on to Stripe wouldn’t Stripe charge $30.52 + 2.6% or am I missing something

    Thanks in a dvance



  9. Er on July 13, 2017 at 8:33 pm

    Please ignore my previous comment



  10. Tom Nguyen on July 17, 2017 at 2:03 pm

    No problem, Er. Were you able to get it figured out?



  11. Mel on July 23, 2017 at 4:24 am

    Hi, thanks for the tutorial, it has been very helpful!

    I have a problem in that I wish to display the total field, however, it displays the calculation total regardless of whether the user has opted to pay the transaction fee. Is there a way around this?



  12. Tom Nguyen on July 25, 2017 at 4:59 pm

    Mel, thanks for reading my blog post, and I’m glad that it has helped. I’m not sure if I’m understanding you. You don’t want to display the calculation total if the user chooses not to cover the transaction fee? On my sample form above, a field showing the total amount doesn’t show if the user doesn’t check the cover fees box.



  13. Mel on July 29, 2017 at 2:43 am

    Hi, thanks for getting back to me. It seems to have fixed itself. I’m not sure why. There may have been some conflict elsewhere…



  14. Mark Hannon on September 2, 2017 at 5:53 pm

    For anyone who finds the formula above isn’t validating, replace the minus sign “-” with a standard hyphen. The example above uses an em dash and the validator didn’t recognize it as an operator.



  15. Tom Nguyen on September 4, 2017 at 8:57 am

    Thanks for chiming in, Mark. I looked at my source code and it actually is a standard hyphen.



  16. Mark Hannon on September 4, 2017 at 9:50 am

    Interesting, for some reason the minus sign converted to an em dash when I pasted the formula in. It may not happen to everyone but if someone else can’t get the formula to validate, it’s an easy fix and this might save them some frustration.



  17. […] to build the registration process in Gravity Forms and use Stripe for the payment processing. With a little trick we learned from Mr. Technique, we added an optional checkbox that allows attendees to “cover” the credit card […]



  18. Cam Cecchini on November 30, 2018 at 3:53 pm

    Thanks for the tutorial! Quick question, would this work using the Gravity Forms extension for WooCommerce? I’m selling blanket kits for my NPO and would like to implement this for the transaction fees associated with purchases (donations). Thanks in advance!



  19. Tom Nguyen on December 3, 2018 at 2:22 pm

    Cam,

    I’ve never used the Gravity Forms extension for WooCommerce. I contacted Gravity Forms support about it, and they told they are not familiar enough with the extension to give an answer. They recommended that you contact WooCommerce about it.



  20. Josh Harwell on January 21, 2019 at 3:48 pm

    Thanks for this insightful tutorial! Is there a way to make the form display the formula for different products totaled together.

    So If I’m ordering 2 adult meals at $5 a piece, plus 2 kid’s meals at $4 a piece it will take the total calculation of that and then add the payment processing to the whole total and not just the individual items?



  21. Tom Nguyen on January 29, 2019 at 8:31 pm

    I’m not sure if I understand you, Josh. The fee is added to the total amount. If there were multiple items selected for purchase, I believe you could use the Total field to add up the prices of items selected for purchase. Then, you could add the transaction fee to the total.



  22. Lori Newman on January 30, 2019 at 10:35 am

    Great tutorial Tom, bookmarking this post for sure 🙂



  23. Tom Nguyen on January 30, 2019 at 8:20 pm

    Glad you found it helpful, Lori!



  24. PTA on February 5, 2019 at 12:17 am

    Great article – my question is that the “Total” pricing field cannot be used in calculations. I basically want the customer to select multiple items that should all be summed up to a “Total” but then if they select that they want to pay with Credit Card, I’d like to add the PayPal fee. If you try to use the Total field in the calculation it ends up creating a circular reference because the Total field automatically sums up all the Product Fields on a page (and in your example the Amount w/fee) is a Product Field. Just wondering if there are any other options.



  25. Tom on April 28, 2019 at 3:14 pm

    I have the same question (or similar) to PTA above.
    I want to add the 2.9% fee to the paypal option, but not for my “Bill me” and “Pay by check” options.
    This for a B2B transaction, so we are only passing on the fee to another business.



  26. Laritza on May 22, 2019 at 5:48 am

    How can I use the Total field? Payment Amount does not work for me, it only calculates half of the fee. Gravity forms says Payment Amount:# field does not exist.
    Thanks!



  27. Anthony on January 16, 2022 at 10:57 pm

    This doesn’t seem to work with the latest version of Gravity Forms (ver 2.5.15). Is there an updated version of this calculation please?

    Even when I click on “validate formula” for the calculation field it says “There appears to be a problem with the formula.” It just returns a zero amount on the front end.



  28. Tom Nguyen on January 17, 2022 at 1:54 pm

    Anthony, we actually have a newer version of Gravity Forms newer than yours (2.15.16). The sample form in my blog post still works. Here’s a screenshot of a successful calculation validation of the dummy form on my blog post. Successful Gravity Forms Calculation Validation



  29. Amanda on January 27, 2022 at 8:46 pm

    Hi. Does it work when you have fields with quantities. My form is here:
    https://windingstairfarm.com/the-farm/tour/
    I thought I’d be able to take the merged field for the first product and apply the formula. Put that all in brackets. Then a PLUS sign. Then take the merge field for the second field and apply the formula. I’ve looked at my formulas to see if I have any syntax errors, and I’m not seeing what I could be doing wrong, unless it just won’t work with this kind of form.

    Thanks in Advance!



  30. Tom Nguyen on February 3, 2022 at 5:18 pm

    Amanda, it does work with quantities. I created a dummy form and tested. I had this for the merge fields for 2 products with quantity fields:

    ({Running Shoes (Price):18.2}*{Running Shoes (Quantity):18.3}+{Shirt (Price):19.2}*{Shirt (Quantity):19.3}+ .3) / (1 – .029)

    I’ll update this blog post shortly with a 2nd dummy form and explanation.



  31. Kiley Hernandez on March 17, 2022 at 11:35 am

    When I use this formula, the amount listed on the entries for that record and what Stipe says the service fees do not match. As you can imagine – accounting is throwing a fit. Maybe there is a simpler way to do this? This is what my goal is. We are receiving donations. We are NOT asking the donatee to cover the cost of the transaction fees however, accounting wants the cost of the transaction listed on the record. Our first donation was for 200.00. The service fee with your formula shows 6.28 as the fee on the entry. The record on Stripe is 6.10 for a discrepancy of 18 cents. What on earth am I doing wrong? HA!



  32. Tom Nguyen on May 9, 2022 at 6:08 pm

    Kiley, I’m not sure what’s wrong. $200 + $6.28 = $206.28. Since you’re using Stripe, that should be the correct amount since 206.28 * .029 + .30 = $6.28.



  33. Sha66y on May 10, 2022 at 2:38 pm

    Thank you for this!
    For PayPal I needed to subtract the amount as well…
    ({Amount:1} + .49) / (1 – .0349) – {Amount:1}

    For a $10 donation I was expecting $10.84, but the result is $10.87Even the formula was adding the $0.49 fee and then calculating the percentage it should be $10.856101 – any ideas?



  34. BG on July 5, 2022 at 6:23 pm

    No matter what I try the receipt generated from stripe will show the product as well as the total so it looks like the customer is being charged twice, when in reality they are being charged once. Any ideas on how to stop this? Beside creating a full custom receipt?



  35. BG on July 5, 2022 at 6:24 pm

    Sorry the receipt generated from Gravity Forms. Not Stripe. Stripe works find with this formula.



  36. Tom Nguyen on July 25, 2022 at 4:43 pm

    BG, I’ve updated the blog post a good bit. Read through it again. You have to use a standard number field instead of a product field with a user-defined price, so that the user-defined amount doesn’t get added in the total.



  37. Tom Nguyen on July 25, 2022 at 5:02 pm

    Sha66y, $10.87 is correct. 10.87 * .0349 + .49 = .87



  38. Tom on September 19, 2022 at 2:13 am

    Hi Tom,

    I wondered how you handle the two types of Stripe fees? For us in AU and I think elsewhere Stripe has the below:

    1.75% + A$0.30 for Domestic cards
    2.9% + A$0.30 for International cards

    I can see from your calcs. above it looks like you only do one calculation?

    I also posted on Gravity Ranger but this post seemed to be more active. Any help would be greatly appreciated!



  39. Tom Nguyen on September 19, 2022 at 9:56 pm

    Tom, I’ve never had to handle 2 types of Stripe fees before, but you could create a conditional product field for each rate.



Leave a Comment





This site uses Akismet to reduce spam. Learn how your comment data is processed.