Files
openfoodnetwork/app/controllers/payments_controller.rb
Ahmed Ejaz 626b802ea7 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
2025-09-22 11:54:20 +05:00

30 lines
742 B
Ruby

# frozen_string_literal: true
class PaymentsController < BaseController
respond_to :html
prepend_before_action :require_logged_in, only: :redirect_to_authorize
def redirect_to_authorize
@payment = Spree::Payment.find(params[:id])
authorize! :show, @payment.order
if (url = @payment.redirect_auth_url)
redirect_to url
else
redirect_to order_url(@payment.order)
end
end
private
def require_logged_in
return if session[:access_token] || spree_current_user
store_location_for :spree_user, request.original_fullpath
flash[:error] = I18n.t("spree.orders.edit.login_to_view_order")
redirect_to main_app.root_path(anchor: "/login", after_login: request.original_fullpath)
end
end