Module: Order::PaymentTransitions

Included in:
Order
Defined in:
app/models/order/payment_transitions.rb

Instance Method Summary collapse

Instance Method Details

#after_authorize(transition) ⇒ Object



32
33
34
35
36
37
38
39
# File 'app/models/order/payment_transitions.rb', line 32

def after_authorize(transition)
  mailer = Nimbleshop.config.mailer.constantize
  mailer.delay.order_notification_to_buyer(number)
  AdminMailer.delay.new_order_notification(number)

  mark_as_purchased!
  shipping_pending!
end

#after_kapture(order, transition) ⇒ Object



41
42
# File 'app/models/order/payment_transitions.rb', line 41

def after_kapture(order, transition)
end

#after_pending(transition) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'app/models/order/payment_transitions.rb', line 44

def after_pending(transition)
  if payment_method.is_a? NimbleshopCod::Cod
    mailer = Nimbleshop.config.mailer.constantize
    mailer.order_notification_to_buyer(number).deliver
    AdminMailer.delay.new_order_notification(number)
  end

  mark_as_purchased!
  shipping_pending!
end

#after_purchase(transition) ⇒ Object

Ideally what to do after state transition should be pushed to individual payment method. In this way we will not have the if condition that we are seeing in after_pending .



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/models/order/payment_transitions.rb', line 18

def after_purchase(transition)
  self.mark_as_purchased!

  # do not use bang version because the order might already bbe in shipping_pending state. That is possible
  # if user used splitable in which case the order is put in shipping_pending state in pending state.
  self.shipping_pending

  ActiveSupport::Notifications.instrument("order.purchased", { order_number: number } )

  mailer = Nimbleshop.config.mailer.constantize
  mailer.delay.order_notification_to_buyer(number)
  AdminMailer.delay.new_order_notification(number)
end

#after_refund(order, transition) ⇒ Object



58
59
# File 'app/models/order/payment_transitions.rb', line 58

def after_refund(order, transition)
end

#after_void(order, transition) ⇒ Object



55
56
# File 'app/models/order/payment_transitions.rb', line 55

def after_void(order, transition)
end