How to Automatically Add Stripe’s Fee Using RSForm!Pro

How to Automatically Add Stripe's Fee Using RSForm!Pro

It’s fairly easy to create a simple payment system using RSForm!Pro in Joomla!.  When you combine it with Stripe as the payment processor, you get a really great way to collect payments on your website.  In this tutorial, I’m going to demonstrate how to automatically add the Stripe payment fee (currently 2.9% + $0.30 per transaction) into the amount that is sent to Stripe and passed on to the consumer.

Sometimes a client wants something that isn’t “out-of-the-box”.  In one instance, setting up a complete e-commerce platform to collect payments would have been overkill, so another optionis RSForm!Pro and Stripe.  However, if they want to pass the Stripe service fee on to the customer (of course letting them know they would be paying it) there’s a bit of a trick.  None of the plugins can do this by default, so a little scripting is in order.

The trick here is you can’t just add 2.9% + $0.30 cents to the total.  Stripe actually works backward!  Their rule is: “We’re going to take 2.9% + $0.30 away from whatever you send us.” If you want $100 from Stripe, the total isn’t $103.20.  

The correct calculation is (100 + .3) / (1-(0.029)) – this adds the $0.30 then adds the 2.9% that will be taken away from the total to give you $100.00.  The total to charge is actually $103.30.

There are now THREE different configuration options for the Stripe Plugin.

The old way of updating the array that’s sent to Stripe DOESN’T work with the new API.

Old Way

In the “Script called on Form Process” box – we USED to enter the following:

$stripe = RSFormProStripe::getInstance();
$stripe->args['amount'] = $amount;

When the payment is sent – this last line replaces the amount with your newly calculated total.

The above script WILL NOT WORK if you’re using one of the new API methods with Stripe.  You can’t actually update the amount field – only some of the comments, etc: (

Better Way

So the code is basically the same, but you have to update the Total field before it’s sent to Stripe. (This works with all three Stripe configurations – so it is the preferred method).

$payment = $_POST['form']['total'];
$total = ($payment + 0.30) / (1 - 0.029);
$total = round($total,2);
$_POST['form']['rsfp_Total'] = $total;

Since you’re updating a field that will get processed before it’s sent to Stripe, you no longer have to multiply by 100 to move the decimal over for Stripe to use it.

The documentation for this field is (at the bottom).

Learn more about RSForm!Pro in our online course!


  • Rod Martin

    Rod holds two masters degrees and has been training people how to do "things" for over 25 years. Originally from Australia, he grew up in Canada and now resides just outside Cincinnati, Ohio. He has worked in both the non-profit and for-profit worlds, in small companies and large corporations. His extensive open source experience includes WordPress, Joomla and Drupal and he really knows how to help you get the most out of the system you chose. Rod plays ice hockey a couple of times a week and rides his Goldwing motorcycle pretty much everywhere he can.

0 0 votes
Article Rating
Notify of

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
2 years ago

Hi Sir,

The above example is really wonderful solution for updating total amount only in the payment page.

Can you please let me know on how to change the currency from USD to INR only in the stripe payment page(not in the form) since USD is a global Currency for the form. When the submitter selected his country as India from the drop-down in the form.

It will really helpful for us. Thank you!

Would love your thoughts, please comment.x