diff --git a/app/mailers/payment_mailer.rb b/app/mailers/payment_mailer.rb index 9dd8172dff..957f0cdf02 100644 --- a/app/mailers/payment_mailer.rb +++ b/app/mailers/payment_mailer.rb @@ -6,11 +6,9 @@ class PaymentMailer < ApplicationMailer def authorize_payment(payment) @payment = payment @order = @payment.order - subject = I18n.t("payment_mailer.authorize_payment.subject", - distributor: @order.distributor.name) I18n.with_locale valid_locale(@order.user) do mail(to: @order.email, - subject:, + subject: default_i18n_subject(distributor: @order.distributor.name), reply_to: @order.distributor.contact.email) end end @@ -18,24 +16,19 @@ class PaymentMailer < ApplicationMailer def authorization_required(payment) @order = payment.order shop_owner = @order.distributor.owner - subject = I18n.t("payment_mailer.authorization_required.subject", - order: @order) I18n.with_locale valid_locale(shop_owner) do - mail(to: shop_owner.email, - subject:, - reply_to: @order.email) + mail(to: shop_owner.email, reply_to: @order.email) end end def refund_available(payment, taler_order_status_url) @order = payment.order + @shop = @order.distributor.name @taler_order_status_url = taler_order_status_url - subject = I18n.t("payment_mailer.refund_available.subject", - order: @order) I18n.with_locale valid_locale(@order.user) do mail(to: @order.email, - subject:, + subject: default_i18n_subject(shop: @shop), reply_to: @order.email) end end diff --git a/app/views/payment_mailer/refund_available.html.haml b/app/views/payment_mailer/refund_available.html.haml index 64cb380f13..94680ef385 100644 --- a/app/views/payment_mailer/refund_available.html.haml +++ b/app/views/payment_mailer/refund_available.html.haml @@ -1,2 +1,2 @@ -%p= t(".message", order_number: @order.number) +%p= t(".message", shop: @shop) %p= link_to @taler_order_status_url, @taler_order_status_url diff --git a/config/locales/en.yml b/config/locales/en.yml index 63caaca96a..2917d93374 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -466,8 +466,10 @@ en: 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." refund_available: - subject: "Refund available" - message: "Your payment for order %{order_number} is being refunded. Claim your refund following the link below." + subject: "Refund from %{shop}" + message: | + Your payment to %{shop} is being refunded. + Accept your refund following the link below. producer_mailer: order_cycle: subject: "Order cycle report for %{producer}" diff --git a/spec/mailers/payment_mailer_spec.rb b/spec/mailers/payment_mailer_spec.rb index ae8ea86772..db44824124 100644 --- a/spec/mailers/payment_mailer_spec.rb +++ b/spec/mailers/payment_mailer_spec.rb @@ -2,7 +2,6 @@ RSpec.describe PaymentMailer do describe '#payment_mailer' do - let(:enterprise) { create(:enterprise) } let(:payment_method) { create(:payment_method, distributors: [order.distributor]) } @@ -15,7 +14,8 @@ RSpec.describe PaymentMailer do subject(:email) { described_class.authorize_payment(payment) } it "includes the distributor's name in the subject" do - expect(email.subject).to include("authorize your payment to #{order.distributor.name}") + order.distributor.name = "Fennel Farmer" + expect(email.subject).to include("authorize your payment to Fennel Farmer") end it "sets a reply-to of the customer email" do @@ -44,11 +44,12 @@ RSpec.describe PaymentMailer do describe "#refund_available" do it "tells the user to accept a refund" do payment = create(:payment) + payment.order.distributor = create(:enterprise, name: "Carrot Castle") link = "https://taler.example.com/order/1" mail = PaymentMailer.refund_available(payment, link) - expect(mail.subject).to eq "Refund available" - expect(mail.body).to match "Claim your refund following the link below." + expect(mail.subject).to eq "Refund from Carrot Castle" + expect(mail.body).to match "Your payment to Carrot Castle is being refunded." expect(mail.body).to match link end end