vinsol/spree-point-of-sale

View on GitHub
app/models/spree/payment_method/point_of_sale.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Spree
  class PaymentMethod::PointOfSale < PaymentMethod

    def actions
      %w{capture void}
    end

    # Indicates whether its possible to capture the payment
    def can_capture?(payment)
      ['checkout', 'pending'].include?(payment.state)
    end

    # Indicates whether its possible to void the payment.
    def can_void?(payment)
      payment.state != 'void'
    end

    def capture(*args)
      simulated_successful_billing_response
    end

    def void(*args)
      simulated_successful_billing_response
    end

    def cancel(*args)
      simulated_successful_billing_response
    end

    def credit(*args)
      simulated_successful_billing_response
    end

    def source_required?
      false
    end

    private
      def simulated_successful_billing_response
        ActiveMerchant::Billing::Response.new(true, "", {}, {})
      end
  end
end