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
-
#actions ⇒ Array<String>
Available actions for the payment source.
-
#can_capture?(payment) ⇒ Boolean
Indicates whether its possible to capture the payment.
-
#can_credit?(payment) ⇒ Boolean
Indicates whether its possible to credit the payment.
-
#can_void?(payment) ⇒ Boolean
Indicates whether its possible to void the payment.
-
#has_payment_profile? ⇒ Boolean
Returns true if the payment source has a payment profile.
Instance Method Details
#actions ⇒ Array<String>
Available actions for the payment source.
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
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.
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.
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.
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 |