mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Skip address setup logic if we're coming from Stripe
The code here runs from a callback which was originally designed to make sure the checkout page was set up correctly in the "normal" checkout workflow. It wasn't really designed to be run when the page is being loaded a second time due to the user being redirected back from Stripe (with SCA). The things it's doing here are necessary in the former case, but a really bad idea in the latter (potentially messing up the order's ship and bill addresses in certain cases like guest checkout).
This commit is contained in:
@@ -84,6 +84,8 @@ class CheckoutController < ::BaseController
|
||||
redirect_to(main_app.shop_path) && return if redirect_to_shop?
|
||||
handle_invalid_stock && return unless valid_order_line_items?
|
||||
|
||||
return if valid_payment_intent_provided?
|
||||
|
||||
before_address
|
||||
setup_for_current_state
|
||||
end
|
||||
|
||||
@@ -210,6 +210,12 @@ describe CheckoutController, type: :controller do
|
||||
expect(response).to redirect_to order_path(order)
|
||||
end
|
||||
|
||||
it "does not attempt to load different addresses" do
|
||||
expect(OpenFoodNetwork::AddressFinder).to_not receive(:new)
|
||||
|
||||
get :edit, params: { payment_intent: "pi_123" }
|
||||
end
|
||||
|
||||
it "creates a customer record" do
|
||||
order.update_columns(customer_id: nil)
|
||||
Customer.delete_all
|
||||
|
||||
Reference in New Issue
Block a user