Skip to content

Instantly share code, notes, and snippets.

@dimasjt
Created December 12, 2014 06:34
Show Gist options
  • Save dimasjt/235c85ce411da7e0a460 to your computer and use it in GitHub Desktop.
Save dimasjt/235c85ce411da7e0a460 to your computer and use it in GitHub Desktop.
def success
if params[:token]
if session[:checkout_user] && session[:checkouts]
checkout = session[:checkout_user]
total = session[:checkouts][:total_price] * 100
purchase = EXPRESS_GATEWAY.purchase(total,
:ip => request.ip,
:token => params[:token],
:payer_id => params[:PayerID]
)
details = EXPRESS_GATEWAY.details_for(params[:token])
@checkout = Checkout.new
@checkout.birth = checkout["birth"].to_date
@checkout.special = checkout["special"]
@checkout.gender = checkout["gender"]
@checkout.country = checkout["country"]
@checkout.mobile = checkout["mobile"]
@checkout.passport = checkout["passport"]
@checkout.select_country = checkout["select_country"]
@checkout.estimate = checkout["estimate"]
@checkout.address = checkout["address"]
@checkout.state = checkout["state"]
@checkout.city = checkout["city"]
@checkout.postal_code = checkout["postal_code"]
@checkout.email_id = details.params["PayerInfo"]["Payer"]
@checkout.express_payer_id = params[:PayerID]
@checkout.express_token = params[:token]
@checkout.first_name = details.params["first_name"]
@checkout.last_name = details.params["last_name"]
@checkout.rooms = session[:checkouts][:rooms].to_s
@checkout.general_price = session[:checkouts][:total_price]
@checkout.nights = session[:checkouts][:night]
@checkout.check_in = session[:checkouts][:check_in]
@checkout.check_out = session[:checkouts][:check_out]
@checkout.guest = session[:checkouts][:guests].to_s
@checkout.hotel_id = session[:checkouts][:hotel_id]
@checkout.payment = details.params["address_owner"]
@checkout.user_id = current_user.id if current_user
if @checkout.save
ContactUs.submit_order_admin(@checkout.first_name, @checkout.last_name, @checkout.hotel.user.email, @checkout.check_in, @checkout.check_out, @checkout.general_price, @checkout.rooms).deliver
ContactUs.submit_order_user(@checkout.first_name, @checkout.last_name, @checkout.email_id, @checkout.check_in, @checkout.check_out, @checkout.general_price, @checkout.rooms).deliver
end
session[:checkouts] = nil
session[:checkout_user] = nil
asdf
end
else
redirect_to root_url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment