Class: Spree::Mollie::PaymentStateUpdater

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/mollie/payment_state_updater.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mollie_order, payment) ⇒ PaymentStateUpdater

Returns a new instance of PaymentStateUpdater.



8
9
10
11
# File 'app/models/spree/mollie/payment_state_updater.rb', line 8

def initialize(mollie_order, payment)
  @mollie_order = mollie_order
  @payment = payment
end

Instance Attribute Details

#mollie_orderObject (readonly)

Returns the value of attribute mollie_order.



6
7
8
# File 'app/models/spree/mollie/payment_state_updater.rb', line 6

def mollie_order
  @mollie_order
end

#paymentObject (readonly)

Returns the value of attribute payment.



5
6
7
# File 'app/models/spree/mollie/payment_state_updater.rb', line 5

def payment
  @payment
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/spree/mollie/payment_state_updater.rb', line 13

def call
  case mollie_order.status

  when 'created'
     transition_to_created!
  when 'expired'
     transition_to_failed!
  when 'authorized'
     transition_to_pending!
  when 'paid', 'completed'
     transition_to_complete!
  when 'canceled'
     transition_to_void!
  when 'shipping'
     transition_to_shipping!
  else
    MollieLogger.debug("Unhandled Mollie payment state received: #{mollie_order.status}. Therefore we did not update the payment state.")
  end

end