mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Extract #load_checkout_order
This commit is contained in:
@@ -54,9 +54,8 @@ class CheckoutController < ::BaseController
|
||||
end
|
||||
|
||||
def load_order
|
||||
@order = current_order
|
||||
load_checkout_order
|
||||
|
||||
return order_invalid! if order_invalid_for_checkout?
|
||||
return handle_invalid_stock unless valid_order_line_items?
|
||||
|
||||
before_address
|
||||
|
||||
@@ -31,6 +31,12 @@ module OrderCompletion
|
||||
new_order.tokenized_permission.save!
|
||||
end
|
||||
|
||||
def load_checkout_order
|
||||
@order = current_order
|
||||
|
||||
order_invalid! if order_invalid_for_checkout?
|
||||
end
|
||||
|
||||
def order_completion_route
|
||||
main_app.order_path(@order, order_token: @order.token)
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ module PaymentGateways
|
||||
|
||||
before_action :enable_embedded_shopfront
|
||||
before_action :destroy_orphaned_paypal_payments, only: :confirm
|
||||
before_action :load_order, only: [:express, :confirm]
|
||||
before_action :load_checkout_order, only: [:express, :confirm]
|
||||
before_action :handle_insufficient_stock, only: [:express, :confirm]
|
||||
before_action :permit_parameters!
|
||||
|
||||
@@ -60,12 +60,6 @@ module PaymentGateways
|
||||
|
||||
private
|
||||
|
||||
def load_order
|
||||
@order = current_order
|
||||
|
||||
order_invalid! if order_invalid_for_checkout?
|
||||
end
|
||||
|
||||
def express_checkout_request_details(order)
|
||||
{
|
||||
SetExpressCheckoutRequestDetails: {
|
||||
|
||||
@@ -4,24 +4,18 @@ class StripeController < BaseController
|
||||
include OrderStockCheck
|
||||
include OrderCompletion
|
||||
|
||||
before_action :load_order, only: :confirm
|
||||
before_action :load_checkout_order, only: :confirm
|
||||
|
||||
def confirm
|
||||
return processing_failed unless valid_payment_intent?
|
||||
|
||||
cancel_incomplete_payments && handle_insufficient_stock unless sufficient_stock?
|
||||
|
||||
process_payment_completion!
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_order
|
||||
@order = current_order
|
||||
|
||||
return order_invalid! if order_invalid_for_checkout?
|
||||
|
||||
(cancel_incomplete_payments && handle_insufficient_stock) unless sufficient_stock?
|
||||
end
|
||||
|
||||
def valid_payment_intent?
|
||||
@valid_payment_intent ||= begin
|
||||
return false unless params["payment_intent"]&.starts_with?("pi_")
|
||||
|
||||
Reference in New Issue
Block a user