mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
add email template to notify hub that auth is required
This commit is contained in:
@@ -7,8 +7,22 @@ class PaymentMailer < Spree::BaseMailer
|
||||
@payment = payment
|
||||
subject = I18n.t('spree.payment_mailer.authorize_payment.subject',
|
||||
distributor: @payment.order.distributor.name)
|
||||
mail(to: payment.order.user.email,
|
||||
from: from_address,
|
||||
subject: subject)
|
||||
I18n.with_locale valid_locale(@payment.order.user) do
|
||||
mail(to: payment.order.user.email,
|
||||
from: from_address,
|
||||
subject: subject)
|
||||
end
|
||||
end
|
||||
|
||||
def authorization_required(payment)
|
||||
@payment = payment
|
||||
shop_owner = @payment.order.distributor.owner
|
||||
subject = I18n.t('spree.payment_mailer.authorization_required.subject',
|
||||
order: @payment.order)
|
||||
I18n.with_locale valid_locale(shop_owner) do
|
||||
mail(to: shop_owner.email,
|
||||
from: from_address,
|
||||
subject: subject)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
= t('spree.payment_mailer.authorization_required.message', order_number: @payment.order.number)
|
||||
= link_to spree.edit_admin_order_url(@payment.order), spree.edit_admin_order_url(@payment.order)
|
||||
@@ -0,0 +1,3 @@
|
||||
= t('spree.payment_mailer.authorization_required.message', order_number: @payment.order.number)
|
||||
|
||||
= link_to spree.edit_admin_order_url(@payment.order), spree.edit_admin_order_url(@payment.order)
|
||||
@@ -3658,6 +3658,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
authorize_payment:
|
||||
subject: "Please authorize your payment to %{distributor} on OFN"
|
||||
instructions: "Your payment of %{amount} to %{distributor} requires additional authentication. Please visit the following URL to authorize your payment:"
|
||||
authorization_required:
|
||||
subject: "A payment requires authorization from the customer"
|
||||
message: "A payment for order %{order_number} requires additional authorization from the customer. The customer has been notified via email and the payment will appear as pending until it is authorized."
|
||||
shipment_mailer:
|
||||
shipped_email:
|
||||
dear_customer: "Dear Customer,"
|
||||
|
||||
@@ -17,6 +17,7 @@ module OrderManagement
|
||||
|
||||
if @payment.cvv_response_message.present?
|
||||
PaymentMailer.authorize_payment(@payment).deliver_now
|
||||
PaymentMailer.authorization_required(@payment).deliver_now
|
||||
end
|
||||
|
||||
@payment
|
||||
|
||||
@@ -63,18 +63,20 @@ module OrderManagement
|
||||
|
||||
before do
|
||||
allow(PaymentMailer).to receive(:authorize_payment) { mail_mock }
|
||||
allow(PaymentMailer).to receive(:authorization_required) { mail_mock }
|
||||
allow(payment).to receive(:authorize!) {
|
||||
payment.state = "pending"
|
||||
payment.cvv_response_message = "https://stripe.com/redirect"
|
||||
}
|
||||
end
|
||||
|
||||
it "adds sends an email requesting authorization" do
|
||||
it "sends an email requesting authorization and an email notifying the shop owner" do
|
||||
payment_authorize.call!
|
||||
|
||||
expect(order.errors.size).to eq 0
|
||||
expect(PaymentMailer).to have_received(:authorize_payment)
|
||||
expect(mail_mock).to have_received(:deliver_now)
|
||||
expect(PaymentMailer).to have_received(:authorization_required)
|
||||
expect(mail_mock).to have_received(:deliver_now).twice
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,6 +43,7 @@ describe Checkout::StripeRedirect do
|
||||
stripe_payment.state = 'pending'
|
||||
true
|
||||
end
|
||||
allow(stripe_payment.order).to receive(:distributor) { distributor }
|
||||
test_redirect_url = "http://stripe_auth_url/"
|
||||
allow(stripe_payment).to receive(:cvv_response_message).and_return(test_redirect_url)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user