Sha256: 2d9e91da322f4aa222b4e3e1244b6ce3cb4e2f7e9255d4e729bddab9d6b616ee

Contents?: true

Size: 1002 Bytes

Versions: 9

Compression:

Stored size: 1002 Bytes

Contents

Spree::Payment::Processing.module_eval do
  def process!(_amount = nil)
    if payment_method.is_a? Spree::Gateway::MollieGateway
      process_with_mollie
    else
      process_with_spree
    end
  end

  def cancel!
    if payment_method.is_a? Spree::Gateway::MollieGateway
      cancel_with_mollie
    else
      cancel_with_spree
    end
  end

  private

  def cancel_with_spree
    response = payment_method.cancel(response_code)
    handle_response(response, :void, :failure)
  end

  def cancel_with_mollie
    response = payment_method.cancel(transaction_id)
    handle_response(response, :void, :failure)
  end

  def process_with_spree
    if payment_method && payment_method.auto_capture?
      purchase!
    else
      authorize!
    end
  end

  def process_with_mollie
    amount ||= money.money
    started_processing!
    response = payment_method.process(
      amount,
      source,
      gateway_options
    )
    handle_response(response, :started_processing, :failure)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spree_mollie_gateway-3.2.1 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-3.2.0 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-3.1.0 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-3.0.4 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-3.0.3 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-3.0.2 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-3.0.1 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-3.0.0 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-3.0.0.pre.beta app/models/spree/payment/processing_decorator.rb