mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
refactor to descriptive method authorization_action_required?
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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!
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user