mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Add route to catch pre-existing payments which may still use Checkout#edit as return URL
This commit is contained in:
@@ -86,6 +86,10 @@ Openfoodnetwork::Application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
# Temporary re-routing for any pending Stripe payments still using the old return URL
|
||||
match '/checkout', via: :get, controller: "payment_gateways/stripe", action: "confirm",
|
||||
constraints: ->(request) { request["payment_intent"]&.start_with?("pm_") }
|
||||
|
||||
get '/checkout', to: 'checkout#edit'
|
||||
put '/checkout', to: 'checkout#update', as: :update_checkout
|
||||
get '/checkout/:state', to: 'checkout#edit', as: :checkout_state
|
||||
|
||||
24
spec/routing/stripe_spec.rb
Normal file
24
spec/routing/stripe_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
describe "routing for Stripe return URLS", type: :routing do
|
||||
before do
|
||||
allow_any_instance_of(SplitCheckoutConstraint).to receive(:current_user) { build(:user) }
|
||||
end
|
||||
|
||||
it "routes /checkout to checkout#edit" do
|
||||
expect(get: "checkout").
|
||||
to route_to("checkout#edit")
|
||||
end
|
||||
|
||||
it "routes /checkout?test=123 to checkout#edit" do
|
||||
expect(get: "/checkout?test=123").
|
||||
to route_to(controller: "checkout", action: "edit", test: "123")
|
||||
end
|
||||
|
||||
it "routes /checkout?payment_intent=pm_123 to payment_gateways/stripe#confirm" do
|
||||
expect(get: "/checkout?payment_intent=pm_123").
|
||||
to route_to(controller: "payment_gateways/stripe", action: "confirm", payment_intent: "pm_123")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user