Sha256: 15f0459a98ced443c9e5e4247e5cd2be63ea167327d98e32228f981a51d4bfca

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 KB

Contents

require 'rest-client'

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 => {
                                    :meta        => payment.meta,
                                    :paid_amount => payment.paid_amount,
                                    :card_track1 => payment.card_track1,
                                    :card_track2 => payment.card_track2
                                  }
      Sidekiq::Logging.logger.debug "Pay response: #{response.to_s}"
      payment.update_attributes(
        :processed => true,
        :card_track1 => nil,
        :card_track2 => nil
      ) if response
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
smartkiosk-client-0.2.1 app/workers/payments/pay_worker.rb
smartkiosk-client-0.2 app/workers/payments/pay_worker.rb
smartkiosk-client-0.1.19 app/workers/payments/pay_worker.rb
smartkiosk-client-0.1.18 app/workers/payments/pay_worker.rb
smartkiosk-client-0.1.17 app/workers/payments/pay_worker.rb
smartkiosk-client-0.1.16 app/workers/payments/pay_worker.rb
smartkiosk-client-0.1.15 app/workers/payments/pay_worker.rb
smartkiosk-client-0.1.14 app/workers/payments/pay_worker.rb
smartkiosk-client-0.1.13 app/workers/payments/pay_worker.rb
smartkiosk-client-0.1.12 app/workers/payments/pay_worker.rb
smartkiosk-client-0.1.11 app/workers/payments/pay_worker.rb