Class: ErpTxnsAndAccts::DelayedJobs::PaymentGatewayJob

Inherits:
Object
  • Object
show all
Defined in:
lib/erp_txns_and_accts/delayed_jobs/payment_gateway_job.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(financial_txn_id, gateway_klass, gateway_action, gateway_options, credit_card) ⇒ PaymentGatewayJob

Returns a new instance of PaymentGatewayJob.



9
10
11
12
13
14
15
# File 'lib/erp_txns_and_accts/delayed_jobs/payment_gateway_job.rb', line 9

def initialize(financial_txn_id, gateway_klass, gateway_action, gateway_options, credit_card)
      @financial_txn_id = financial_txn_id
      @gateway_klass    = gateway_klass
      @gateway_action   = gateway_action
      @gateway_options  = gateway_options
      @credit_card      = credit_card
end

Class Method Details

.start(financial_txn, gateway, gateway_action, gateway_options, credit_card) ⇒ Object



4
5
6
7
# File 'lib/erp_txns_and_accts/delayed_jobs/payment_gateway_job.rb', line 4

def self.start(financial_txn, gateway, gateway_action, gateway_options, credit_card)
      job_object = ErpTxnsAndAccts::DelayedJobs::PaymentGatewayJob.new(financial_txn.id, gateway.name.to_s, gateway_action, gateway_options, credit_card)
      Delayed::Job.enqueue(job_object, 50, 1.seconds.from_now)
end

Instance Method Details

#perform ⇒ Object



17
18
19
20
21
# File 'lib/erp_txns_and_accts/delayed_jobs/payment_gateway_job.rb', line 17

def perform
      gateway = @gateway_klass.constantize
      financial_txn = FinancialTxn.find(@financial_txn_id)
      financial_txn.send(@gateway_action, @credit_card, gateway, @gateway_options)
end