Merge pull request #11290 from cyrillefr/Orders_in_confirmation_state_cannot_be_completed_by_hub_or_shop

Fix Orders in confirmation state cannot be completed by hub or shop
This commit is contained in:
Filipe
2023-11-16 19:50:14 +00:00
committed by GitHub
13 changed files with 49 additions and 12 deletions

View File

@@ -67,7 +67,7 @@ module Spree
end
def actions
%w{capture void credit resend_authorization_email}
%w{capture_and_complete_order void credit resend_authorization_email}
end
def can_resend_authorization_email?(payment)
@@ -75,7 +75,7 @@ module Spree
end
# Indicates whether its possible to capture the payment
def can_capture?(payment)
def can_capture_and_complete_order?(payment)
return false if payment.requires_authorization?
payment.pending? || payment.checkout?

View File

@@ -47,6 +47,11 @@ module Spree
end
end
def capture_and_complete_order!
OrderWorkflow.new(order).complete!
capture!
end
def void_transaction!
return true if void?

View File

@@ -4,11 +4,11 @@ module Spree
class PaymentMethod
class Check < Spree::PaymentMethod
def actions
%w{capture void}
%w{capture_and_complete_order void}
end
# Indicates whether its possible to capture the payment
def can_capture?(payment)
def can_capture_and_complete_order?(payment)
['checkout', 'pending'].include?(payment.state)
end