JSFiddle - React, Tailwind, and code Playground
PayPal Fee Calculations for clientResponse
by Jennifer Perrin
HTML
<form>
Fee %: <input class="" type="" name="payFee" id="payFee" value="1.9" /><br />
Client Amount: <input type="text" name="priceSet" id="priceSet" size="30" value="" /><br />
<input class="" type="hidden" name="amount" value="" />
View Total: <input type="text" name="pricePlusFee" id="pricePlusFee" readonly="readonly" size="30" value="" />
</form>
JavaScript
$(document).ready(function() {
$("#priceSet").on('change', function() {
var priceInp = $("#priceSet").val();
var priceFee = $("#payFee").val();
var fee = Math.round(((priceInp / 100) * priceFee)*100)/100;
var sum = Number(priceInp) + Number(fee);
$("#pricePlusFee").val(sum);
$("[name=amount]").val(sum);
});
});