mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
rename and consolidate authorization? methods
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user