rename and consolidate authorization? methods

This commit is contained in:
Andy Brett
2021-05-28 12:34:44 -07:00
parent 674ca3026b
commit 31738ceb49
7 changed files with 8 additions and 12 deletions

View File

@@ -177,7 +177,7 @@ module Spree
raise Spree::Core::GatewayError, I18n.t('authorization_failure') unless @payment.pending?
return unless @payment.authorization_action_required?
return unless @payment.requires_authorization?
PaymentMailer.authorize_payment(@payment).deliver_later
raise Spree::Core::GatewayError, I18n.t('action_required')

View File

@@ -83,12 +83,12 @@ module Spree
end
def can_resend_authorization_email?(payment)
payment.pending? && payment.authorization_action_required?
payment.pending? && payment.requires_authorization?
end
# Indicates whether its possible to capture the payment
def can_capture?(payment)
return false if payment.authorization_action_required?
return false if payment.requires_authorization?
payment.pending? || payment.checkout?
end

View File

@@ -127,7 +127,7 @@ module Spree
end
def resend_authorization_email!
return unless authorization_action_required?
return unless requires_authorization?
PaymentMailer.authorize_payment(self).deliver_later
end

View File

@@ -11,7 +11,7 @@ module Spree
def process_offline!
return unless validate!
return if authorization_action_required?
return if requires_authorization?
if preauthorized?
capture!
@@ -182,10 +182,6 @@ module Spree
options
end
def authorization_action_required?
cvv_response_message.present?
end
private
def preauthorized?

View File

@@ -7,7 +7,7 @@ class PaymentsRequiringAction
def query
Spree::Payment.joins(:order).where("spree_orders.user_id = ?", user.id).
authorization_action_required
requires_authorization
end
private

View File

@@ -41,7 +41,7 @@ module Api
# This methods requires to eager load the payment association (with its required WHERE
# constraints) so as not to cause and N+1.
def ready_to_capture
pending_payments = object.pending_payments.reject(&:authorization_action_required?)
pending_payments = object.pending_payments.reject(&:requires_authorization?)
object.payment_required? && pending_payments.any?
end

View File

@@ -6,7 +6,7 @@ module OrderManagement
def call!(redirect_url = full_order_path(@order))
super(redirect_url)
return unless @payment.authorization_action_required?
return unless @payment.requires_authorization?
PaymentMailer.authorize_payment(@payment).deliver_now
PaymentMailer.authorization_required(@payment).deliver_now