use scope on payment model

This commit is contained in:
Andy Brett
2021-02-22 13:06:59 -08:00
parent e5eb8f97f9
commit 7bb49b51fd
2 changed files with 3 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ module Spree
scope :pending, -> { with_state('pending') }
scope :failed, -> { with_state('failed') }
scope :valid, -> { where('state NOT IN (?)', %w(failed invalid)) }
scope :authorization_action_required, -> { where.not(cvv_response_message: nil) }
# order state machine (see http://github.com/pluginaweek/state_machine/tree/master for details)
state_machine initial: :checkout do

View File

@@ -6,8 +6,8 @@ class PaymentsRequiringAction
end
def query
Spree::Payment.joins(order: [:user]).where.not(cvv_response_message: nil).
where("spree_users.id = ?", user.id)
Spree::Payment.joins(order: [:user]).where("spree_users.id = ?", user.id).
authorization_action_required
end
private