Class: Dotpay::Response

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

Constant Summary collapse

CHECKSUM_KEYS =
%w(id control t_id amount email service code username password t_status)
STATUS_NEW =
1
STATUS_DONE =
2
STATUS_REJECTED =
3
STATUS_REFUND =
4
STATUS_COMPLAINT =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Response

Returns a new instance of Response.



15
16
17
# File 'lib/dotpay/response.rb', line 15

def initialize(params)
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



13
14
15
# File 'lib/dotpay/response.rb', line 13

def params
  @params
end

Instance Method Details

#amountObject



27
28
29
# File 'lib/dotpay/response.rb', line 27

def amount
  params['amount']
end

#authorized?Boolean

Returns:

  • (Boolean)


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

def authorized?
  params['md5'] == calculate_checksum
end

#controlObject



23
24
25
# File 'lib/dotpay/response.rb', line 23

def control
  params['control']
end

#statusObject



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

def status
  params['t_status'].to_i
end

#status_complaint?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/dotpay/response.rb', line 55

def status_complaint?
  status == STATUS_COMPLAINT
end

#status_done?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/dotpay/response.rb', line 43

def status_done?
  status == STATUS_DONE
end

#status_new?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/dotpay/response.rb', line 39

def status_new?
  status == STATUS_NEW
end

#status_refund?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/dotpay/response.rb', line 51

def status_refund?
  status == STATUS_REFUND
end

#status_rejected?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/dotpay/response.rb', line 47

def status_rejected?
  status == STATUS_REJECTED
end

#t_idObject



19
20
21
# File 'lib/dotpay/response.rb', line 19

def t_id
  params['t_id']
end