Sha256: 648b0bf795f77383d2501817c4e621c6e749385b3480935179fd227ca71e4633

Contents?: true

Size: 834 Bytes

Versions: 3

Compression:

Stored size: 834 Bytes

Contents

module Spree
  module OrderDecorator
    def self.prepended(base)
      return if base.checkout_steps.key?(:payment_confirm)

      base.insert_checkout_step(
        :payment_confirm,
        before: :complete,
        if: ->(order) { order.intents? }
      )
    end

    def process_payments!
      # Payments are processed in confirm_payment step where after successful
      # 3D Secure authentication `intent_client_key` is saved for payment.
      # In case authentication is unsuccessful, `intent_client_key` is removed.
      return if intents? && payments.valid.last.intent_client_key.present?

      super
    end

    def intents?
      payments.valid.map { |p| p.payment_method&.has_preference?(:intents) && p.payment_method&.get_preference(:intents) }.any?
    end
  end
end

Spree::Order.prepend(Spree::OrderDecorator)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_gateway-3.9.3 app/models/spree/order_decorator.rb
spree_gateway-3.9.2 app/models/spree/order_decorator.rb
spree_gateway-3.9.0 app/models/spree/order_decorator.rb