Class: Spree::PaypalAccount

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spree/paypal_account.rb

Instance Method Summary collapse

Instance Method Details

#actionsObject



5
6
7
# File 'app/models/spree/paypal_account.rb', line 5

def actions
  %w{capture credit}
end

#can_capture?(payment) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/models/spree/paypal_account.rb', line 9

def can_capture?(payment)
  !echeck?(payment) && payment.state == "pending"
end

#can_credit?(payment) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
# File 'app/models/spree/paypal_account.rb', line 13

def can_credit?(payment)
  return false unless payment.state == "completed"
  return false unless payment.order.payment_state == "credit_owed"
  payment.credit_allowed > 0
  !payment.payment_method.find_capture(payment).nil?
end

#echeck?(payment) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
# File 'app/models/spree/paypal_account.rb', line 25

def echeck?(payment)
  logs = payment.log_entries.all(:order => 'created_at DESC')
  logs.each do |log|
    details = YAML.load(log.details) # return the transaction details
    if details.params['payment_type'] == 'echeck'
      return true
    end
  end
  return false
end

#payment_gatewayObject

fix for Payment#payment_profiles_supported?



21
22
23
# File 'app/models/spree/paypal_account.rb', line 21

def payment_gateway
  false
end