added email notification when order arives

This commit is contained in:
Senad Uka
2015-08-09 10:58:14 +02:00
parent 8b6a62b7e7
commit 2ff5ceabd2
4 changed files with 30 additions and 1 deletions

View File

@@ -54,6 +54,26 @@ put '/cart/delivery_destination', &update_delivery_destination
post '/cart/delivery_destination', &update_delivery_destination
def send_order_email(cart)
Pony.options = {
:subject => "Nova Narudžba: #{cart.id}",
:html_body => "Mušterija naručila nešto. <br /> Pogledati https://www.ribica.ba/backoffice/carts/#{cart.id}",
:body => "Mušterija naručila nešto. Pogledati https://www.ribica.ba/backoffice/carts/#{cart.id}",
:via => :smtp,
:via_options => {
:address => 'smtp.gmail.com',
:port => '587',
:enable_starttls_auto => true,
:user_name => 'ribica.ba@gmail.com',
:password => 'pumparica*pumpa*sumpa*lumpa',
:authentication => :plain, # :plain, :login, :cram_md5, no auth by default
:domain => "localhost.localdomain"
}
}
Pony.mail(:to => "narudzbe@ribica.ba")
end
post '/cart/confirmation' do
anonymous = anonymous_id
cart = Cart.just_find(anonymous, logged_in_user_id)
@@ -64,5 +84,6 @@ post '/cart/confirmation' do
# since there is no more ordered cart this needs to be done
# in order for next call of Cart#just_find to be ready
Cart.find_or_create(anonymous, logged_in_user_id)
send_order_email(cart)
"OK".to_json
end