Sha256: 3c13039c96fd6648962b9bd55f3c64c53d30425145be6fb906357d7d33b6358b

Contents?: true

Size: 422 Bytes

Versions: 102

Compression:

Stored size: 422 Bytes

Contents

module Spree
  module Checkout
    class RemoveStoreCredit
      prepend Spree::ServiceModule::Base

      def call(order:)
        return failed unless order

        ApplicationRecord.transaction do
          order.payments.checkout.store_credits.map(&:invalidate!) unless order.completed?
        end

        order.reload.payments.store_credits.valid.any? ? failure(order) : success(order)
      end
    end
  end
end

Version data entries

102 entries across 102 versions & 1 rubygems

Version Path
spree_core-4.10.1 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.10.0 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.9.0 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.8.3 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.8.2 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.7.3 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.6.6 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.5.5 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.0.9 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.1.15 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.2.7 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.3.3 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.4.1 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.5.4 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.6.5 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.7.2 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.7.1 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.6.4 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.7.0 app/services/spree/checkout/remove_store_credit.rb
spree_core-4.6.3 app/services/spree/checkout/remove_store_credit.rb