Class: Pay::Charge

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

Instance Method Summary collapse

Instance Method Details

#braintree?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/models/pay/charge.rb', line 35

def braintree?
  processor == "braintree"
end

#charged_toObject



27
28
29
# File 'app/models/pay/charge.rb', line 27

def charged_to
  "#{card_type} (**** **** **** #{card_last4})"
end

#paypal?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/pay/charge.rb', line 39

def paypal?
  braintree? && card_type == "PayPal"
end

#processor_chargeObject



18
19
20
# File 'app/models/pay/charge.rb', line 18

def processor_charge
  send("#{processor}_charge")
end

#refund!(refund_amount = nil) ⇒ Object



22
23
24
25
# File 'app/models/pay/charge.rb', line 22

def refund!(refund_amount = nil)
  refund_amount ||= amount
  send("#{processor}_refund!", refund_amount)
end

#stripe?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/pay/charge.rb', line 31

def stripe?
  processor == "stripe"
end