@@ 102,9 102,16 @@ class Plan
@plan[:currency]
end
- def bonus_for(fiat_amount, cad_to_usd)
- bonus = (0.050167 * fiat_amount) - (currency == :CAD ? 1 : cad_to_usd)
- return bonus.round(4, :floor) if bonus > 0
+ def bonus_for(fiat_amount)
+ return BigDecimal.new(0) if fiat_amount <= 15
+ fiat_amount * case fiat_amount
+ when (15..29.99)
+ 0.01
+ when (30..139.99)
+ 0.03
+ else
+ 0.05
+ end
end
def price
@@ 195,9 202,9 @@ class Customer
result || BigDecimal.new(0)
end
- def add_btc_credit(txid, btc_amount, fiat_amount, cad_to_usd)
+ def add_btc_credit(txid, btc_amount, fiat_amount)
add_transaction(txid, btc_amount, fiat_amount, "Bitcoin payment")
- if (bonus = plan.bonus_for(fiat_amount, cad_to_usd))
+ if (bonus = plan.bonus_for(fiat_amount))
add_transaction("bonus_for_#{txid}", bonus, "Bitcoin payment bonus")
end
notify_btc_credit(txid, btc_amount, fiat_amount, bonus)
@@ 237,7 244,7 @@ REDIS.hgetall("pending_btc_transactions").each do |(txid, customer_id)|
customer = Customer.new(customer_id)
if (plan = customer.plan)
amount = btc * btc_sell_price.fetch(plan.currency).round(4, :floor)
- customer.add_btc_credit(txid, btc, amount, cad_to_usd)
+ customer.add_btc_credit(txid, btc, amount)
customer.plan.activate_any_pending_plan!
REDIS.hdel("pending_btc_transactions", txid)
else