do transition :from => 'cart', :to => 'address' transition :from => 'address', :to => 'delivery' transition :from => 'delivery', :to => 'payment', :if => :payment_required? transition :from => 'delivery', :to => 'complete' transition :from => 'confirm', :to => 'complete' transition :from => 'payment', :to => 'confirm', :if => Proc.new { |order| order.payment_method && order.payment_method.payment_profiles_supported? } transition :from => 'payment', :to => 'complete' end event :cancel { transition :to => 'canceled', :if => :allow_cancel? } event :return { transition :to => 'returned', :from => 'awaiting_return' } event :resume { transition :to => 'resumed', :from => 'canceled', :if => :allow_resume? } event :authorize_return { transition :to => 'awaiting_return' } before_transition :to => 'complete' { |order| order.process_payments! } before_transition :to => ['delivery'] do |order| order.shipments.each { |s| s.destroy unless s.shipping_method.available_to_order?(order) } end after_transition :to => 'complete', :do => :finalize! after_transition :to => 'delivery', :do => :create_tax_charge! after_transition :to => 'payment', :do => :create_shipment! after_transition :to => 'resumed', :do => :after_resume after_transition :to => 'canceled', :do => :after_cancel end