Module: SpreeCmCommissioner::PaymentDecorator
- Defined in:
- app/models/spree_cm_commissioner/payment_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #can_void? ⇒ Boolean
- #check_payment_method? ⇒ Boolean
- #payment_receive_manually? ⇒ Boolean
-
#process! ⇒ Object
order trigger payment.process! when calling order.next.
-
#set_payable ⇒ Object
must set current_user_instance before hand.
Class Method Details
.prepended(base) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'app/models/spree_cm_commissioner/payment_decorator.rb', line 3 def self.prepended(base) base.attr_accessor :current_user_instance base.belongs_to :payable, polymorphic: true, optional: true base.before_save :set_payable base.whitelisted_ransackable_attributes |= %w[payable_id] end |
Instance Method Details
#can_void? ⇒ Boolean
29 30 31 |
# File 'app/models/spree_cm_commissioner/payment_decorator.rb', line 29 def can_void? state.in? i[pending processing completed checkout] end |
#check_payment_method? ⇒ Boolean
25 26 27 |
# File 'app/models/spree_cm_commissioner/payment_decorator.rb', line 25 def check_payment_method? payment_method.is_a?(Spree::PaymentMethod::Check) end |
#payment_receive_manually? ⇒ Boolean
21 22 23 |
# File 'app/models/spree_cm_commissioner/payment_decorator.rb', line 21 def payment_receive_manually? check_payment_method? && payment_method.auto_capture? && order.ticket_seller_user? end |
#process! ⇒ Object
order trigger payment.process! when calling order.next.
15 16 17 18 19 |
# File 'app/models/spree_cm_commissioner/payment_decorator.rb', line 15 def process! return complete! if payment_receive_manually? super end |
#set_payable ⇒ Object
must set current_user_instance before hand
35 36 37 |
# File 'app/models/spree_cm_commissioner/payment_decorator.rb', line 35 def set_payable self.payable = current_user_instance.presence if completed? end |