You can use charge class to calculate and build your transaction fee
Register Charges namespace
use Luminova\ExtraUtils\Payment\Charges;
Initialize charge class instance
$charge = new Charge();
Set total transaction amount (Required)
$charge->setAmount($amount);
Set transaction fee or merchant fee (Optional)
$charge->setFee($amount);
Or Set transaction fee by rate 1.7%
(Optional)
$charge->setFeeRate($rate);
Set shipping fee (Optional)
$charge->setShipping($amount);
Build your charges
$builder = $charge->build();
Get charges after building
Get total amount
$totalFloat = $builder->getTotal();
Get total as integer
$totalInt = $builder->toInt();
Convert total to cent integer
$centInt = $builder->toCent();
Convert total to cent float
$centFloat = $builder->toCentAsFloat();
Get Fee
$fee = $builder->getFee();