Class: Spree::Paysera::CompleteOrder

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, payment_method, params) ⇒ CompleteOrder

Returns a new instance of CompleteOrder.



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

def initialize(order, payment_method, params)
  @order = order
  @payment_method = payment_method
  @order_total = order.total.to_money
  @payamount = params[:payamount].to_money / 100
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'app/domain/spree/paysera/complete_order.rb', line 4

def order
  @order
end

#order_totalObject (readonly)

Returns the value of attribute order_total.



4
5
6
# File 'app/domain/spree/paysera/complete_order.rb', line 4

def order_total
  @order_total
end

#payamountObject (readonly)

Returns the value of attribute payamount.



4
5
6
# File 'app/domain/spree/paysera/complete_order.rb', line 4

def payamount
  @payamount
end

#payment_methodObject (readonly)

Returns the value of attribute payment_method.



4
5
6
# File 'app/domain/spree/paysera/complete_order.rb', line 4

def payment_method
  @payment_method
end

Class Method Details

.for(order, payment_method, params) ⇒ Object



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

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

Instance Method Details

#runObject



17
18
19
20
21
22
# File 'app/domain/spree/paysera/complete_order.rb', line 17

def run
  return if order.paid?

  check_payammount!
  complete_order
end