Class: Billy::Charge
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Billy::Charge
- Defined in:
- app/models/billy/charge.rb
Instance Method Summary collapse
- #amount_refunded_with_currency ⇒ Object
- #amount_with_currency ⇒ Object
- #card_type_name ⇒ Object
- #charged_to ⇒ Object
- #full_refund? ⇒ Boolean
- #partial_refund? ⇒ Boolean
- #refunded? ⇒ Boolean
Instance Method Details
#amount_refunded_with_currency ⇒ Object
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_currency ⇒ Object
50 51 52 |
# File 'app/models/billy/charge.rb', line 50 def amount_with_currency Billy::Currency.format(amount, currency: currency) end |
#card_type_name ⇒ Object
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_to ⇒ Object
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
42 43 44 |
# File 'app/models/billy/charge.rb', line 42 def full_refund? refunded? && amount == amount_refunded end |
#partial_refund? ⇒ Boolean
46 47 48 |
# File 'app/models/billy/charge.rb', line 46 def partial_refund? refunded? && !full_refund? end |
#refunded? ⇒ Boolean
38 39 40 |
# File 'app/models/billy/charge.rb', line 38 def refunded? amount_refunded.to_i > 0 end |