move payment to requires_authorization if cvv_result is present

This commit is contained in:
Andy Brett
2021-05-29 10:56:00 -07:00
parent a6cec20056
commit 527f4e2cb3
6 changed files with 16 additions and 6 deletions

View File

@@ -175,7 +175,9 @@ module Spree
@payment.authorize!(full_order_path(@payment.order))
raise Spree::Core::GatewayError, I18n.t('authorization_failure') unless @payment.pending?
unless @payment.pending? || @payment.requires_authorization?
raise Spree::Core::GatewayError, I18n.t('authorization_failure')
end
return unless @payment.requires_authorization?

View File

@@ -236,7 +236,9 @@ module Spree
if response.cvv_result
self.cvv_response_code = response.cvv_result['code']
self.cvv_response_message = response.cvv_result['message']
self.require_authorization if self.cvv_response_message.present?
if self.cvv_response_message.present?
return self.require_authorization!
end
end
end
__send__("#{success_state}!")

View File

@@ -15,7 +15,9 @@ module OrderManagement
@payment.authorize!(redirect_url)
@order.errors.add(:base, I18n.t('authorization_failure')) unless @payment.pending?
unless @payment.pending? || @payment.requires_authorization?
@order.errors.add(:base, I18n.t('authorization_failure'))
end
@payment
end

View File

@@ -65,7 +65,7 @@ module OrderManagement
allow(PaymentMailer).to receive(:authorize_payment) { mail_mock }
allow(PaymentMailer).to receive(:authorization_required) { mail_mock }
allow(payment).to receive(:authorize!) {
payment.state = "pending"
payment.state = "requires_authorization"
payment.cvv_response_message = "https://stripe.com/redirect"
}
end

View File

@@ -82,7 +82,7 @@ feature '
expect(page).to have_link "StripeSCA"
expect(page).to have_content "PENDING"
expect(OrderPaymentFinder.new(order.reload).last_payment.state).to eq "pending"
expect(OrderPaymentFinder.new(order.reload).last_payment.state).to eq "requires_authorization"
end
end
end

View File

@@ -10,7 +10,11 @@ describe PaymentsRequiringAction do
describe '#query' do
context "payment has a cvv_response_message" do
let(:payment) do
create(:payment, order: order, cvv_response_message: "https://stripe.com/redirect")
create(:payment,
order: order,
cvv_response_message: "https://stripe.com/redirect",
state: "requires_authorization"
)
end
it "finds the payment" do