Created
September 19, 2025 04:35
-
-
Save aimahdi/4b9a69eae4c1003f360dd50b000e00ab to your computer and use it in GitHub Desktop.
Paddle payment tax calculator when tax is included with the price
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function calculateAmount($subtotal, $discount){ | |
$finalSubtotal = round(($subtotal /1.15), 2); | |
echo "Subtotal: {$finalSubtotal}\n"; | |
$finalDiscount = round(($discount / 1.15), 2); | |
echo "Discount: {$finalDiscount}\n"; | |
$payableAmount = $finalSubtotal - $finalDiscount; | |
echo "Price: {$payableAmount}\n"; | |
$tax = round(($payableAmount *0.15), 2); | |
echo "Tax: ${tax}\n"; | |
$totalPayable = $payableAmount + $tax; | |
echo "Total Payable: {$totalPayable}\n"; | |
} | |
calculateAmount(5, 0); | |
echo "------------------------------\n"; | |
calculateAmount(25.80, 12.90) | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment