Module: Spree::PaymentSourceConcern

Extended by:
ActiveSupport::Concern
Included in:
CreditCard, PaymentSource
Defined in:
app/models/concerns/spree/payment_source_concern.rb

Instance Method Summary collapse

Instance Method Details

#actionsArray<String>

Available actions for the payment source.

Returns:

  • (Array<String>)


11
12
13
# File 'app/models/concerns/spree/payment_source_concern.rb', line 11

def actions
  %w{capture void credit}
end

#can_capture?(payment) ⇒ Boolean

Indicates whether its possible to capture the payment

Parameters:

Returns:

  • (Boolean)


18
19
20
# File 'app/models/concerns/spree/payment_source_concern.rb', line 18

def can_capture?(payment)
  payment.pending? || payment.checkout?
end

#can_credit?(payment) ⇒ Boolean

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.

Parameters:

Returns:

  • (Boolean)


33
34
35
# File 'app/models/concerns/spree/payment_source_concern.rb', line 33

def can_credit?(payment)
  payment.completed? && payment.credit_allowed > 0
end

#can_void?(payment) ⇒ Boolean

Indicates whether its possible to void the payment.

Parameters:

Returns:

  • (Boolean)


25
26
27
# File 'app/models/concerns/spree/payment_source_concern.rb', line 25

def can_void?(payment)
  !payment.failed? && !payment.void?
end

#has_payment_profile?Boolean

Returns true if the payment source has a payment profile.

Returns:

  • (Boolean)


39
40
41
# File 'app/models/concerns/spree/payment_source_concern.rb', line 39

def has_payment_profile?
  gateway_customer_profile_id.present? || gateway_payment_profile_id.present?
end