Sha256: b7c61679a464f0e378d25e0586c67385ce17e1c5941e50b429e6347242d56445

Contents?: true

Size: 810 Bytes

Versions: 22

Compression:

Stored size: 810 Bytes

Contents

# This class is responsible for building a default payment on an order, using a
# payment source that is already in the user's "wallet" and is marked
# as being the default payment source.
class Spree::Wallet::DefaultPaymentBuilder
  def initialize(order)
    @order = order
  end

  # Build a payment to be added to an order prior to moving into the "payment"
  # state.
  #
  # @return [Payment] the unsaved payment to be added, or nil if none.
  def build
    default = order.user.try!(:wallet).try!(:default_wallet_payment_source)
    if default && order.payments.where(source_type: default.payment_source_type).none?
      Spree::Payment.new(
        payment_method: default.payment_source.payment_method,
        source: default.payment_source,
      )
    end
  end

  private

  attr_reader :order
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
solidus_core-2.5.2 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.5.1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.5.0 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.5.0.rc1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.5.0.beta2 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.5.0.beta1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.4.2 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.3.1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.4.1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.2.2 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.4.0 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.4.0.rc1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.4.0.beta1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.3.0 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.3.0.rc3 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.3.0.rc2 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.3.0.rc1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.3.0.beta1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.2.1 app/models/spree/wallet/default_payment_builder.rb
solidus_core-2.2.0 app/models/spree/wallet/default_payment_builder.rb