mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
don't send emails if auth required during checkout
This commit is contained in:
@@ -14,7 +14,8 @@ module Checkout
|
||||
def path
|
||||
return unless stripe_payment_method?
|
||||
|
||||
payment = OrderManagement::Order::StripeScaPaymentAuthorize.new(@order).call!(full_checkout_path)
|
||||
payment = OrderManagement::Order::StripeScaPaymentAuthorize.new(@order).
|
||||
call!(full_checkout_path, false)
|
||||
raise if @order.errors.any?
|
||||
|
||||
field_with_url(payment)
|
||||
|
||||
@@ -10,14 +10,14 @@ module OrderManagement
|
||||
@payment = OrderPaymentFinder.new(@order).last_pending_payment
|
||||
end
|
||||
|
||||
def call!(redirect_url = full_order_path(@order))
|
||||
def call!(redirect_url = full_order_path(@order), send_emails = true)
|
||||
return unless @payment&.checkout?
|
||||
|
||||
@payment.authorize!(redirect_url)
|
||||
|
||||
@order.errors.add(:base, I18n.t('authorization_failure')) unless @payment.pending?
|
||||
|
||||
if @payment.cvv_response_message.present?
|
||||
if send_emails && @payment.cvv_response_message.present?
|
||||
PaymentMailer.authorize_payment(@payment).deliver_now
|
||||
PaymentMailer.authorization_required(@payment).deliver_now
|
||||
end
|
||||
|
||||
@@ -78,6 +78,15 @@ module OrderManagement
|
||||
expect(PaymentMailer).to have_received(:authorization_required)
|
||||
expect(mail_mock).to have_received(:deliver_now).twice
|
||||
end
|
||||
|
||||
it "doesn't send emails if param is set to false" do
|
||||
payment_authorize.call!(nil, false)
|
||||
|
||||
expect(order.errors.size).to eq 0
|
||||
expect(PaymentMailer).to_not have_received(:authorize_payment)
|
||||
expect(PaymentMailer).to_not have_received(:authorization_required)
|
||||
expect(mail_mock).to_not have_received(:deliver_now)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user