Member-only story

Calculate and pass on Stripe fees in your PHP application

You can’t just calculate the fee based on the charge amount and add them together. Your fee component will need to consider the fee for itself.

Rod Staines
2 min readMar 6, 2022
Photo by Jeremy Bishop on Unsplash

As per the Stripe documentation, it’s important to understand the legalities of passing on fees to your customers before building it into your application.

I created a Laravel billing application that utilised Stripe to process payments. Some clients paid using Direct Debit and others by Credit Card.

We wanted to pass the fee on to customers, so in order to make sure we weren’t shortchanging ourselves, the calculated fee had to include the fee for itself.

If you calculate the fee on your charge amount, add the fee and then process payment, the resulting fee Stripe adds will not match what you calculated. That’s because the fee component you calculated also attracts a fee from Stripe.

The following formula is provided by Stripe to account for this situation.

Formula provided in Stripe Documentation

Translating the formula to PHP to calculate…

--

--

No responses yet