Add PayoutPendingJob
This commit is contained in:
parent
e05466d0c6
commit
94398f8bdf
5 changed files with 8 additions and 33 deletions
7
app/jobs/payout_pending_job.rb
Normal file
7
app/jobs/payout_pending_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class PayoutPendingJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(payout)
|
||||||
|
NonprofitMailer.pending_payout_notification(payout.id).deliver_now
|
||||||
|
end
|
||||||
|
end
|
|
@ -69,7 +69,7 @@ module InsertPayout
|
||||||
).first
|
).first
|
||||||
# Create PaymentPayout records linking all the payments to the payout
|
# Create PaymentPayout records linking all the payments to the payout
|
||||||
pps = Psql.execute(Qexpr.new.insert('payment_payouts', payment_ids.map { |id| { payment_id: id.to_i } }, common_data: { payout_id: payout['id'].to_i }))
|
pps = Psql.execute(Qexpr.new.insert('payment_payouts', payment_ids.map { |id| { payment_id: id.to_i } }, common_data: { payout_id: payout['id'].to_i }))
|
||||||
NonprofitMailer.delay.pending_payout_notification(payout['id'].to_i)
|
PayoutPendingJob.perform_later(Payout.find(payout['id'].to_i))
|
||||||
return payout
|
return payout
|
||||||
end
|
end
|
||||||
rescue Stripe::StripeError => e
|
rescue Stripe::StripeError => e
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
module JobTypes
|
|
||||||
class NonprofitPendingPayoutJob < EmailJob
|
|
||||||
attr_reader :payout_id
|
|
||||||
|
|
||||||
def initialize(payout_id)
|
|
||||||
@payout_id = payout_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform
|
|
||||||
NonprofitMailer.pending_payout_notification(@payout_id).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -34,7 +34,6 @@ module UpdatePayouts
|
||||||
payout.failure_message = failure_message
|
payout.failure_message = failure_message
|
||||||
payout.save!
|
payout.save!
|
||||||
|
|
||||||
# NonprofitMailer.delay.pending_payout_notification(payout['id'].to_i)
|
|
||||||
payout
|
payout
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
require 'rails_helper.rb'
|
|
||||||
|
|
||||||
describe JobTypes::NonprofitPendingPayoutJob do
|
|
||||||
describe '.perform' do
|
|
||||||
it 'calls the correct active mailer' do
|
|
||||||
expect(NonprofitMailer).to receive(:pending_payout_notification).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
|
||||||
|
|
||||||
job = JobTypes::NonprofitPendingPayoutJob.new(1)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue