Class: SolidusAfterpay::OrderComponentBuilder

Inherits:
Object
  • Object
show all
Defined in:
app/models/solidus_afterpay/order_component_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order:, mode: nil, redirect_confirm_url: nil, redirect_cancel_url: nil, popup_origin_url: nil) ⇒ OrderComponentBuilder

Returns a new instance of OrderComponentBuilder.



9
10
11
12
13
14
15
# File 'app/models/solidus_afterpay/order_component_builder.rb', line 9

def initialize(order:, mode: nil, redirect_confirm_url: nil, redirect_cancel_url: nil, popup_origin_url: nil)
  @order = order
  @mode = mode
  @redirect_confirm_url = redirect_confirm_url
  @redirect_cancel_url = redirect_cancel_url
  @popup_origin_url = popup_origin_url
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.



7
8
9
# File 'app/models/solidus_afterpay/order_component_builder.rb', line 7

def mode
  @mode
end

#orderObject (readonly)

Returns the value of attribute order.



7
8
9
# File 'app/models/solidus_afterpay/order_component_builder.rb', line 7

def order
  @order
end

Returns the value of attribute popup_origin_url.



7
8
9
# File 'app/models/solidus_afterpay/order_component_builder.rb', line 7

def popup_origin_url
  @popup_origin_url
end

#redirect_cancel_urlObject (readonly)

Returns the value of attribute redirect_cancel_url.



7
8
9
# File 'app/models/solidus_afterpay/order_component_builder.rb', line 7

def redirect_cancel_url
  @redirect_cancel_url
end

#redirect_confirm_urlObject (readonly)

Returns the value of attribute redirect_confirm_url.



7
8
9
# File 'app/models/solidus_afterpay/order_component_builder.rb', line 7

def redirect_confirm_url
  @redirect_confirm_url
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/solidus_afterpay/order_component_builder.rb', line 17

def call
  ::Afterpay::Components::Order.new(
    amount: amount,
    mode: mode,
    consumer: consumer,
    billing: address(order.billing_address),
    shipping: address(order.shipping_address),
    merchant: merchant,
    items: items,
    merchant_reference: order.number
  )
end