Sha256: 4ae02163231a828b66eea7478825eb3f81f2715fa3fcadbfd788b3dbb0c5a635

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

module Spree::PaymentDecorator
  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

Spree::Payment.prepend(Spree::PaymentDecorator)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_mollie_gateway-4.0.1 app/models/spree/payment_decorator.rb
spree_mollie_gateway-4.0.0 app/models/spree/payment_decorator.rb