I am integrating Payment Gateway with my PHP application. I am facing an issue during solving some basic small equation via JavaScript or PHP. actually my payment gateway takes some percentages from principal amount as they have own rules.
I want the amount being deducted and add it during payment initiates when user makes payment. For more clarity, below is my example - Suppose user purchases an item for amount $100 at the payment gateway, their payment will be calculated with the formula below:-
var amount = '10352';
var percent = amount * '2.5' / '100';
var charge = percent + parseFloat('5');
var TAX = charge * '18' / '100';
var totalcharge = charge + TAX;
var okAmount = parseFloat(amount) + parseFloat(totalcharge);
//output result is *10663.28* which is correct.
but when I trying to do subtraction, Its not showing the correct answer in PHP.
$amount ="10663.28";
$percent = $amount * '2.5' / '100';
$charge = $percent + '5';
$GST = $charge * '18' / '100';
$totalcharge = $charge + $GST;
$totalAmount = $amount - $totalcharge;
but the answer is not == 10352 even I try my best to apply at the same formula.
Please let me know what the issue is and what i might be doing wrong. What i want to know is How I make 10663.28
to 10352
again in PHP.
Thank you so much. Note: This is not my question and it already applied by me