From ac06126f59362558e5f753d4b8ab5534f7e0ed20 Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Thu, 28 Aug 2025 02:29:32 +0500 Subject: [PATCH] replace cvv_response_message usage with redirect_auth_url --- app/models/spree/payment.rb | 4 ++-- app/serializers/api/payment_serializer.rb | 2 +- app/services/process_payment_intent.rb | 2 +- .../order/stripe_sca_payment_authorize_spec.rb | 2 +- lib/tasks/data/anonymize_data.rake | 2 +- .../payment_gateways/stripe_controller_spec.rb | 12 ++++++------ .../orders/payments/payments_controller_spec.rb | 4 ++-- spec/lib/stripe/authorize_response_patcher_spec.rb | 2 +- spec/models/spree/payment_spec.rb | 6 +++--- spec/queries/payments_requiring_action_query_spec.rb | 8 ++++---- spec/requests/payments_controller_spec.rb | 8 ++++---- spec/serializers/api/admin/order_serializer_spec.rb | 2 +- spec/services/checkout/stripe_redirect_spec.rb | 2 +- spec/services/process_payment_intent_spec.rb | 4 ++-- spec/system/consumer/account/payments_spec.rb | 4 ++-- 15 files changed, 32 insertions(+), 32 deletions(-) diff --git a/app/models/spree/payment.rb b/app/models/spree/payment.rb index 03111f42c6..b68595c801 100644 --- a/app/models/spree/payment.rb +++ b/app/models/spree/payment.rb @@ -57,7 +57,7 @@ module Spree scope :failed, -> { with_state('failed') } scope :valid, -> { where.not(state: %w(failed invalid)) } scope :void, -> { with_state('void') } - scope :authorization_action_required, -> { where.not(cvv_response_message: nil) } + scope :authorization_action_required, -> { where.not(redirect_auth_url: nil) } scope :requires_authorization, -> { with_state("requires_authorization") } scope :with_payment_intent, ->(code) { where(response_code: code) } @@ -164,7 +164,7 @@ module Spree end def clear_authorization_url - update_attribute(:cvv_response_message, nil) + update_attribute(:redirect_auth_url, nil) end private diff --git a/app/serializers/api/payment_serializer.rb b/app/serializers/api/payment_serializer.rb index 8d8e365882..a2231062be 100644 --- a/app/serializers/api/payment_serializer.rb +++ b/app/serializers/api/payment_serializer.rb @@ -2,7 +2,7 @@ module Api class PaymentSerializer < ActiveModel::Serializer - attributes :amount, :updated_at, :payment_method, :state, :cvv_response_message + attributes :amount, :updated_at, :payment_method, :state, :redirect_auth_url def payment_method object.payment_method.try(:name) diff --git a/app/services/process_payment_intent.rb b/app/services/process_payment_intent.rb index 1a57d9dd27..9376dc499e 100644 --- a/app/services/process_payment_intent.rb +++ b/app/services/process_payment_intent.rb @@ -5,7 +5,7 @@ # /checkout; for admin payments and subscription payemnts it's the order url. # # This class confirms that the payment intent matches what's in our database, -# marks the payment as complete, and removes the cvv_response_message field, +# marks the payment as complete, and removes the redirect_auth_url field, # which we use to indicate that authorization is required. It also completes the # Order, if appropriate. diff --git a/engines/order_management/spec/services/order_management/order/stripe_sca_payment_authorize_spec.rb b/engines/order_management/spec/services/order_management/order/stripe_sca_payment_authorize_spec.rb index 338d938a1a..81876ad376 100644 --- a/engines/order_management/spec/services/order_management/order/stripe_sca_payment_authorize_spec.rb +++ b/engines/order_management/spec/services/order_management/order/stripe_sca_payment_authorize_spec.rb @@ -66,7 +66,7 @@ module OrderManagement allow(PaymentMailer).to receive(:authorization_required) { mail_mock } allow(payment).to receive(:authorize!) { payment.state = "requires_authorization" - payment.cvv_response_message = "https://stripe.com/redirect" + payment.redirect_auth_url = "https://stripe.com/redirect" } end diff --git a/lib/tasks/data/anonymize_data.rake b/lib/tasks/data/anonymize_data.rake index 250e8d44b1..d6db68b175 100644 --- a/lib/tasks/data/anonymize_data.rake +++ b/lib/tasks/data/anonymize_data.rake @@ -64,7 +64,7 @@ namespace :ofn do environment = '#{Rails.env}'") Spree::Payment.update_all("response_code = null, avs_response = null, cvv_response_code = null, identifier = null, - cvv_response_message = null") + cvv_response_message = null, redirect_auth_url = null") Spree::CreditCard.update_all(" month = 12, year = 2020, start_month = 12, start_year = 2000, cc_type = 'VISA', first_name = 'Dummy', last_name = 'Dummy', last_digits = '2543'") diff --git a/spec/controllers/payment_gateways/stripe_controller_spec.rb b/spec/controllers/payment_gateways/stripe_controller_spec.rb index 1475503759..de1cc7ccb1 100644 --- a/spec/controllers/payment_gateways/stripe_controller_spec.rb +++ b/spec/controllers/payment_gateways/stripe_controller_spec.rb @@ -208,7 +208,7 @@ RSpec.describe PaymentGateways::StripeController do create( :payment, payment_method:, - cvv_response_message: "https://stripe.com/redirect", + redirect_auth_url: "https://stripe.com/redirect", response_code: "pi_123", order:, state: "requires_authorization" @@ -244,7 +244,7 @@ RSpec.describe PaymentGateways::StripeController do expect(response).to redirect_to order_path(order) payment.reload expect(payment.state).to eq("completed") - expect(payment.cvv_response_message).to be nil + expect(payment.redirect_auth_url).to be nil end it "moves the order state to completed" do @@ -273,7 +273,7 @@ RSpec.describe PaymentGateways::StripeController do expect(response).to redirect_to order_path(order) payment.reload expect(payment.state).to eq("completed") - expect(payment.cvv_response_message).to be nil + expect(payment.redirect_auth_url).to be nil end end @@ -288,7 +288,7 @@ RSpec.describe PaymentGateways::StripeController do expect(response).to redirect_to order_path(order) payment.reload expect(payment.state).to eq("completed") - expect(payment.cvv_response_message).to be nil + expect(payment.redirect_auth_url).to be nil end end end @@ -307,7 +307,7 @@ RSpec.describe PaymentGateways::StripeController do expect(response).to redirect_to order_path(order) expect(flash[:error]).to eq("The payment could not be processed. error message") payment.reload - expect(payment.cvv_response_message).to be nil + expect(payment.redirect_auth_url).to be nil expect(payment.state).to eq("failed") end end @@ -330,7 +330,7 @@ RSpec.describe PaymentGateways::StripeController do expect(response).to redirect_to order_path(order) expect(flash[:error]).to eq("The payment could not be processed. ") payment.reload - expect(payment.cvv_response_message).to eq("https://stripe.com/redirect") + expect(payment.redirect_auth_url).to eq("https://stripe.com/redirect") expect(payment.state).to eq("requires_authorization") end end diff --git a/spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb b/spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb index 6214e06af5..44a4258d4b 100644 --- a/spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb +++ b/spec/controllers/spree/admin/orders/payments/payments_controller_spec.rb @@ -78,7 +78,7 @@ RSpec.describe Spree::Admin::PaymentsController do context "where further action is required" do before do allow_any_instance_of(Spree::Payment).to receive(:authorize!) do |payment| - payment.update cvv_response_message: "https://www.stripe.com/authorize" + payment.update redirect_auth_url: "https://www.stripe.com/authorize" payment.update state: "requires_authorization" end end @@ -234,7 +234,7 @@ RSpec.describe Spree::Admin::PaymentsController do allow(PaymentMailer).to receive(:authorize_payment) { mail_mock } request.env["HTTP_REFERER"] = "http://foo.com" allow(Spree::Payment).to receive(:find).with(payment.id.to_s) { payment } - allow(payment).to receive(:cvv_response_message).and_return("https://www.stripe.com/authorize") + allow(payment).to receive(:redirect_auth_url).and_return("https://www.stripe.com/authorize") allow(payment).to receive(:requires_authorization?) { true } end diff --git a/spec/lib/stripe/authorize_response_patcher_spec.rb b/spec/lib/stripe/authorize_response_patcher_spec.rb index 3eb2f2e626..12bf6e4367 100644 --- a/spec/lib/stripe/authorize_response_patcher_spec.rb +++ b/spec/lib/stripe/authorize_response_patcher_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Stripe::AuthorizeResponsePatcher do it "patches response.cvv_result.message with nil" do new_response = patcher.call! - expect(new_response.cvv_result['message']).to be_nil + expect(new_response.cvv_result['redirect_auth_url']).to eq nil end end end diff --git a/spec/models/spree/payment_spec.rb b/spec/models/spree/payment_spec.rb index 4146375110..9037bdee67 100644 --- a/spec/models/spree/payment_spec.rb +++ b/spec/models/spree/payment_spec.rb @@ -1048,11 +1048,11 @@ RSpec.describe Spree::Payment do end describe "#clear_authorization_url" do - let(:payment) { create(:payment, cvv_response_message: "message") } + let(:payment) { create(:payment, redirect_auth_url: "auth_url") } - it "removes the cvv_response_message" do + it "removes the redirect_auth_url" do payment.clear_authorization_url - expect(payment.cvv_response_message).to eq(nil) + expect(payment.redirect_auth_url).to eq(nil) end end diff --git a/spec/queries/payments_requiring_action_query_spec.rb b/spec/queries/payments_requiring_action_query_spec.rb index d18a861802..6c2d56d9e5 100644 --- a/spec/queries/payments_requiring_action_query_spec.rb +++ b/spec/queries/payments_requiring_action_query_spec.rb @@ -9,11 +9,11 @@ RSpec.describe PaymentsRequiringActionQuery do let(:order) { create(:order, user:) } describe '#call' do - context "payment has a cvv_response_message" do + context "payment has a redirect_auth_url" do let(:payment) do create(:payment, order:, - cvv_response_message: "https://stripe.com/redirect", + redirect_auth_url: "https://stripe.com/redirect", state: "requires_authorization") end @@ -22,9 +22,9 @@ RSpec.describe PaymentsRequiringActionQuery do end end - context "payment has no cvv_response_message" do + context "payment has no redirect_auth_url" do let(:payment) do - create(:payment, order:, cvv_response_message: nil) + create(:payment, order:, redirect_auth_url: nil) end it "does not find the payment" do diff --git a/spec/requests/payments_controller_spec.rb b/spec/requests/payments_controller_spec.rb index 9aab1272eb..242a4e1202 100644 --- a/spec/requests/payments_controller_spec.rb +++ b/spec/requests/payments_controller_spec.rb @@ -18,18 +18,18 @@ RSpec.describe "/payments/:id/authorize" do describe "when user is logged in" do before { sign_in user } - context "has cvv response message" do + context "has redirect auth url" do before do - allow_any_instance_of(Spree::Payment).to receive(:cvv_response_message).and_return('http://example.com') + allow_any_instance_of(Spree::Payment).to receive(:redirect_auth_url).and_return('http://example.com') end - it "redirects to the CVV response URL" do + it "redirects to the 3D-Auth url" do get authorize_payment_path(payment) expect(response).to redirect_to('http://example.com') end end - context "doesn't have cvv response message" do + context "doesn't have redirect auth url" do it "redirect to order URL" do get authorize_payment_path(payment) expect(response).to redirect_to(order_url(order)) diff --git a/spec/serializers/api/admin/order_serializer_spec.rb b/spec/serializers/api/admin/order_serializer_spec.rb index 580a5ae2b1..5a1a2c1f50 100644 --- a/spec/serializers/api/admin/order_serializer_spec.rb +++ b/spec/serializers/api/admin/order_serializer_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Api::Admin::OrderSerializer do order:, state: 'requires_authorization', amount: 123.45, - cvv_response_message: "https://stripe.com/redirect" + redirect_auth_url: "https://stripe.com/redirect" ) end diff --git a/spec/services/checkout/stripe_redirect_spec.rb b/spec/services/checkout/stripe_redirect_spec.rb index 9798958994..49b68149ea 100644 --- a/spec/services/checkout/stripe_redirect_spec.rb +++ b/spec/services/checkout/stripe_redirect_spec.rb @@ -36,7 +36,7 @@ RSpec.describe Checkout::StripeRedirect do true end - expect(stripe_payment).to receive(:cvv_response_message).and_return(test_redirect_url) + expect(stripe_payment).to receive(:redirect_auth_url).and_return(test_redirect_url) expect(service.path).to eq test_redirect_url end diff --git a/spec/services/process_payment_intent_spec.rb b/spec/services/process_payment_intent_spec.rb index 98bc89f00e..cc6684e9b3 100644 --- a/spec/services/process_payment_intent_spec.rb +++ b/spec/services/process_payment_intent_spec.rb @@ -17,7 +17,7 @@ RSpec.describe ProcessPaymentIntent do create( :payment, payment_method:, - cvv_response_message: "https://stripe.com/redirect", + redirect_auth_url: "https://stripe.com/redirect", response_code: "pi_123", order:, state: "requires_authorization" @@ -104,7 +104,7 @@ RSpec.describe ProcessPaymentIntent do service.call! payment.reload expect(payment.state).to eq("completed") - expect(payment.cvv_response_message).to be nil + expect(payment.redirect_auth_url).to be nil end it "completes the order" do diff --git a/spec/system/consumer/account/payments_spec.rb b/spec/system/consumer/account/payments_spec.rb index 0efbf46c13..742551f5fa 100644 --- a/spec/system/consumer/account/payments_spec.rb +++ b/spec/system/consumer/account/payments_spec.rb @@ -17,7 +17,7 @@ RSpec.describe "Payments requiring action" do let!(:payment) do create(:payment, order:, - cvv_response_message: "https://stripe.com/redirect", + redirect_auth_url: "https://stripe.com/redirect", state: "requires_authorization") end @@ -31,7 +31,7 @@ RSpec.describe "Payments requiring action" do context "there are no payments requiring authorization" do let!(:payment) do - create(:payment, order:, cvv_response_message: nil) + create(:payment, order:, redirect_auth_url: nil) end it "does not show the table of payments requiring authorization" do