twomice / com.joineryhq.percentagepricesetfield

Other
5 stars 11 forks source link

Percentage plus fixed amount #14

Open dsuguy2007 opened 7 years ago

dsuguy2007 commented 7 years ago

How would you set it up to charge the fee like Stripe does which is 2.9% plus 30 cents per transaction?

twomice commented 7 years ago

This specific behavior is not currently supported. I think it would be possible to add support for this by adding another field for "additional fixed amount". I'm not able to prioritize this at the moment, but think it would be a fine addition.

dandrzejewski commented 5 years ago

The formula for this would be:

total=(subtotal+fixed)/(1-percent)

So, using a typical example, if the fixed amount is $0.30 and the percentage is 2.9%, the formula works out to:

total=(subtotal+.3)/(1-.029)

Hope this helps.

UPDATE: Here's a quick (and extremely dirty) hack. Change line 31 of public_price_set_form.js to:

var total = (baseTotal+.3)/(1-(percentage/100));

Also add this to percentagepricesetfield.php after line 344:

$additional_amount = (($base_total + .3) / (1 - .029)) - $base_total; $additional_amount = round($additional_amount, 2);

If I have time at some point, I'll variablize this and add config options that allow you to use this formula instead and set a fixed ammount.