Class: Spree::Paysera::BuildForm

Inherits:
Object
  • Object
show all
Defined in:
app/domain/spree/paysera/build_form.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payment_method, order) ⇒ BuildForm

Returns a new instance of BuildForm.



12
13
14
15
# File 'app/domain/spree/paysera/build_form.rb', line 12

def initialize(payment_method, order)
  @payment_method = payment_method
  @order = order
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



6
7
8
# File 'app/domain/spree/paysera/build_form.rb', line 6

def order
  @order
end

#payment_methodObject (readonly)

Returns the value of attribute payment_method.



6
7
8
# File 'app/domain/spree/paysera/build_form.rb', line 6

def payment_method
  @payment_method
end

Class Method Details

.for(payment_method, order) ⇒ Object



8
9
10
# File 'app/domain/spree/paysera/build_form.rb', line 8

def self.for(payment_method, order)
  new(payment_method, order).run
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/domain/spree/paysera/build_form.rb', line 17

def run
  @result = {}

  add_gateway_details
  add_order_details

  form = Spree::PayseraForm.new(@result)
  raise Spree::Paysera::Error, 'Params are not valid' unless form.valid?

  form
end