Skip to content

Instantly share code, notes, and snippets.

@aimahdi
Created September 19, 2025 04:35
Show Gist options
  • Save aimahdi/4b9a69eae4c1003f360dd50b000e00ab to your computer and use it in GitHub Desktop.
Save aimahdi/4b9a69eae4c1003f360dd50b000e00ab to your computer and use it in GitHub Desktop.
Paddle payment tax calculator when tax is included with the price
<?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