3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'app/models/spree_loyalty_points/payment_decorator.rb', line 3
def self.prepended(base)
base.include Spree::LoyaltyPoints
base.include Spree::Payment::LoyaltyPoints
base.validates :amount, numericality: { greater_than: 0 }, if: :by_loyalty_points?
base.validate :redeemable_user_balance, if: :by_loyalty_points?
base.scope :state_not, ->(s) { where('state != ?', s) }
fsm = base.state_machines[:state]
fsm.after_transition from: fsm.states.map(&:name) - [:completed], to: [:completed], do: :notify_paid_order
fsm.after_transition from: fsm.states.map(&:name) - [:completed], to: [:completed], do: :redeem_loyalty_points, if: :by_loyalty_points?
fsm.after_transition from: [:completed], to: fsm.states.map(&:name) - [:completed], do: :return_loyalty_points, if: :by_loyalty_points?
end
|