Sha256: fc3536fde8cec8ab04275d35082e7108875ecad01571b789fadd7c67f853366c

Contents?: true

Size: 1004 Bytes

Versions: 5

Compression:

Stored size: 1004 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.create_transaction(
        amount,
        source,
        gateway_options
    )
    handle_response(response, :pend, :failure)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_mollie_gateway-2.1.5 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-2.1.4 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-2.1.4.pre.alpha app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-2.1.3 app/models/spree/payment/processing_decorator.rb
spree_mollie_gateway-2.1.2 app/models/spree/payment/processing_decorator.rb