mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-22 05:18:51 +00:00
Log bugsnag and still send failed payment email when any exception is caught during the confirmation process
This commit is contained in:
@@ -52,6 +52,7 @@ class SubscriptionConfirmJob
|
||||
end
|
||||
rescue StandardError => e
|
||||
Bugsnag.notify(e, order: order)
|
||||
send_failed_payment_email(order, e.message)
|
||||
end
|
||||
|
||||
def process_payment!(order)
|
||||
@@ -89,9 +90,9 @@ class SubscriptionConfirmJob
|
||||
SubscriptionMailer.confirmation_email(order).deliver
|
||||
end
|
||||
|
||||
def send_failed_payment_email(order)
|
||||
def send_failed_payment_email(order, error_message = nil)
|
||||
order.update!
|
||||
record_and_log_error(:failed_payment, order)
|
||||
record_and_log_error(:failed_payment, order, error_message)
|
||||
SubscriptionMailer.failed_payment_email(order).deliver
|
||||
end
|
||||
end
|
||||
|
||||
@@ -216,7 +216,7 @@ describe SubscriptionConfirmJob do
|
||||
|
||||
it "records and logs an error and sends the email" do
|
||||
expect(order).to receive(:update!)
|
||||
expect(job).to receive(:record_and_log_error).with(:failed_payment, order).once
|
||||
expect(job).to receive(:record_and_log_error).with(:failed_payment, order, nil).once
|
||||
job.send(:send_failed_payment_email, order)
|
||||
expect(SubscriptionMailer).to have_received(:failed_payment_email).with(order)
|
||||
expect(mail_mock).to have_received(:deliver)
|
||||
|
||||
Reference in New Issue
Block a user