~singpolyma/sgx-jmp

ba0328469129a1e73c53b06b81e560fd68a3fa72 — Christopher Vollick 7 months ago 36f007c
Declines should be an Int

Previously this retured a string and everywhere that used it had to
convert it into an it, or handle it if it's nil.

That's dumb.
Now it's always an int, and `nil.to_i` is 0 anyway so I don't have to
check that either.
3 files changed, 3 insertions(+), 3 deletions(-)

M lib/customer_finacials.rb
M lib/financial_info.rb
M lib/transaction.rb
M lib/customer_finacials.rb => lib/customer_finacials.rb +1 -1
@@ 31,7 31,7 @@ class CustomerFinancials
	end

	def declines
		REDIS.get("jmp_pay_decline-#{@customer_id}")
		REDIS.get("jmp_pay_decline-#{@customer_id}").then(&:to_i)
	end

	def mark_decline

M lib/financial_info.rb => lib/financial_info.rb +1 -1
@@ 17,7 17,7 @@ class AdminFinancialInfo
		]).then do |transactions, declines, payment_methods, btc_addresses|
			new(
				transactions: transactions,
				declines: declines || 0,
				declines: declines,
				payment_methods: payment_methods, btc_addresses: btc_addresses
			)
		end

M lib/transaction.rb => lib/transaction.rb +1 -1
@@ 5,7 5,7 @@ require "bigdecimal"
class Transaction
	def self.sale(customer, amount:, payment_method: nil)
		customer.declines.then do |declines|
			raise "too many declines" if declines.to_i >= 2
			raise "too many declines" if declines >= 2

			BRAINTREE.transaction.sale(
				amount: amount,