Add RefundNotificationJob
This commit is contained in:
parent
b6292ab7aa
commit
8a97e3a8af
6 changed files with 23 additions and 31 deletions
7
app/jobs/refund_notification_donor_email_job.rb
Normal file
7
app/jobs/refund_notification_donor_email_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class RefundNotificationDonorEmailJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(refund)
|
||||||
|
UserMailer.refund_receipt(refund).deliver_now
|
||||||
|
end
|
||||||
|
end
|
8
app/jobs/refund_notification_job.rb
Normal file
8
app/jobs/refund_notification_job.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class RefundNotificationJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(refund)
|
||||||
|
RefundNotificationJobDonorEmail.perform_later(refund)
|
||||||
|
RefundNotificationJobNonprofitEmail.perform_later(refund)
|
||||||
|
end
|
||||||
|
end
|
7
app/jobs/refund_notification_nonprofit_email_job.rb
Normal file
7
app/jobs/refund_notification_nonprofit_email_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class RefundNotificationNonprofitEmailJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(*args)
|
||||||
|
# Do something later
|
||||||
|
end
|
||||||
|
end
|
|
@ -66,7 +66,7 @@ module InsertRefunds
|
||||||
# Update original payment to increment its refund_total for any future refund attempts
|
# Update original payment to increment its refund_total for any future refund attempts
|
||||||
Qx.update(:payments).set("refund_total=refund_total + #{h['amount'].to_i}").ts.where(id: original_payment['id']).execute
|
Qx.update(:payments).set("refund_total=refund_total + #{h['amount'].to_i}").ts.where(id: original_payment['id']).execute
|
||||||
# Send the refund receipts in a delayed job
|
# Send the refund receipts in a delayed job
|
||||||
Delayed::Job.enqueue JobTypes::DonorRefundNotificationJob.new(refund_row['id'])
|
RefundNotificationJob.perform_later Refund.find(refund_row['id'])
|
||||||
Delayed::Job.enqueue JobTypes::NonprofitRefundNotificationJob.new(refund_row['id'])
|
Delayed::Job.enqueue JobTypes::NonprofitRefundNotificationJob.new(refund_row['id'])
|
||||||
{ 'payment' => payment_row, 'refund' => refund_row }
|
{ 'payment' => payment_row, 'refund' => refund_row }
|
||||||
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
|
|
||||||
module JobTypes
|
|
||||||
class DonorRefundNotificationJob < EmailJob
|
|
||||||
attr_reader :refund_id
|
|
||||||
def initialize(refund_id)
|
|
||||||
@refund_id = refund_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform
|
|
||||||
UserMailer.refund_receipt(@refund_id).deliver
|
|
||||||
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::DonorRefundNotificationJob do
|
|
||||||
describe '.perform' do
|
|
||||||
it 'calls the correct active mailer' do
|
|
||||||
expect(UserMailer).to receive(:refund_receipt).with(1).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
|
||||||
|
|
||||||
job = JobTypes::DonorRefundNotificationJob.new(1)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue