Class: Gateway::AdyenHPP
- Inherits:
-
Gateway
- Object
- Gateway
- Gateway::AdyenHPP
- Defined in:
- app/models/spree/gateway/adyen_hpp.rb
Overview
Gateway for Adyen Hosted Payment Pages solution
Instance Method Summary collapse
- #authorize(amount, source, gateway_options) ⇒ Object
- #cancel(psp_reference, _gateway_options = {}) ⇒ Object
- #capture(amount, psp_reference, currency:, **_opts) ⇒ Object
- #credit(amount, psp_reference, currency:, **_opts) ⇒ Object
- #merchant_account ⇒ Object
- #method_type ⇒ Object
- #provider ⇒ Object
- #provider_class ⇒ Object
- #restricted_brand_codes ⇒ Object
- #shared_secret ⇒ Object
- #ship_before_date ⇒ Object
- #skin_code ⇒ Object
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 (amount, source, ) # 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, = {}) 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_account ⇒ Object
12 13 14 |
# File 'app/models/spree/gateway/adyen_hpp.rb', line 12 def merchant_account ENV["ADYEN_MERCHANT_ACCOUNT"] || preferred_merchant_account end |
#method_type ⇒ Object
31 32 33 |
# File 'app/models/spree/gateway/adyen_hpp.rb', line 31 def method_type "adyen" end |
#provider ⇒ Object
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] = merchant_account provider_class end |
#provider_class ⇒ Object
16 17 18 |
# File 'app/models/spree/gateway/adyen_hpp.rb', line 16 def provider_class ::Adyen::API end |
#restricted_brand_codes ⇒ Object
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_secret ⇒ Object
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_date ⇒ Object
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_code ⇒ Object
39 40 41 |
# File 'app/models/spree/gateway/adyen_hpp.rb', line 39 def skin_code ENV["ADYEN_SKIN_CODE"] || preferred_skin_code end |