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