Php 加入支付网关佣金后,如何计算产品价格?

Php 加入支付网关佣金后,如何计算产品价格?,php,payment-gateway,ccavenue,Php,Payment Gateway,Ccavenue,我们有一件东西要卖,价值大约100美元。对它征收5%的税。第三方支付网关收取网关总金额的3%的佣金(即100+5%的3%)。 由于无法向客户收取3%的支付网关佣金,我们将此额外佣金隐藏在商品价格下。 所以价格应该从100增加到X (100 + 5% tax) + 3% Commission = (X + 5% Tax) ; 请注意,当增加X+5%税的金额时,佣金也会增加 (100 + 5%) + 3% = (100 + 5) + 3.15 = 108.15 如果我们向gateway发送108

我们有一件东西要卖,价值大约100美元。对它征收5%的税。第三方支付网关收取网关总金额的3%的佣金(即100+5%的3%)。 由于无法向客户收取3%的支付网关佣金,我们将此额外佣金隐藏在商品价格下。 所以价格应该从100增加到X

(100 + 5% tax) + 3% Commission = (X + 5% Tax) ;
请注意,当增加X+5%税的金额时,佣金也会增加

(100 + 5%) + 3% = (100 + 5) + 3.15 = 108.15
如果我们向gateway发送108.15,它将收取108.15金额的3.255,这意味着额外收取0.105。即,扣除网关佣金后,我们收到的金额较少(104.895)

我需要隔离的项目价格,这将不会导致额外的费用向公司

$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.

包含支付网关佣金后如何找到产品价格?

不要用“加”的方式思考,用“乘”的方式思考:

将你的价值乘以因子f:

f=1/0.97

100*(1/0.97)*1.05=~108.25(商店价格含税)

108.25*0.03=~3.25(佣金)

->105.00(剩下的就是100+5%的税)

还可以参数化因子f:

f=100/(100-佣金)


请看一下我的答案,如果你想考虑佣金在商店里的价格,请告诉我。您可以这样做,但在我看来,从会计角度来看,这是错误的。

在这种情况下,请使用以下代码:

$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));

简而言之,你需要y=x*0.97的反函数。这是y'=x*(1/0.97)。你在这里说的哪一部分是错的“你可以这么做,但在我看来,从会计角度来看,这是错的。”?
price with tax 105
price with tax and commission 108.15
product price is=>103
product price with commission 108.15