Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/views/pay/user_mailer/payment_action_required.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Extra confirmation is needed to process your payment

Your <%= Pay.application_name %> subscription requires confirmation to process your payment to continue access.

Confirm your payment: <%= pay.payment_url(params[:payment_intent_id]) %>

If you have any questions, please hit reply and let us know.

— The <%= Pay.application_name %> Team
9 changes: 9 additions & 0 deletions app/views/pay/user_mailer/payment_failed.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Your payment was declined

We were unable to charge your payment method for your <%= Pay.application_name %> subscription. Please update your billing information.

Update billing information: <%= root_url %>

Let us know if you have any questions.

— The <%= Pay.application_name %> Team
21 changes: 21 additions & 0 deletions app/views/pay/user_mailer/refund.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
We have processed your <%= Pay.application_name %> refund.
Please allow up to 7 business days for your refund to appear in your account

Questions? Please reply to this email.

------------------------------------
RECEIPT - REFUND

<%= Pay.application_name %>
Amount: <%= params[:pay_charge].amount_refunded_with_currency %>

Refunded to: <%= params[:pay_charge].charged_to %>
Transaction ID: <%= params[:pay_charge].id %>
Date: <%= l params[:pay_charge].created_at %>
<% if params[:pay_charge].customer.owner.try(:extra_billing_info?) %>
<%= params[:pay_charge].customer.owner.extra_billing_info %>
<% end %>

<%= Pay.business_name %>
<%= Pay.business_address %>
------------------------------------
8 changes: 8 additions & 0 deletions app/views/pay/user_mailer/subscription_renewing.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Your upcoming <%= Pay.application_name %> subscription renewal

This is a friendly reminder that your <%= Pay.application_name %> subscription will renew automatically on <%= l params[:date].to_date, format: :long %>.

You may manage your subscription via your account: <%= root_url %>
If you have any questions, please hit reply and let us know.

— The <%= Pay.application_name %> Team
8 changes: 8 additions & 0 deletions app/views/pay/user_mailer/subscription_trial_ended.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Your <%= Pay.application_name %> trial has ended

This is just a friendly reminder that your <%= Pay.application_name %> trial has ended.

You may manage your subscription via your account: <%= root_url %>
If you have any questions, please hit reply and let us know.

— The <%= Pay.application_name %> Team
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Your <%= Pay.application_name %> trial is ending soon

This is just a friendly reminder that your <%= Pay.application_name %> trial will be ending soon.

You may manage your subscription via your account: <%= root_url %>
If you have any questions, please hit reply and let us know.

— The <%= Pay.application_name %> Team
13 changes: 7 additions & 6 deletions test/mailers/pay/user_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ class UserMailerTest < ActionMailer::TestCase
email = Pay::UserMailer.with(pay_customer: @pay_customer, pay_subscription: Pay::Subscription.new, date: time).subscription_renewing

assert_equal [@user.email], email.to
assert_equal I18n.t("pay.user_mailer.subscription_renewing.subject", application: Pay.application_name), email.subject
assert_includes email.body.decoded, I18n.l(time.to_date, format: :long)
assert_equal I18n.t("pay.user_mailer.subscription_renewing.subject", application: Pay.application_name),
email.subject
assert_includes email.html_part.decoded, I18n.l(time.to_date, format: :long)
end

test "payment_action_required" do
email = Pay::UserMailer.with(pay_customer: @pay_customer, payment_intent_id: "x", pay_subscription: Pay::Subscription.new).payment_action_required

assert_equal [@user.email], email.to
assert_equal I18n.t("pay.user_mailer.payment_action_required.subject", application: Pay.application_name), email.subject
assert_includes email.body.decoded, Pay::Engine.instance.routes.url_helpers.payment_path("x")
assert_includes email.html_part.decoded, Pay::Engine.instance.routes.url_helpers.payment_path("x")
end

test "receipt with no extra billing info column" do
Expand All @@ -99,22 +100,22 @@ class UserMailerTest < ActionMailer::TestCase

assert_equal [@user.email], email.to
assert_equal I18n.t("pay.user_mailer.subscription_trial_will_end.subject", application: Pay.application_name), email.subject
assert_includes email.body.decoded, "trial is ending soon"
assert_includes email.html_part.decoded, "trial is ending soon"
end

test "subscription_trial_ended" do
email = Pay::UserMailer.with(pay_customer: @pay_customer).subscription_trial_ended

assert_equal [@user.email], email.to
assert_equal I18n.t("pay.user_mailer.subscription_trial_ended.subject", application: Pay.application_name), email.subject
assert_includes email.body.decoded, "trial has ended"
assert_includes email.html_part.decoded, "trial has ended"
end

test "subscription payment failed" do
email = Pay::UserMailer.with(pay_customer: @pay_customer).payment_failed

assert_equal [@user.email], email.to
assert_equal I18n.t("pay.user_mailer.payment_failed.subject", application: Pay.application_name), email.subject
assert_includes email.body.decoded, "payment was declined"
assert_includes email.html_part.decoded, "payment was declined"
end
end