Class: Billy::Charge

Inherits:
ApplicationRecord show all
Defined in:
app/models/billy/charge.rb

Instance Method Summary collapse

Instance Method Details

#amount_refunded_with_currencyObject



54
55
56
# File 'app/models/billy/charge.rb', line 54

def amount_refunded_with_currency
  Billy::Currency.format(amount_refunded, currency: currency)
end

#amount_with_currencyObject



50
51
52
# File 'app/models/billy/charge.rb', line 50

def amount_with_currency
  Billy::Currency.format(amount, currency: currency)
end

#card_type_nameObject



27
28
29
30
31
32
33
34
35
36
# File 'app/models/billy/charge.rb', line 27

def card_type_name
  case card_type
  when "visa"
    "Visa"
  when "master", "mastercard"
    "MasterCard"
  when "paypal"
    "PayPal"
  end
end

#charged_toObject



19
20
21
22
23
24
25
# File 'app/models/billy/charge.rb', line 19

def charged_to
  if method == "card"
    "#{card_type_name} ending in #{card_last4}"
  elsif method == "paypal"
    "PayPal"
  end
end

#full_refund?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/billy/charge.rb', line 42

def full_refund?
  refunded? && amount == amount_refunded
end

#partial_refund?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/models/billy/charge.rb', line 46

def partial_refund?
  refunded? && !full_refund?
end

#refunded?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/billy/charge.rb', line 38

def refunded?
  amount_refunded.to_i > 0
end