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>)


7
8
9
# File 'app/models/concerns/spree/payment_source_concern.rb', line 7

def actions
  %w{capture void credit}
end

#can_capture?(payment) ⇒ Boolean

Indicates whether its possible to capture the payment

Parameters:

Returns:

  • (Boolean)


14
15
16
# File 'app/models/concerns/spree/payment_source_concern.rb', line 14

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)


29
30
31
# File 'app/models/concerns/spree/payment_source_concern.rb', line 29

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)


21
22
23
# File 'app/models/concerns/spree/payment_source_concern.rb', line 21

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)


35
36
37
# File 'app/models/concerns/spree/payment_source_concern.rb', line 35

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