diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 6b0f08ba99..8567f30502 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -148,12 +148,14 @@ class CheckoutController < ::BaseController end def valid_payment_intent_provided? - return false unless params["payment_intent"]&.starts_with?("pi_") + @valid_payment_intent_provided ||= begin + return false unless params["payment_intent"]&.starts_with?("pi_") - last_payment = OrderPaymentFinder.new(@order).last_payment - @order.state == "payment" && - last_payment&.state == "requires_authorization" && - last_payment&.response_code == params["payment_intent"] + last_payment = OrderPaymentFinder.new(@order).last_payment + @order.state == "payment" && + last_payment&.state == "requires_authorization" && + last_payment&.response_code == params["payment_intent"] + end end def handle_redirect_from_stripe