Skip to content

Commit 2b22cf0

Browse files
committed
Reorder precondition checks in payment processing
This way we group simple checks and checks that would raise exceptions in different groups for better readability.
1 parent b1d3858 commit 2b22cf0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/app/models/spree/payment/processing.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,14 @@ def handle_void_response(response)
165165

166166
# @raises Spree::Core::GatewayError
167167
def check_payment_preconditions!
168-
return if payment_method.nil?
168+
return if processing?
169+
return unless payment_method
169170
return unless payment_method.source_required?
171+
170172
unless source
171173
gateway_error(I18n.t('spree.payment_processing_failed'))
172174
end
173-
return if processing?
175+
174176
unless payment_method.supports?(source)
175177
invalidate!
176178
gateway_error(I18n.t('spree.payment_method_not_supported'))

0 commit comments

Comments
 (0)