Sha256: d07ed1a483027acaeca7d2833246e727b46daac56810af6cca6f320d05936a22

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

Spree::Payment.class_eval do
  def transaction_id
    if payment_method.is_a? Spree::Gateway::MollieGateway
      source.transaction_id
    else
      response_code
    end
  end

  def build_source
    return unless new_record?

    if source_attributes.present? && source.blank? && payment_method.try(:payment_source_class)
      self.source = payment_method.payment_source_class.new(source_attributes)
      source.payment_method_id = payment_method.id
      source.user_id = order.user_id if order

      # Spree will not process payments if order is completed.
      # We should call process! for completed orders to create a new Mollie payment.
      process! if order.completed?
    end
  end

  def authorized?
    if source.is_a? Spree::MolliePaymentSource
      pending?
    else
      false
    end
  end

  def after_pay_method?
    if source.is_a? Spree::MolliePaymentSource
      return source.payment_method_name == ::Mollie::Method::KLARNAPAYLATER || source.payment_method_name == ::Mollie::Method::KLARNASLICEIT
    else
      false
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spree_mollie_gateway-3.2.1 app/models/spree/payment_decorator.rb
spree_mollie_gateway-3.2.0 app/models/spree/payment_decorator.rb
spree_mollie_gateway-3.1.0 app/models/spree/payment_decorator.rb
spree_mollie_gateway-3.0.4 app/models/spree/payment_decorator.rb
spree_mollie_gateway-3.0.3 app/models/spree/payment_decorator.rb
spree_mollie_gateway-3.0.2 app/models/spree/payment_decorator.rb
spree_mollie_gateway-3.0.1 app/models/spree/payment_decorator.rb