问题
We have an item to sell worth around $100. There is a 5% tax applicable to it. A third party payment gateway takes a commission of 3% of total amount given to gateway (ie., 3% of 100+5%). Since its not possible to charge 3% payment gateway commission customer, we hide this extra commission under item price. So the price should be increased from 100 to an "X" amount.
(100 + 5% tax) + 3% Commission = (X + 5% Tax) ;
Please note when increase amount from X + 5% Tax, the commission also increases.
(100 + 5%) + 3% = (100 + 5) + 3.15 = 108.15
If we sent 108.15 to gateway, it charge 3.255 on the amount 108.15, which means 0.105 additional. ie. We received a lesser amount after deducting gateway commission (104.895).
I need to isolate the item price which will not result in an additional charge to company.
$tax = 5 ; //5%
$itemAmount = 100 ;
$priceWithTax = $itemAmount + ($itemAmount * 5/100) ;
$commission = 3 ; //3%
//We sent 105 to gateway.. which results 105 to customer and 3.15 to company.
$priceWithTaxCommission = $priceWithTax /* or X */ + ($priceWithTax * $commission/100) ;
$ToGateway = $priceWithTax + ($priceWithTax* 3/100) ;
//Results 108.15, If we sent 108.15 to gateway it again charge 3% on 108.15. Which is wrong.
How to find product price after including payment gateway commission ?
回答1:
Don't think in the term of "add", think in the term of "multiply":
Multiply your worth with factor f:
f = 1/0.97
100 * (1/0.97) * 1.05 = ~108.25 (shop-price including taxes)
108.25 * 0.03 = ~3.25 (commision)
-> 105.00 (what's left and that is 100 + 5% taxes).
You can also parameterize factor f:
f = 100 / (100 - commision)
Please have a look at my answer and let me know if you want to consider the taxes of the commision-part in your shop-price. You can do this but in my opinion this would be wrong from a accountance-view.
回答2:
In this case use from this code:
$mainPrice = 100;
$tax = 5;
$commission = 3;
$priceWithTax = $mainPrice + ($mainPrice * ($tax / 100));
echo $priceWithTax.'<hr/>';
$priceWithTaxCommission = $priceWithTax + ($priceWithTax * ($commission / 100));
echo $priceWithTaxCommission.'<hr>';
$x = $priceWithTaxCommission / (1+($tax / 100));
echo 'product price is=>'.$x.'<hr/>';
echo $x + ($x * ($tax / 100));
this code return as following:
price with tax 105
price with tax and commission 108.15
product price is=>103
product price with commission 108.15
来源:https://stackoverflow.com/questions/47010418/how-to-calculate-product-price-after-adding-payment-gateway-commission-to-it