Sha256: f3fb6bb37d57d59387bf7973593c31947e764624448b9537341a3c20dc1c4183

Contents?: true

Size: 852 Bytes

Versions: 5

Compression:

Stored size: 852 Bytes

Contents

module SpreeGateway
  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(::SpreeGateway::OrderDecorator)

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
spree_gateway-3.11.0 app/models/spree_gateway/order_decorator.rb
spree_gateway-3.10.0 app/models/spree_gateway/order_decorator.rb
archetype_spree_gateway-3.9.5.1 app/models/spree_gateway/order_decorator.rb
archetype_spree_gateway-3.9.5 app/models/spree_gateway/order_decorator.rb
spree_gateway-3.9.4 app/models/spree_gateway/order_decorator.rb