Sha256: 3cfa0d37ebe01bfee56337750ea26865624e60197eb9a87d822c0c8746f51c76

Contents?: true

Size: 712 Bytes

Versions: 7

Compression:

Stored size: 712 Bytes

Contents

require 'rest-client'

Application.load 'lib/smartkiosk/sidekiq'

module Payments
  class PayWorker
    include Sidekiq::Worker

    sidekiq_options :queue => :payments

    def perform(payment_id)
      payment = Payment.find(payment_id)
      response = RestClient.post "#{Terminal.config.host}/payments/#{payment.foreign_id}/pay",
                                 :provider => payment.provider.keyword,
                                 :terminal => Terminal.config.keyword,
                                 :payment => { :paid_amount => payment.paid_amount }
      Sidekiq::Logging.logger.debug "Pay response: #{response.to_s}"
      payment.update_attributes(:processed => true) if response
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smartkiosk-client-0.0.10 app/workers/payments/pay_worker.rb
smartkiosk-client-0.0.9 app/workers/payments/pay_worker.rb
smartkiosk-client-0.0.8 app/workers/payments/pay_worker.rb
smartkiosk-client-0.0.7 app/workers/payments/pay_worker.rb
smartkiosk-client-0.0.6 app/workers/payments/pay_worker.rb
smartkiosk-client-0.0.5 app/workers/payments/pay_worker.rb
smartkiosk-client-0.0.4 app/workers/payments/pay_worker.rb