Class: SpreeAdyen::CheckoutPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/spree_adyen/checkout_presenter.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(payment_session) ⇒ CheckoutPresenter

Returns a new instance of CheckoutPresenter.



5
6
7
# File 'app/presenters/spree_adyen/checkout_presenter.rb', line 5

def initialize(payment_session)
  @payment_session = payment_session
end

Instance Method Details

#to_hObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/presenters/spree_adyen/checkout_presenter.rb', line 13

def to_h
  @to_h ||= {
    session: {
      id: payment_session.adyen_id,
      sessionData: payment_session.adyen_data
    },
    environment: payment_session.payment_method.environment,

    amount: {
      value: Spree::Money.new(payment_session.amount, currency: currency).cents,
      currency: currency
    },
    countryCode: country_iso,
    locale: locale,
    clientKey: payment_session.payment_method.preferred_client_key,
    showPayButton: true
  }
end

#to_json(*_args) ⇒ Object



9
10
11
# File 'app/presenters/spree_adyen/checkout_presenter.rb', line 9

def to_json(*_args)
  @to_json ||= to_h.to_json
end