Add PaymentNotificationEmailNonprofitJob
This commit is contained in:
parent
283ebc553b
commit
0d70861a19
8 changed files with 4 additions and 51 deletions
|
@ -1,7 +1,7 @@
|
||||||
class PaymentNotificationEmailNonprofitJob < ApplicationJob
|
class PaymentNotificationEmailNonprofitJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
|
||||||
def perform(*args)
|
def perform(donation, user=nil)
|
||||||
# Do something later
|
DonationMailer.nonprofit_payment_notification(donation.id, user&.id).deliver_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ class PaymentMailer < BaseMailer
|
||||||
def resend_admin_receipt(payment_id, user_id)
|
def resend_admin_receipt(payment_id, user_id)
|
||||||
payment = Payment.find(payment_id)
|
payment = Payment.find(payment_id)
|
||||||
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
||||||
return Delayed::Job.enqueue JobTypes::NonprofitPaymentNotificationJob.new(payment.donation.id, user_id)
|
PaymentNotificationEmailNonprofitJob.perform_later(payment.donation, User.find(user_id))
|
||||||
elsif payment.kind == 'Ticket'
|
elsif payment.kind == 'Ticket'
|
||||||
return TicketMailer.receipt_admin(payment.donation.id, user_id).deliver
|
return TicketMailer.receipt_admin(payment.donation.id, user_id).deliver
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,6 @@ module InsertDonation
|
||||||
result['donation'] = insert_donation(data, entities)
|
result['donation'] = insert_donation(data, entities)
|
||||||
update_donation_keys(result)
|
update_donation_keys(result)
|
||||||
result['activity'] = InsertActivities.for_one_time_donations([result['payment'].id])
|
result['activity'] = InsertActivities.for_one_time_donations([result['payment'].id])
|
||||||
EmailJobQueue.queue(JobTypes::NonprofitPaymentNotificationJob, result['donation'].id)
|
|
||||||
PaymentNotificationJob.perform_later result['donation'], entities[:supporter_id].locale
|
PaymentNotificationJob.perform_later result['donation'], entities[:supporter_id].locale
|
||||||
QueueDonations.delay.execute_for_donation(result['donation'].id)
|
QueueDonations.delay.execute_for_donation(result['donation'].id)
|
||||||
result
|
result
|
||||||
|
@ -107,7 +106,6 @@ module InsertDonation
|
||||||
update_donation_keys(result)
|
update_donation_keys(result)
|
||||||
|
|
||||||
DirectDebitCreateJob.perform_later(result['donation'].id, locale_for_supporter(result['donation'].supporter.id))
|
DirectDebitCreateJob.perform_later(result['donation'].id, locale_for_supporter(result['donation'].supporter.id))
|
||||||
EmailJobQueue.queue(JobTypes::NonprofitPaymentNotificationJob, result['donation'].id)
|
|
||||||
|
|
||||||
QueueDonations.delay.execute_for_donation(result['donation'].id)
|
QueueDonations.delay.execute_for_donation(result['donation'].id)
|
||||||
# do this for making test consistent
|
# do this for making test consistent
|
||||||
|
|
|
@ -70,7 +70,6 @@ module InsertRecurringDonation
|
||||||
result['activity'] = InsertActivities.for_recurring_donations([result['payment'].id])
|
result['activity'] = InsertActivities.for_recurring_donations([result['payment'].id])
|
||||||
end
|
end
|
||||||
# Send receipts
|
# Send receipts
|
||||||
EmailJobQueue.queue(JobTypes::NonprofitPaymentNotificationJob, result['donation'].id)
|
|
||||||
PaymentNotificationJob.perform_later result['donation'], entities[:supporter_id].locale
|
PaymentNotificationJob.perform_later result['donation'], entities[:supporter_id].locale
|
||||||
QueueDonations.delay.execute_for_donation(result['donation']['id'])
|
QueueDonations.delay.execute_for_donation(result['donation']['id'])
|
||||||
result
|
result
|
||||||
|
@ -95,8 +94,7 @@ module InsertRecurringDonation
|
||||||
|
|
||||||
InsertDonation.update_donation_keys(result) if result['payment']
|
InsertDonation.update_donation_keys(result) if result['payment']
|
||||||
|
|
||||||
DonationMailer.delay.nonprofit_payment_notification(result['donation']['id'])
|
DonorDirectDebitNotificationJob.perform_later(Donation.find(result['donation']['id']), locale_for_supporter(result['donation']['supporter_id']);
|
||||||
DonationMailer.delay.donor_direct_debit_notification(result['donation']['id'], locale_for_supporter(result['donation']['supporter_id']))
|
|
||||||
|
|
||||||
QueueDonations.delay.execute_for_donation(result['donation']['id'])
|
QueueDonations.delay.execute_for_donation(result['donation']['id'])
|
||||||
|
|
||||||
|
|
|
@ -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 NonprofitPaymentNotificationJob < EmailJob
|
|
||||||
attr_reader :donation_id, :user_id
|
|
||||||
def initialize(donation_id, user_id = nil)
|
|
||||||
@donation_id = donation_id
|
|
||||||
@user_id = user_id
|
|
||||||
end
|
|
||||||
|
|
||||||
def perform
|
|
||||||
DonationMailer.nonprofit_payment_notification(@donation_id, @user_id).deliver
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -95,7 +95,6 @@ module PayRecurringDonation
|
||||||
.where('id=$id', id: rd_id).returning('*')
|
.where('id=$id', id: rd_id).returning('*')
|
||||||
).first
|
).first
|
||||||
PaymentNotificationJob.perform_later donation, donation&.supporter&.locale || 'en'
|
PaymentNotificationJob.perform_later donation, donation&.supporter&.locale || 'en'
|
||||||
Delayed::Job.enqueue JobTypes::NonprofitPaymentNotificationJob.new(rd['donation_id'])
|
|
||||||
InsertActivities.for_recurring_donations([result['payment']['id']])
|
InsertActivities.for_recurring_donations([result['payment']['id']])
|
||||||
else
|
else
|
||||||
result['recurring_donation'] = Psql.execute(
|
result['recurring_donation'] = Psql.execute(
|
||||||
|
@ -147,8 +146,6 @@ module PayRecurringDonation
|
||||||
.where('id=$id', id: rd_id).returning('*')
|
.where('id=$id', id: rd_id).returning('*')
|
||||||
).first
|
).first
|
||||||
## add PaymentNotificationJobHere
|
## add PaymentNotificationJobHere
|
||||||
Delayed::Job.enqueue JobTypes::DonorPaymentNotificationJob.new(rd['donation_id'])
|
|
||||||
Delayed::Job.enqueue JobTypes::NonprofitPaymentNotificationJob.new(rd['donation_id'])
|
|
||||||
InsertActivities.for_recurring_donations([result['payment']['id']])
|
InsertActivities.for_recurring_donations([result['payment']['id']])
|
||||||
else
|
else
|
||||||
result['recurring_donation'] = Psql.execute(
|
result['recurring_donation'] = Psql.execute(
|
||||||
|
|
|
@ -1,22 +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::NonprofitPaymentNotificationJob do
|
|
||||||
describe '.perform' do
|
|
||||||
it 'calls the correct active mailer' do
|
|
||||||
expect(DonationMailer).to receive(:nonprofit_payment_notification).with(1, nil).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
|
||||||
|
|
||||||
job = JobTypes::NonprofitPaymentNotificationJob.new(1)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'calls the correct active mailer, with user id' do
|
|
||||||
expect(DonationMailer).to receive(:nonprofit_payment_notification).with(1, 2).and_wrap_original { |_m, *_args| mailer = double('object'); expect(mailer).to receive(:deliver).and_return(nil); mailer }
|
|
||||||
|
|
||||||
job = JobTypes::NonprofitPaymentNotificationJob.new(1, 2)
|
|
||||||
job.perform
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -331,7 +331,6 @@ RSpec.shared_context :shared_rd_donation_value_context do
|
||||||
result = m.call(*args)
|
result = m.call(*args)
|
||||||
}.to have_enqueued_job(PaymentNotificationJob).with(result, supporter.local)
|
}.to have_enqueued_job(PaymentNotificationJob).with(result, supporter.local)
|
||||||
@donation_id = result.id
|
@donation_id = result.id
|
||||||
expect_email_queued.with(JobTypes::NonprofitPaymentNotificationJob, @donation_id)
|
|
||||||
|
|
||||||
expect(QueueDonations).to receive(:execute_for_donation).with(@donation_id)
|
expect(QueueDonations).to receive(:execute_for_donation).with(@donation_id)
|
||||||
|
|
||||||
|
@ -378,7 +377,6 @@ RSpec.shared_context :shared_rd_donation_value_context do
|
||||||
|
|
||||||
|
|
||||||
@donation_id = result.id
|
@donation_id = result.id
|
||||||
expect_email_queued.with(JobTypes::NonprofitPaymentNotificationJob, @donation_id)
|
|
||||||
expect(QueueDonations).to receive(:execute_for_donation).with(@donation_id)
|
expect(QueueDonations).to receive(:execute_for_donation).with(@donation_id)
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue