Class: Paysera::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/paysera/response.rb

Constant Summary collapse

PAYSERA_PUBLIC_KEY =
'https://www.webtopay.com/download/public.key'

Instance Method Summary collapse

Constructor Details

#initialize(query, projectid: nil, sign_password: nil) ⇒ Response

Returns a new instance of Response.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/paysera/response.rb', line 11

def initialize(query, projectid: nil, sign_password: nil)
  raise send_error("'data' parameter was not found") if query[:data].nil?
  raise send_error("'ss1' parameter was not found") if query[:ss1].nil?
  raise send_error("'ss2' parameter was not found") if query[:ss2].nil?

  projectid ||= Paysera.projectid
  raise send_error("'projectid' parameter was not found") if projectid.nil?

  sign_password ||= Paysera.sign_password
  raise send_error("'sign_password' parameter was not found") if sign_password.nil?

  raise send_error("Unable to verify 'ss1'") unless valid_ss1? query[:data], query[:ss1], sign_password
  raise send_error("Unable to verify 'ss2'") unless valid_ss2? query[:data], query[:ss2]

  @data = convert_to_hash safely_decode_string(query[:data])

  raise send_error("'projectid' mismatch") if @data[:projectid].to_i != projectid
end

Instance Method Details

#bank?Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/paysera/response.rb', line 35

def bank?
  # Same here, if response have paytext param, then it is bank payment
  @data.key? :paytext
end

#get_dataObject



40
41
42
# File 'lib/paysera/response.rb', line 40

def get_data
  @data
end

#sms?Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'lib/paysera/response.rb', line 30

def sms?
  # Basically if response data have sms param then it is sms payment
  @data.key? :sms
end