Class: SpreeAdyen::PaymentSetupSessions::RequestPayloadPresenter

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

Overview

Builds the payload for a zero-auth (tokenization-only) Adyen Sessions API request. Used to vault a payment method without charging the customer — Adyen returns an AUTHORISATION webhook with the stored payment method ID in additionalData.

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(customer:, merchant_account:, payment_method:, channel:, return_url:, currency: nil) ⇒ RequestPayloadPresenter

Returns a new instance of RequestPayloadPresenter.



15
16
17
18
19
20
21
22
# File 'app/presenters/spree_adyen/payment_setup_sessions/request_payload_presenter.rb', line 15

def initialize(customer:, merchant_account:, payment_method:, channel:, return_url:, currency: nil)
  @customer = customer
  @merchant_account = 
  @payment_method = payment_method
  @channel = channel
  @return_url = return_url
  @currency = currency || DEFAULT_CURRENCY
end

Instance Method Details

#to_hObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/presenters/spree_adyen/payment_setup_sessions/request_payload_presenter.rb', line 24

def to_h
  {
    metadata: {
      spree_payment_method_id: payment_method.id,
      spree_setup_session: true
    },
    amount: {
      value: 0,
      currency: currency
    },
    returnUrl: return_url,
    reference: reference,
    merchantAccount: ,
    expiresAt: expires_at
  }.merge!(shopper_details, DEFAULT_PARAMS, channel_params, SpreeAdyen::ApplicationInfoPresenter.new.to_h)
end