Module: Spree::Adyen::Payment

Extended by:
ActiveSupport::Concern
Includes:
HppCheck
Defined in:
app/models/concerns/spree/adyen/payment.rb

Instance Method Summary collapse

Methods included from HppCheck

#hpp_payment?

Instance Method Details

#cancel!Object

cancel!

bool | error

Borrowed from handle_void_response, this has been modified so that it won’t actually void the payment yet.



47
48
49
50
51
52
53
54
55
56
57
# File 'app/models/concerns/spree/adyen/payment.rb', line 47

def cancel!
  if hpp_payment?
    if source.requires_manual_refund?
      log_manual_refund
    else
      process { payment_method.cancel response_code }
    end
  else
    super
  end
end

#capture!Object

capture!

bool | error



12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/concerns/spree/adyen/payment.rb', line 12

def capture!
  if hpp_payment?
    amount = money.money.cents
    process do
      payment_method.send(
        :capture, amount, response_code, gateway_options)
    end
  else
    super
  end
end

#credit!(amount, options) ⇒ Object

credit!

bool | error

Issue a request to credit the payment, this does NOT perform validation on the amount to be credited, which is assumed to have been done prior to this.

credit! is only implemented for hpp payments, because of the delayed manner of Adyen api communications. If this method is called on a payment that is not from Adyen then it should fail. This is crummy way of getting around the fact that Payment methods cannot specifiy these methods.



35
36
37
38
39
40
41
# File 'app/models/concerns/spree/adyen/payment.rb', line 35

def credit! amount, options
  if hpp_payment?
    process { payment_method.credit(amount, response_code, options) }
  else
    fail NotImplementedError, "Spree::Payment does not implement credit!"
  end
end