Class: Spree::PagseguroCheckout

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spree/pagseguro_checkout.rb

Instance Method Summary collapse

Instance Method Details

#process!Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/spree/pagseguro_checkout.rb', line 7

def process!
  payments.pending.each do |payment|
    raise RuntimeError.new('Payment and Order not belongs to same transaction') unless payment.order.id === transaction.reference.to_i

    case
      when status_paid? then payment.complete!
      when status_cancelled?
        payment.failure
        payment.order.cancel!
    end
  end
end