class Tinkoff::Notification
Public Class Methods
new(params)
click to toggle source
# File lib/tinkoff/notification.rb, line 3 def initialize(params) @data = params.slice('TerminalKey', 'OrderId', 'Success', 'Status', 'PaymentId', 'ErrorCode', 'Amount', 'RebillId', 'CardId', 'Pan', 'Token', 'ExpDate', 'DATA') @token_ok = authentic? end
Public Instance Methods
authentic?()
click to toggle source
true - if token is okay, false - otherwise oplata.tinkoff.ru/landing/develop/notifications/tokens
# File lib/tinkoff/notification.rb, line 38 def authentic? values = @data.except('Token').merge({Password: Tinkoff.tinkoff_params[:Password]}) .stringify_keys.sort.to_h.values.join get('Token') == Digest::SHA256.hexdigest(values) end
failure?()
click to toggle source
# File lib/tinkoff/notification.rb, line 28 def failure? !success? end
get(key)
click to toggle source
# File lib/tinkoff/notification.rb, line 20 def get(key) @data[key] end
payment_confirmed?()
click to toggle source
# File lib/tinkoff/notification.rb, line 32 def payment_confirmed? @token_ok && success? && @data['Status'] == 'CONFIRMED' end
success?()
click to toggle source
# File lib/tinkoff/notification.rb, line 24 def success? @token_ok && @data['Success'] == true end