Questions about Payment Form extension

Payment Processing Fee calculation

  • Jay Larson
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 1 month ago - 2 years 1 month ago #149431 by Jay Larson
Payment Processing Fee calculation was created by Jay Larson
Hello Tuan,

I noticed that Payment Form has not been calculating processing fees that match what Stripe and PayPal are charging us. For example, if I sell an item for $400, the Stripe processing fee is $12.26, but PF shows $11.90. Similarly, the PayPal fee is $14.97, but PF calculates $14.49.

Looking at the formula in the helper.php file:
Code:
$fees['payment_processing_fee'] = round($paymentFeeAmount + $grossAmount * $paymentFeePercent / 100, 2);
Stripe is 2.9% plus $0.30 per transaction. So this formula yields round($0.30 + $400 * 2.9 / 100, 2) = $11.90

If we change the formula to:
Code:
$fees['payment_processing_fee'] = round(($paymentFeeAmount + $grossAmount) / (1-($paymentFeePercent/100)), 2) - $grossAmount;
we have, round(($0.30 + $400) / (1 - (2.9 / 100) 0,2) - $400 = round($412.2554, 2) - $400 = $12.26

Using the second formula calculates correctly for PayPal as well.

Best Regards,
Jay

 
Last edit: 2 years 1 month ago by Jay Larson. Reason: formatting

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #149437 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Payment Processing Fee calculation
Thanks Jay. For now, please keep the change yourself. I don't want to change the formula now because it could cause unexpected behavior for sites which are using it

I will see if I can make it configurable in next release

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Jay Larson
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 1 month ago - 2 years 1 month ago #149494 by Jay Larson
Replied by Jay Larson on topic Payment Processing Fee calculation
 No worries, Tuan! I just wanted you to be aware that the current formula is incorrect.

Here is the math explanation for the correct formula..

Reverse Fee Calculation:
Let x be the price we charge to receive a specific payout y. For Stripe, there is a transaction processing fee of 2.9%, that is, 0.029x. There is an additional charge of $0.30 per transaction. We end up with the formula x − 0.029x − 0.30 = y.

In the above example, we want the payout from Stripe to be x − 0.029x − 0.30 = 400. Simplify to x − 0.029x = 400.30, then to 0.971x = 400.30. We find that x = 400.30 / 0.971 = $412.2554. Rounded to two decimals = total payment of $412.26.

In other words, (payout + transaction fee) / (1 – percentage fee).

Stripe calculates $412.26 * 2.9% = $11.96 + $0.30 transaction fee = $12.26. You get a payout of $400, and Bob’s your uncle! 

Similarly, for PayPal, with 3.49% processing fee and $0.49 per transaction: x − 0.0349x − 0.49 = 400. Simplify to x − 0.0349x = 400.49, then to 0.9651x = 400.49. We find that x = 400.49 / 0.9651 = $414.97254, rounding to total payment of $414.97.

PayPal calculates $414.97 * 3.49% = $14.482453 + $0.49 transaction fee = $14.972453. Round to $14.97. You get a payout of $400.

The formula works for any combination of processing fee % and per transaction fee.
Screen grab from my Stripe account:



Regards,
Jay 
Last edit: 2 years 1 month ago by Jay Larson.

Please Log in or Create an account to join the conversation.

  • Jay Larson
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 1 month ago - 2 years 1 month ago #149949 by Jay Larson
Replied by Jay Larson on topic Payment Processing Fee calculation
Hi Tuan,

You mentioned in the other thread that "there was nothing to fix here" regarding processing fees. I have shown you specific examples, and even a screen shot from my Stripe account, so I hope you will reconsider.

Sale of a $400 item: Payment Form calculates a Stripe processing fee of $11.90 for a total of $411.90. When Stripe processes the $411.90 transaction, they charge 2.9%, which equals $11.95, plus $0,30 for a total fee of $12.25, not $11.90. This is because they also charge 2.9% on what PF is calculating as the fee.

The corrected formula is:
Code:
$fees['payment_processing_fee'] = round(($paymentFeeAmount + $grossAmount) / (1-($paymentFeePercent/100)), 2) - $grossAmount;

The difference here is to start with the desired payout amount ($400, for example) and then work backward to the total charge that will yield that amount.

Thanks,
Jay
Last edit: 2 years 1 month ago by Jay Larson. Reason: typo

Please Log in or Create an account to join the conversation.

  • Jay Larson
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 10 months ago #151540 by Jay Larson
Replied by Jay Larson on topic Payment Processing Fee calculation
PF v6.6.0 still uses the incorrect formula. Our bookkeeper is tired of having to make adjusting entries for each payment in order to reconcile to our Stripe and PayPal balances.

Can we just get a refund please? We bought Payment Form ($29.99) and two payment plug-ins ($24.99 each).

Thanks,
Jay

Please Log in or Create an account to join the conversation.

More
1 year 10 months ago #151542 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Payment Processing Fee calculation
Hello Jay

Sorry but I cannot refund because of this reason. The fee formula has been working like that for years. It might not work as you want, but other customers have been using it, so we could not change. What I will do is provider you an override which will work as you want and safe for updating.

I will work on it and send it to you during this weekend.

Tuan

Please Log in or Create an account to join the conversation.

  • Jay Larson
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 10 months ago - 1 year 10 months ago #151555 by Jay Larson
Replied by Jay Larson on topic Payment Processing Fee calculation
I understand it has been wrong for many years but that is a poor reason for not fixing it. It's working incorrectly for me and all other customers, whether they realize it or not.

Just today, we had a sale for $1425.00.
Payment Form calculated the processing fee to be $41.33 and sent the charge to Stripe for $1466.33.
Stripe actually charged us $42.82 so we get a net of $1423.51.

Do you see that $1425.00 is not the same number as $1423.51? 

Here is a screenshot from our Stripe account.
Last edit: 1 year 10 months ago by Jay Larson.

Please Log in or Create an account to join the conversation.

More
1 year 10 months ago #151571 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Payment Processing Fee calculation
The point is it has been working like that for years (not only Payment Form but my other extensions), so suddenly change how it works could cause un-expected behavior (Yes, I realized few other customers complained about this - from my other extensions, but most others use it as how it is)

So the only way here is implement an override or make it configurable. I will work on it and update you during the weekend

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc