Sha256: de8965aa4d25c05e583e9f3e1ae174d216b70d9ce84c92fe1706dfc2d9c49f71

Contents?: true

Size: 1.52 KB

Versions: 22

Compression:

Stored size: 1.52 KB

Contents

module Spree
  class PaymentSource < Spree::Base
    self.abstract_class = true

    belongs_to :payment_method

    has_many :payments, as: :source
    has_many :wallet_payment_sources, class_name: 'Spree::WalletPaymentSource', as: :payment_source, inverse_of: :payment_source

    attr_accessor :imported

    # @return [Array<String>] the actions available on this payment source
    def actions
      %w(capture void credit)
    end

    # @param payment [Spree::Payment] the payment we want to know if can be captured
    # @return [Boolean] true when the payment is in the pending or checkout states
    def can_capture?(payment)
      payment.pending? || payment.checkout?
    end

    # @param payment [Spree::Payment] the payment we want to know if can be voided
    # @return [Boolean] true when the payment is not failed or voided
    def can_void?(payment)
      !payment.failed? && !payment.void?
    end

    # Indicates whether its possible to credit the payment.  Note that most
    # gateways require that the payment be settled first which generally
    # happens within 12-24 hours of the transaction.
    #
    # @param payment [Spree::Payment] the payment we want to know if can be credited
    # @return [Boolean] true when the payment is completed and can be credited
    def can_credit?(payment)
      payment.completed? && payment.credit_allowed > 0
    end

    # Indicates whether this payment source can be used more than once. E.g. a
    # credit card with a 'payment profile'.
    def reusable?
      false
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
solidus_core-2.5.2 app/models/spree/payment_source.rb
solidus_core-2.5.1 app/models/spree/payment_source.rb
solidus_core-2.5.0 app/models/spree/payment_source.rb
solidus_core-2.5.0.rc1 app/models/spree/payment_source.rb
solidus_core-2.5.0.beta2 app/models/spree/payment_source.rb
solidus_core-2.5.0.beta1 app/models/spree/payment_source.rb
solidus_core-2.4.2 app/models/spree/payment_source.rb
solidus_core-2.3.1 app/models/spree/payment_source.rb
solidus_core-2.4.1 app/models/spree/payment_source.rb
solidus_core-2.2.2 app/models/spree/payment_source.rb
solidus_core-2.4.0 app/models/spree/payment_source.rb
solidus_core-2.4.0.rc1 app/models/spree/payment_source.rb
solidus_core-2.4.0.beta1 app/models/spree/payment_source.rb
solidus_core-2.3.0 app/models/spree/payment_source.rb
solidus_core-2.3.0.rc3 app/models/spree/payment_source.rb
solidus_core-2.3.0.rc2 app/models/spree/payment_source.rb
solidus_core-2.3.0.rc1 app/models/spree/payment_source.rb
solidus_core-2.3.0.beta1 app/models/spree/payment_source.rb
solidus_core-2.2.1 app/models/spree/payment_source.rb
solidus_core-2.2.0 app/models/spree/payment_source.rb