refactor to descriptive method authorization_action_required?

This commit is contained in:
Andy Brett
2021-02-10 09:36:35 -08:00
parent 5d2c612839
commit 9104ca72a9
5 changed files with 10 additions and 6 deletions

View File

@@ -157,7 +157,7 @@ module Spree
raise Spree::Core::GatewayError, I18n.t('authorization_failure') unless @payment.pending?
return unless @payment.cvv_response_message.present?
return unless @payment.authorization_action_required?
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.cvv_response_message.present?
payment.pending? && payment.authorization_action_required?
end
# Indicates whether its possible to capture the payment
def can_capture?(payment)
return false if payment.cvv_response_message.present?
return false if payment.authorization_action_required?
payment.pending? || payment.checkout?
end

View File

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

View File

@@ -15,7 +15,7 @@ module Spree
def process_offline!
return unless validate!
return if cvv_response_message.present?
return if authorization_action_required?
if payment_method.auto_capture?
charge_offline!
@@ -186,6 +186,10 @@ module Spree
options
end
def authorization_action_required?
cvv_response_message.present?
end
private
def validate!

View File

@@ -17,7 +17,7 @@ module OrderManagement
@order.errors.add(:base, I18n.t('authorization_failure')) unless @payment.pending?
if send_emails && @payment.cvv_response_message.present?
if send_emails && @payment.authorization_action_required?
PaymentMailer.authorize_payment(@payment).deliver_now
PaymentMailer.authorization_required(@payment).deliver_now
end