Oayment confirmation added to cart contoroller
This commit is contained in:
@@ -101,3 +101,25 @@ post '/cart/confirmation' do
|
|||||||
send_order_email(cart)
|
send_order_email(cart)
|
||||||
"OK".to_json
|
"OK".to_json
|
||||||
end
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user