Oayment confirmation added to cart contoroller

This commit is contained in:
adam.harbas@a-net.ba
2016-01-07 10:49:50 +01:00
parent 0efb73e385
commit ea1c760e85

View File

@@ -101,3 +101,25 @@ post '/cart/confirmation' do
send_order_email(cart)
"OK".to_json
end
get '/payment/confirmation' do
data = param[:custom]
anonymus = data[:anonymous_id_string]
user = data[:user_id]
cart = Cart.just_find(anonymus, user)
allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note"]
params = data.reject { |key,_| !allowed_keys.include?(key) }
cart.delivery_destination.update_attributes(params)
cart.delivery_destination.save!
if cart.item_in_carts.length > 0
cart.ordered = true
cart.save!
end
Cart.find_or_create(anonymous, logged_in_user_id)
report_to_trello(cart)
send_order_email(cart)
"OK".to_json
end