@@ 213,7 213,9 @@ class Customer
end
def add_btc_credit(txid, btc_amount, fiat_amount)
- add_transaction(txid, btc_amount, fiat_amount, "Bitcoin payment")
+ return unless add_transaction(
+ txid, btc_amount, fiat_amount, "Bitcoin payment"
+ )
if (bonus = plan.bonus_for(fiat_amount))
add_transaction("bonus_for_#{txid}", bonus, "Bitcoin payment bonus")
end
@@ 231,7 233,7 @@ class Customer
end
def add_transaction(id, amount, note)
- DB.exec_params(<<-SQL, [@customer_id, id, amount, note])
+ DB.exec_params(<<-SQL, [@customer_id, id, amount, note]).cmd_tuples > 0
INSERT INTO transactions
(customer_id, transaction_id, amount, note)
VALUES