Reputation: 429
How we can calculate the Stripe.
I am using this formula to calculate Stripe Fee.
Say
amount = $100
(100 * 0.029) + 0.30 = 103.20
But On stripe it is displaying 103.29
instead of 103.20
.
Don't know what's going on??
Upvotes: 4
Views: 7676
Reputation: 4663
I think the correct formula is :
function calculateCCAfterFee(amount) {
var FIXED_FEE = 0.30;
var PERCENTAGE_FEE = 0.029;
var temp_fee = amount * PERCENTAGE_FEE;
var full_fee = temp_fee + FIXED_FEE;
// var full_fee ;
return Number(full_fee).toFixed(2);
}
Because this returns actual amount of fee could be reduced from the amount customer pays.
Upvotes: 0
Reputation: 528
function calculateCCAfterFee(qty) {
var FIXED_FEE = 0.30;
var PERCENTAGE_FEE = 0.029;
return Number((qty + FIXED_FEE)/(1 - PERCENTAGE_FEE)).toFixed(1);
}
For the lost js developer ...
Upvotes: 5
Reputation: 17503
Stripe's pricing depends on the region, and might vary according to some other factors such as whether the card is domestic or not, or the card's brand. But for US accounts, the pricing is simple: 2.9% + $0.30.
So if you create a $100.00 charge, the fee will be:
($100.00 * 2.9%) + $0.30 = $3.20.
Those $3.20 will be taken out of the $100.00, i.e. the customer will be charged $100.00 and your account's balance will be increased by $96.80 ($100.00 - $3.20).
If you want to pass the fee to the customer, then it's a bit more complicated, but this article explains the math you need to apply.
In this case, if you want to receive $100.00, you'd compute the charge's amount like this:
($100.00 + $0.30) / (1 - 2.9%) = $100.30 / 0.971 = $103.30.
So you'd charge $103.30 to your customer. Stripe's fee will be $3.30 ($103.30 * 2.9% + $0.30 = $3.30), and your account's balance will be increased by $100.00.
Upvotes: 22