Class: SpreeAdyen::PaymentSessions::RequestPayloadPresenter

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

Constant Summary collapse

DEFAULT_PARAMS =
{
  recurringProcessingModel: 'UnscheduledCardOnFile',
  shopperInteraction: 'Ecommerce',
  storePaymentMethodMode: 'enabled'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(order:, amount:, user:, merchant_account:, payment_method:, channel:, return_url:) ⇒ RequestPayloadPresenter

Returns a new instance of RequestPayloadPresenter.



10
11
12
13
14
15
16
17
18
# File 'app/presenters/spree_adyen/payment_sessions/request_payload_presenter.rb', line 10

def initialize(order:, amount:, user:, merchant_account:, payment_method:, channel:, return_url:)
  @order = order
  @amount = amount
  @user = user
  @merchant_account = 
  @payment_method = payment_method
  @channel = channel
  @return_url = return_url
end

Instance Method Details

#to_hObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/presenters/spree_adyen/payment_sessions/request_payload_presenter.rb', line 20

def to_h
  {
    metadata: { # unfortunately metadata is not always available in webhooks, even for AUTHORISATION events
      spree_payment_method_id: payment_method.id,
      spree_order_id: order_number
    },
    amount: {
      value: Spree::Money.new(amount, currency: currency).cents,
      currency: currency
    },
    returnUrl: return_url,
    reference: reference,
    countryCode: country_iso,
    lineItems: line_items,
    merchantAccount: ,
    merchantOrderReference: order_number,
    expiresAt: expires_at
  }.merge!(shopper_details, DEFAULT_PARAMS, channel_params, additional_data_params, SpreeAdyen::ApplicationInfoPresenter.new.to_h)
end