diff --git a/bin/process_pending_btc_transactions b/bin/process_pending_btc_transactions index 2f7c73751dbef159cf5699d73a67a0d40ea3f6c5..d82927c9906674e039d8e21c0bc08290263da9cb 100755 --- a/bin/process_pending_btc_transactions +++ b/bin/process_pending_btc_transactions @@ -196,19 +196,19 @@ class Customer result || BigDecimal.new(0) end - def add_btc_credit(txid, fiat_amount, cad_to_usd) - add_transaction(txid, fiat_amount, "Bitcoin payment") + def add_btc_credit(txid, btc_amount, fiat_amount, cad_to_usd) + add_transaction(txid, btc_amount, fiat_amount, "Bitcoin payment") if (bonus = plan.bonus_for(fiat_amount, cad_to_usd)) add_transaction("bonus_for_#{txid}", bonus, "Bitcoin payment bonus") end - notify_btc_credit(txid, fiat_amount, bonus) + notify_btc_credit(txid, btc_amount, fiat_amount, bonus) end - def notify_btc_credit(txid, fiat_amount, bonus) + def notify_btc_credit(txid, btc_amount, fiat_amount, bonus) tx_hash, = txid.split("/", 2) notify([ - "Your Bitcoin transaction has been added as ", - "$#{'%.4f' % fiat_amount} ", + "Your Bitcoin transaction of #{btc_amount.to_s('F')} BTC ", + "has been added as $#{'%.4f' % fiat_amount} (#{plan.currency}) ", ("+ $#{'%.4f' % bonus} bonus " if bonus), "to your account.\n(txhash: #{tx_hash})" ].compact.join) @@ -238,7 +238,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, amount, cad_to_usd) + customer.add_btc_credit(txid, btc, amount, cad_to_usd) customer.plan.activate_any_pending_plan! REDIS.hdel("pending_btc_transactions", txid) else