Class: Spree::OrderCapturing
- Inherits:
-
Object
- Object
- Spree::OrderCapturing
- Defined in:
- app/models/spree/order_capturing.rb
Instance Method Summary collapse
- #capture_payments ⇒ Object
-
#initialize(order, sorted_payment_method_classes = nil) ⇒ OrderCapturing
constructor
A new instance of OrderCapturing.
Constructor Details
#initialize(order, sorted_payment_method_classes = nil) ⇒ OrderCapturing
Returns a new instance of OrderCapturing.
13 14 15 16 17 18 |
# File 'app/models/spree/order_capturing.rb', line 13 def initialize(order, sorted_payment_method_classes = nil) Spree::Deprecation.warn "Spree::OrderCapturing is deprecated and will be removed without replacement. " \ "Please implement your own automated capturing logic in your store." @order = order @sorted_payment_method_classes = sorted_payment_method_classes || Spree::OrderCapturing.sorted_payment_method_classes end |
Instance Method Details
#capture_payments ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/spree/order_capturing.rb', line 20 def capture_payments return if @order.paid? Spree::OrderMutex.with_lock!(@order) do uncaptured_amount = @order.display_total.cents sorted_payments(@order).each do |payment| amount = [uncaptured_amount, payment.money.cents].min if amount > 0 payment.capture!(amount) uncaptured_amount -= amount elsif Spree::OrderCapturing.void_unused_payments payment.void_transaction! end end end end |