Class: Payments::PayWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/payments/pay_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(payment_id) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/workers/payments/pay_worker.rb', line 9

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,
                                :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