Module: Spree::Adyen::Admin::RefundsController

Extended by:
ActiveSupport::Concern
Includes:
HppCheck
Defined in:
app/controllers/concerns/spree/adyen/admin/refunds_controller.rb

Instance Method Summary collapse

Methods included from HppCheck

#hpp_payment?

Instance Method Details

#adyen_createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/concerns/spree/adyen/admin/refunds_controller.rb', line 12

def adyen_create
  if hpp_payment?(@payment)
    # this sucks, but the attributes are not assigned until after
    # callbacks if we're here we aren't going down the normal flow
    # anyways
    @refund.attributes = permitted_resource_params

    # early exit if @refund is invalid, .create will have the error
    # messages
    return if @refund.invalid?

    @payment.refunds.reset # we don't want to save the refund
    @payment.credit!(cents, currency: currency)

    respond
  end
end