2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-12 20:03:43 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
|
|
|
|
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
|
2018-03-25 17:30:42 +00:00
|
|
|
class PaymentMailer < BaseMailer
|
|
|
|
# Send a donation receipt to a single admin
|
|
|
|
# or a ticket receipt
|
|
|
|
def resend_admin_receipt(payment_id, user_id)
|
|
|
|
payment = Payment.find(payment_id)
|
|
|
|
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
2019-11-07 20:06:12 +00:00
|
|
|
PaymentNotificationEmailNonprofitJob.perform_later(payment.donation, User.find(user_id))
|
2018-03-25 17:30:42 +00:00
|
|
|
elsif payment.kind == 'Ticket'
|
2019-11-07 20:51:09 +00:00
|
|
|
return TicketMailer.receipt_admin(payment.donation.id, user_id).deliver_later
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Send a donation receipt to the donor
|
|
|
|
# or a ticket followup email to the supporter
|
|
|
|
def resend_donor_receipt(payment_id)
|
|
|
|
payment = Payment.find(payment_id)
|
|
|
|
if payment.kind == 'Donation' || payment.kind == 'RecurringDonation'
|
2019-11-07 18:35:38 +00:00
|
|
|
PaymentNotificationEmailDonorJob.perform_later payment.donation
|
2018-03-25 17:30:42 +00:00
|
|
|
elsif payment.kind == 'Ticket'
|
2019-11-07 20:51:09 +00:00
|
|
|
return TicketMailer.followup(payment.tickets.pluck(:id), payment.charge).deliver_later
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|