Class: CryptocoinPayable::PaymentProcessor
- Inherits:
-
Object
- Object
- CryptocoinPayable::PaymentProcessor
- Defined in:
- lib/cryptocoin_payable/commands/payment_processor.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.perform ⇒ Object
5 6 7 |
# File 'lib/cryptocoin_payable/commands/payment_processor.rb', line 5 def self.perform new.perform end |
.update_transactions_for(payment) ⇒ Object
9 10 11 |
# File 'lib/cryptocoin_payable/commands/payment_processor.rb', line 9 def self.update_transactions_for(payment) new.update_transactions_for(payment) end |
Instance Method Details
#perform ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cryptocoin_payable/commands/payment_processor.rb', line 13 def perform CoinPayment.unconfirmed.find_each do |payment| # Check for completed payment first, in case it's 0 and we don't need to # make an API call. update_payment_state(payment) next if payment.confirmed? begin update_transactions_for(payment) rescue StandardError => error STDERR.puts 'PaymentProcessor: Unknown error encountered, skipping transaction' STDERR.puts error next end # Check for payments after the response comes back. update_payment_state(payment) # If the payment has not moved out of the pending state after loading # new transactions, we expire it. update_payment_expired_state(payment) if payment.pending? end end |
#update_transactions_for(payment) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cryptocoin_payable/commands/payment_processor.rb', line 38 def update_transactions_for(payment) transactions = Adapters.for(payment.coin_type).fetch_transactions(payment.address) payment.transaction do if supports_bulk_insert? update_via_bulk_insert(payment, transactions) else update_via_many_insert(payment, transactions) end end transactions end |