-
Notifications
You must be signed in to change notification settings - Fork 308
investigate credit card processing fee computation #1664
Comments
|
When we run credit cards during payday, we upcharge to cover the fee. Do we upcharge too much? Is that where I got the 187.98 from originally? We used to upcharge based on 3.9% + $0.30. Maybe that explains it? |
Here's the upcharge algorithm: FEE_CHARGE = ( Decimal("0.30") # $0.30
, Decimal("0.029") # 2.9%
)
def upcharge(amount):
"""Given an amount, return a higher amount and the difference.
"""
typecheck(amount, Decimal)
charge_amount = (amount + FEE_CHARGE[0]) / (1 - FEE_CHARGE[1])
charge_amount = charge_amount.quantize(FEE_CHARGE[0], rounding=ROUND_UP)
return charge_amount, charge_amount - amount |
The change in fee does not explain it. Here's what 3.9% + $0.30 looks like:
|
Okay, figured it out. Per 20b5fa0, the upcharge algorithm used to be: FEE_CHARGE = ( Decimal("0.30") # $0.30
, Decimal("1.039") # 3.9%
)
def upcharge(amount):
"""Given an amount, return a higher amount and the difference.
"""
typecheck(amount, Decimal)
charge_amount = (amount + FEE_CHARGE[0]) * FEE_CHARGE[1]
charge_amount = charge_amount.quantize(FEE_CHARGE[0], rounding=ROUND_UP)
return charge_amount, charge_amount - amount That is, we used to multiply by 1.039 instead of dividing by .971. This explains the $6.21 upcharge I'm seeing on 151.00 on May 23, 2013, as well as the $187.98 on $4,812.02 I'm seeing on May 30. In other words, I had ran numbers through upcharge until I got one approximating $5,000.00, and had used that. |
I guess I should leave this open to adjust the fee for their latest payin. |
|
So that's the amount to add to their balance in Gittip. The |
And of course the amount should be |
Done. |
What was actually the problem here? Does it involve anyone else? Why was Heroku balance wrong? |
@zwn The problem is that I applied the wrong fee when I charged Heroku $5,000 a couple days ago. I applied the fee that I applied when I charged them $5,000 six months ago, but we've changed our fee algorithm since then (in 20b5fa0). I was confused and afraid the problem ran deeper, because when yesterday I double-checked the fee (ahead of providing them with an invoice, see #1199 (comment)), I wasn't using the correct algorithm to compute the old fee. The fee six months ago was different in two ways:
In other words, the old algorithm for upcharging a base amount (which is what we usually do when we charge credit cards during payday) was not strictly the opposite of the usual algorithm for skimming a fee off the top (which is what we wanted to do in Heroku's case here). When I was double-checking the fee on the $5,000 this time around (which was after I had already recorded the new $5,000 exchange), I took into account the first change but not the second. Taking both together accounts for the fee we charged six months ago, both against the $5,000 and also against the $151 from the week before that. |
So it seems that there was a decision made to change the fee computation function, though there doesn't seem to be a rationalisation for why it was changed. In my opinion, the new function is actually incorrect based on the stated fees. I would expect (X * 1.029) + .30. However, even if it is (X + .30) * 1.029 this is not the same as (x + .30) / .0971 It is usually a negligible difference that is rounded out, but on large amounts it does make a difference. For $100: 100_1.029 + .30 = 103.20 for $5000 = [5145.30, 5145.31, 5149.64] Is this rounding error intentional? Related issues: #1031 |
I'm working with Heroku on another $5,000 payin. I used the same fee as last time, which was $187.98. However, I don't believe this is correct.
The text was updated successfully, but these errors were encountered: