Sha256: 32f19a0768229034760fb3753dad7b5bdb98c5f30d85638cbc785a46cdc8c0e7
Contents?: true
Size: 931 Bytes
Versions: 7
Compression:
Stored size: 931 Bytes
Contents
module Pay class Charge < ApplicationRecord self.table_name = Pay.chargeable_table # Associations belongs_to :owner, class_name: Pay.billable_class, foreign_key: :owner_id # Scopes scope :sorted, -> { order(created_at: :desc) } default_scope -> { sorted } # Validations validates :amount, presence: true validates :processor, presence: true validates :processor_id, presence: true validates :card_type, presence: true def processor_charge send("#{processor}_charge") end def refund!(refund_amount = nil) refund_amount ||= amount send("#{processor}_refund!", refund_amount) end def charged_to "#{card_type} (**** **** **** #{card_last4})" end def stripe? processor == "stripe" end def braintree? processor == "braintree" end def paypal? braintree? && card_type == "PayPal" end end end
Version data entries
7 entries across 7 versions & 1 rubygems