donation mailer

This commit is contained in:
Emi Matchu 2014-09-10 14:32:54 -05:00
parent 90b45dcecd
commit f11f6374da
16 changed files with 101 additions and 7 deletions

View file

@ -70,6 +70,8 @@ gem 'react-rails', '~> 0.8.0.0'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby' gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem "letter_opener", :group => :development
# Needed for the new asset pipeline # Needed for the new asset pipeline
group :assets do group :assets do

View file

@ -174,6 +174,10 @@ GEM
i18n (0.6.9) i18n (0.6.9)
journey (1.0.4) journey (1.0.4)
json (1.8.1) json (1.8.1)
launchy (2.4.2)
addressable (~> 2.3)
letter_opener (1.2.0)
launchy (~> 2.2)
mail (2.5.4) mail (2.5.4)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
@ -336,6 +340,7 @@ DEPENDENCIES
haml (~> 4.0.0) haml (~> 4.0.0)
http_accept_language! http_accept_language!
json (~> 1.8.1) json (~> 1.8.1)
letter_opener
memcache-client (~> 1.8.5) memcache-client (~> 1.8.5)
mini_magick (~> 3.4) mini_magick (~> 3.4)
msgpack (~> 0.5.3) msgpack (~> 0.5.3)

View file

@ -2,6 +2,8 @@
var donationForm = document.getElementById('donation-form'); var donationForm = document.getElementById('donation-form');
var amountField = donationForm.querySelector( var amountField = donationForm.querySelector(
'[name=donation\\[amount\\]]'); '[name=donation\\[amount\\]]');
var emailField = donationForm.querySelector(
'[name=donation\\[donor_email\\]]');
var tokenField = donationForm.querySelector( var tokenField = donationForm.querySelector(
'[name=donation\\[stripe_token\\]]'); '[name=donation\\[stripe_token\\]]');
@ -10,6 +12,7 @@
image: donationForm.getAttribute('data-checkout-image'), image: donationForm.getAttribute('data-checkout-image'),
token: function(token) { token: function(token) {
tokenField.value = token.id; tokenField.value = token.id;
emailField.value = token.email;
donationForm.submit(); donationForm.submit();
} }
}); });

View file

@ -0,0 +1,8 @@
class DonationMailer < ActionMailer::Base
default from: "matchu@openneo.net"
def thank_you_email(donation, recipient)
@donation = donation
mail(to: recipient, subject: 'Thanks for donating to Dress to Impress!')
end
end

View file

@ -29,6 +29,7 @@ class Donation < ActiveRecord::Base
donation.charge_id = charge.id donation.charge_id = charge.id
donation.user_id = user.try(:id) donation.user_id = user.try(:id)
donation.donor_name = user.try(:name) donation.donor_name = user.try(:name)
donation.donor_email = params[:donor_email]
donation.secret = new_secret donation.secret = new_secret
num_features = amount / FEATURE_COST num_features = amount / FEATURE_COST
@ -42,6 +43,8 @@ class Donation < ActiveRecord::Base
features.each(&:save!) features.each(&:save!)
end end
DonationMailer.thank_you_email(donation, customer.email).deliver
donation donation
end end

View file

@ -0,0 +1,38 @@
<p>
Hello, hello! I'm Matchu, loving father of Dress to Impress.
I started building the site on a whim one day, and never expected it to
really catch on—but here you are, proving that someone else out there loves
Dress to Impress as much as I do &lt;3 Thank you so much!
</p>
<p>
Before I forget, let's get to receipt business.
You donated
<strong><%= number_to_currency @donation.amount / 100.0 %></strong>
(thanks again, by the way!),
and you can update the name and outfits on that donation whenever you like at
<%= link_to donation_url(@donation), donation_url(@donation) %>.
</p>
<p>
Anyway. I hope you enjoy our little thank-you gift (you <em>do</em> have some
beautiful outfits for me to show off, right?), and that Dress to Impress
continues to bring you joy :)
</p>
<p>
Oh! And, if you ever have anything to say to me, <em>please</em> let me know
at <%= mail_to 'matchu@openneo.net' %>. I'm looking forward to any and all
questions, comments, concerns, insults, treasure maps, love letters, or memes
you send my way :D
</p>
<p>
Thanks again for your help! DTI &lt;3s you.<br />
—Matchu
</p>
<p>
P.S. Seriously. Reply to this email and tell me something.
It'll make my day :D
</p>

