Created
February 19, 2015 13:39
-
-
Save kakawka/bca86c58b1e500837a12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def after_payment | |
p = params | |
booking = Booking.find(params[:orderId]) | |
generated_hash = Digest::MD5.hexdigest([Setting.find_by_name('rbkmoney').value, p['orderID'], "Бронирование номера #{booking.room.name}", | |
Setting.find_by_name('rbkmoneyAccount').value, booking.price, "RUR", p['status'], '', booking.email, p['paymentData'], | |
Setting.find_by_name('secretKey').value].join('::')) | |
if p['hash'] == generated_hash | |
if p['status'] == 5 | |
booking.update_attribute(:state, "paid") | |
BookingMailer.paid(booking.id).deliver | |
require 'SMSApi' | |
sms = SMSApi.new | |
sms.send(booking.phone, "Оплата получена. Бронирование подтверждено. Вам отправлено письмо на e-mail") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment