From 480dfdf9613d7ec8887edf38991ef5953873cb1e Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 3 Dec 2020 00:37:11 +0000 Subject: [PATCH] Handle redirect case For some reason the process is now working correctly, the authorization step succeeds and a redirect link is stored in the payment with state pending. The payment state is correctly left at pending. Here we add a check for the redirect path sent by stripe and fail the authorization if there is one (it means the payment would need an extra auth step only available in the frontoffice now and probably through email to customer at some point in the future). For some reason the flash with the authorization failure message is not showing up for the user --- app/controllers/spree/admin/payments_controller.rb | 4 +++- spec/features/admin/payments_stripe_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/spree/admin/payments_controller.rb b/app/controllers/spree/admin/payments_controller.rb index 0b5732caa1..8b5f42c472 100644 --- a/app/controllers/spree/admin/payments_controller.rb +++ b/app/controllers/spree/admin/payments_controller.rb @@ -135,7 +135,9 @@ module Spree return unless @payment.payment_method.class == Spree::Gateway::StripeSCA @payment.authorize! - raise Spree::Core::GatewayError, I18n.t('authorization_failure') unless @payment.pending? + return if @payment.pending? && @payment.cvv_response_message.nil? + + raise Spree::Core::GatewayError, I18n.t('authorization_failure') end end end diff --git a/spec/features/admin/payments_stripe_spec.rb b/spec/features/admin/payments_stripe_spec.rb index 1a3d6047bf..f030d32451 100644 --- a/spec/features/admin/payments_stripe_spec.rb +++ b/spec/features/admin/payments_stripe_spec.rb @@ -78,8 +78,8 @@ feature ' click_button "Update" expect(page).to have_link "StripeSCA" - expect(page).to have_content "PROCESSING" - expect(OrderPaymentFinder.new(order.reload).last_payment.state).to eq "processing" + expect(page).to have_content "PENDING" + expect(OrderPaymentFinder.new(order.reload).last_payment.state).to eq "pending" end end end