Skip to content

Commit 448aaf1

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 4c9ef7c commit 448aaf1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

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

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

167167
# @raises Spree::Core::GatewayError
168168
def check_payment_preconditions!
169-
return if payment_method.nil?
169+
return if processing?
170+
return unless payment_method
170171
return unless payment_method.source_required?
172+
171173
unless source
172174
gateway_error(I18n.t('spree.payment_processing_failed'))
173175
end
174-
return if processing?
176+
175177
unless payment_method.supports?(source)
176178
invalidate!
177179
gateway_error(I18n.t('spree.payment_method_not_supported'))

0 commit comments

Comments
 (0)