Class: Spree::Adyen::HppSource

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

Constant Summary collapse

MANUALLY_REFUNDABLE =
[
  "directEbanking"
].freeze
PENDING =
"PENDING".freeze
AUTHORISED =
"AUTHORISED".freeze
REFUSED =
"REFUSED".freeze
CANCELLED =
"CANCELLED".freeze

Instance Method Summary collapse

Instance Method Details

#actionsObject



49
50
51
52
53
54
55
# File 'app/models/spree/adyen/hpp_source.rb', line 49

def actions
  if mutable?
    authorised_actions
  else
    []
  end
end

#authorised?Boolean

Returns:

  • (Boolean)


65
66
67
68
69
# File 'app/models/spree/adyen/hpp_source.rb', line 65

def authorised?
  # Many banks return pending, this is considered a valid response and
  # the order should proceed.
  [PENDING, AUTHORISED].include? auth_result
end

#can_cancel?(payment) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/models/spree/adyen/hpp_source.rb', line 57

def can_cancel? payment
  payment.refunds.empty?
end

#can_capture?(payment) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'app/models/spree/adyen/hpp_source.rb', line 45

def can_capture? payment
  payment.uncaptured_amount != 0.0
end

#requires_manual_refund?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/models/spree/adyen/hpp_source.rb', line 61

def requires_manual_refund?
  MANUALLY_REFUNDABLE.include?(payment_method)
end