mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user