View file

@ -14,14 +14,15 @@
%p %p
%strong But enough about us. Let's talk about you! %strong But enough about us. Let's talk about you!
When we brag about you on our donors list, what should we say? When we brag about you on our #{link_to 'donors list', donate_path},
what should we say?
(If you'd rather take care of this later, no worries! (If you'd rather take care of this later, no worries!
Check your email for a copy of this URL.) Check your email for a copy of this URL.)
= form_for @donation, html: {id: 'edit-donation'} do |f| = form_for @donation, html: {id: 'edit-donation'} do |f|
%ul %ul
%li.name %li.name
= f.label :donor_name, "Your name on the donors page" = f.label :donor_name, "Your name on the donors list"
= f.text_field :donor_name, placeholder: 'Anonymous' = f.text_field :donor_name, placeholder: 'Anonymous'
- @features.each do |feature| - @features.each do |feature|

View file

@ -10,10 +10,14 @@
'data-checkout-image' => image_path('default-preview.png'), 'data-checkout-image' => image_path('default-preview.png'),
'data-checkout-publishable-key' => Rails.configuration.stripe[:publishable_key] do 'data-checkout-publishable-key' => Rails.configuration.stripe[:publishable_key] do
= hidden_field_tag 'donation[stripe_token]' = hidden_field_tag 'donation[stripe_token]'
= hidden_field_tag 'donation[donor_email]'
%header %header
%p#donation-form-title %p#donation-form-title
Thanks for supporting Dress to Impress! Thanks for supporting Dress to Impress!
%p#donation-form-subtitle %p#donation-form-subtitle
Securely powered by #{link_to 'Stripe', 'https://stripe.com/'}.
We never, ever see your payment info.
%br
All donations go directly to our hosting costs. Thanks for your help! All donations go directly to our hosting costs. Thanks for your help!
%div %div
= precede '$' do = precede '$' do

View file

@ -15,6 +15,8 @@ OpenneoImpressItems::Application.configure do
# Don't care if the mailer can't send # Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = {host: "impress.dev.openneo.net"}
config.action_mailer.delivery_method = :letter_opener
config.active_support.deprecation = :log config.active_support.deprecation = :log

View file

@ -19,6 +19,8 @@ OpenneoImpressItems::Application.configure do
config.active_support.deprecation = :log config.active_support.deprecation = :log
config.action_mailer.default_url_options[:host] = 'impress.dev.openneo.net'
config.threadsafe! config.threadsafe!
end end

View file

@ -61,6 +61,21 @@ OpenneoImpressItems::Application.configure do
# config.force_ssl = true # config.force_ssl = true
config.react.variant = :production config.react.variant = :production
config.action_mailer.default_url_options = {host: "impress.openneo.net"}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "mail.openneo.net",
:port => 587,
:domain => "openneo.net",
:authentication => :login,
:user_name => "matchu@openneo.net",
:password => ENV.fetch("MATCHU_EMAIL_PASSWORD"),
:enable_starttls_auto => false
}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
end end
LocalImpressHost = 'newimpress.openneo.net' LocalImpressHost = 'newimpress.openneo.net'

View file

@ -0,0 +1,5 @@
class AddEmailToDonations < ActiveRecord::Migration
def change
add_column :donations, :donor_email, :string
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140910030549) do ActiveRecord::Schema.define(:version => 20140910181819) do
create_table "auth_servers", :force => true do |t| create_table "auth_servers", :force => true do |t|
t.string "short_name", :limit => 10, :null => false t.string "short_name", :limit => 10, :null => false
@ -114,6 +114,7 @@ ActiveRecord::Schema.define(:version => 20140910030549) do
t.string "secret" t.string "secret"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "donor_email"
end end
create_table "donations_old", :force => true do |t| create_table "donations_old", :force => true do |t|

View file

@ -0,0 +1,5 @@
require "spec_helper"
describe DonationMailer do
pending "add some examples to (or delete) #{__FILE__}"
end

BIN
vendor/cache/launchy-2.4.2.gem vendored Normal file

Binary file not shown.

BIN
vendor/cache/letter_opener-1.2.0.gem vendored Normal file

Binary file not shown.