diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index 92e39715a8..48bcd08f3c 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -9,7 +9,7 @@ class PaymentsController < BaseController @payment = Spree::Payment.find(params[:id]) authorize! :show, @payment.order - if (url = @payment.cvv_response_message) + if (url = @payment.redirect_auth_url) redirect_to url else redirect_to order_url(@payment.order) diff --git a/app/models/spree/payment/processing.rb b/app/models/spree/payment/processing.rb index 8f9d0e4573..57b4f4335a 100644 --- a/app/models/spree/payment/processing.rb +++ b/app/models/spree/payment/processing.rb @@ -241,7 +241,8 @@ module Spree if response.cvv_result self.cvv_response_code = response.cvv_result['code'] self.cvv_response_message = response.cvv_result['message'] - if cvv_response_message.present? + self.redirect_auth_url = response.cvv_result['redirect_auth_url'] + if redirect_auth_url.present? return require_authorization! end end diff --git a/app/services/checkout/stripe_redirect.rb b/app/services/checkout/stripe_redirect.rb index ed59e93e2e..74eca0a7cd 100644 --- a/app/services/checkout/stripe_redirect.rb +++ b/app/services/checkout/stripe_redirect.rb @@ -40,7 +40,7 @@ module Checkout # Stripe::AuthorizeResponsePatcher patches the Stripe authorization response # so that this field stores the redirect URL. It also verifies that it is a Stripe URL. def stripe_payment_url(payment) - payment.cvv_response_message + payment.redirect_auth_url end end end diff --git a/app/views/spree/users/_transactions.html.haml b/app/views/spree/users/_transactions.html.haml index e36d6c9382..262282360b 100644 --- a/app/views/spree/users/_transactions.html.haml +++ b/app/views/spree/users/_transactions.html.haml @@ -16,7 +16,7 @@ %td = payment.updated_at.strftime("%Y-%m-%d") %td - %a{ href: "#{payment.cvv_response_message}" } + %a{ href: "#{payment.redirect_auth_url}" } %button.x-small = t(".authorise") %td.text-right diff --git a/db/migrate/20250820224718_add_redirect_auth_url_in_payment_model.rb b/db/migrate/20250820224718_add_redirect_auth_url_in_payment_model.rb new file mode 100644 index 0000000000..fbc0b0653b --- /dev/null +++ b/db/migrate/20250820224718_add_redirect_auth_url_in_payment_model.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddRedirectAuthUrlInPaymentModel < ActiveRecord::Migration[7.1] + def change + add_column :spree_payments, :redirect_auth_url, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 8b0718760e..d92bed1b26 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2025_07_09_012346) do +ActiveRecord::Schema[7.1].define(version: 2025_08_20_224718) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" @@ -652,6 +652,7 @@ ActiveRecord::Schema[7.0].define(version: 2025_07_09_012346) do t.string "cvv_response_code", limit: 255 t.text "cvv_response_message" t.datetime "captured_at", precision: nil + t.string "redirect_auth_url" t.index ["order_id"], name: "index_spree_payments_on_order_id" end diff --git a/lib/stripe/authorize_response_patcher.rb b/lib/stripe/authorize_response_patcher.rb index 5586718949..3a3ed67ea1 100644 --- a/lib/stripe/authorize_response_patcher.rb +++ b/lib/stripe/authorize_response_patcher.rb @@ -10,7 +10,7 @@ module Stripe def call! if (url = url_for_authorization(@response)) && field_to_patch(@response).present? - field_to_patch(@response)['message'] = url + field_to_patch(@response)['redirect_auth_url'] = url end @response