add redirect_auth_url column and replace cvv_response_message for redirection

- Added redirect_auth_url column to spree_payments table
- Updated payment redirection logic to use redirect_auth_url instead of cvv_response_message
- Cleans up old monkeypatch usage and improves Stripe checkout reliability
This commit is contained in:
Ahmed Ejaz
2025-08-27 03:13:11 +05:00
parent 9e746d1b40
commit 626b802ea7
7 changed files with 15 additions and 6 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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