Class: Gateway::AdyenHPP

Inherits:
Gateway
  • Object
show all
Defined in:
app/models/spree/gateway/adyen_hpp.rb

Overview

Gateway for Adyen Hosted Payment Pages solution

Instance Method Summary collapse

Instance Method Details

#authorize(amount, source, gateway_options) ⇒ Object



47
48
49
50
51
52
53
# File 'app/models/spree/gateway/adyen_hpp.rb', line 47

def authorize(amount, source, gateway_options)
  # to get around the order checking for processed payments we create payments
  # in the checkout state and allow the payment method to attempt to auth
  # them here. We just return a dummy response here because the payment has
  # already been authorized
  ActiveMerchant::Billing::Response.new(true, "successful hpp payment")
end

#cancel(psp_reference, _gateway_options = {}) ⇒ Object



63
64
65
66
67
# File 'app/models/spree/gateway/adyen_hpp.rb', line 63

def cancel(psp_reference, _gateway_options = {})
  handle_response(
    provider.cancel_or_refund_payment(psp_reference),
    psp_reference)
end

#capture(amount, psp_reference, currency:, **_opts) ⇒ Object



55
56
57
58
59
60
61
# File 'app/models/spree/gateway/adyen_hpp.rb', line 55

def capture(amount, psp_reference, currency:, **_opts)
  value = { currency: currency, value: amount }

  handle_response(
    provider.capture_payment(psp_reference, value),
    psp_reference)
end

#credit(amount, psp_reference, currency:, **_opts) ⇒ Object



69
70
71
72
73
74
75
# File 'app/models/spree/gateway/adyen_hpp.rb', line 69

def credit(amount, psp_reference, currency:, **_opts)
  amount = { currency: currency, value: amount }

  handle_response(
    provider.refund_payment(psp_reference, amount),
    psp_reference)
end

#merchant_accountObject



12
13
14
# File 'app/models/spree/gateway/adyen_hpp.rb', line 12

def 
  ENV["ADYEN_MERCHANT_ACCOUNT"] || 
end

#method_typeObject



31
32
33
# File 'app/models/spree/gateway/adyen_hpp.rb', line 31

def method_type
  "adyen"
end

#providerObject



20
21
22
23
24
25
26
27
28
29
# File 'app/models/spree/gateway/adyen_hpp.rb', line 20

def provider
  ::Adyen.configuration.api_username =
    (ENV["ADYEN_API_USERNAME"] || preferred_api_username)
  ::Adyen.configuration.api_password =
    (ENV["ADYEN_API_PASSWORD"] || preferred_api_password)
  ::Adyen.configuration.default_api_params[:merchant_account] =
    

  provider_class
end

#provider_classObject



16
17
18
# File 'app/models/spree/gateway/adyen_hpp.rb', line 16

def provider_class
  ::Adyen::API
end

#restricted_brand_codesObject



77
78
79
# File 'app/models/spree/gateway/adyen_hpp.rb', line 77

def restricted_brand_codes
  preferred_restricted_brand_codes.split(',').compact.uniq
end

#shared_secretObject



35
36
37
# File 'app/models/spree/gateway/adyen_hpp.rb', line 35

def shared_secret
  ENV["ADYEN_SHARED_SECRET"] || preferred_shared_secret
end

#ship_before_dateObject



43
44
45
# File 'app/models/spree/gateway/adyen_hpp.rb', line 43

def ship_before_date
  preferred_days_to_ship.days.from_now
end

#skin_codeObject



39
40
41
# File 'app/models/spree/gateway/adyen_hpp.rb', line 39

def skin_code
  ENV["ADYEN_SKIN_CODE"] || preferred_skin_code
end