Class: AdaptivePay::Response
- Inherits:
-
Object
- Object
- AdaptivePay::Response
show all
- Defined in:
- lib/adaptive_pay/response.rb
Instance Method Summary
collapse
Constructor Details
#initialize(interface, type, response) ⇒ Response
Returns a new instance of Response.
4
5
6
7
8
9
|
# File 'lib/adaptive_pay/response.rb', line 4
def initialize(interface, type, response)
@type = type
@base_page_url = interface.base_page_url
@attributes = {}
parse response
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/adaptive_pay/response.rb', line 46
def method_missing(name, *args)
if @attributes.has_key?(name.to_s.camelize(:lower))
@attributes[name.to_s.camelize(:lower)]
else
super
end
end
|
Instance Method Details
#completed? ⇒ Boolean
28
29
30
|
# File 'lib/adaptive_pay/response.rb', line 28
def completed?
payment_exec_status == "COMPLETED"
end
|
#created? ⇒ Boolean
20
21
22
|
# File 'lib/adaptive_pay/response.rb', line 20
def created?
payment_exec_status == "CREATED"
end
|
#failure? ⇒ Boolean
15
16
17
|
# File 'lib/adaptive_pay/response.rb', line 15
def failure?
!@success
end
|
#payment_page_url ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/adaptive_pay/response.rb', line 33
def payment_page_url
case @type
when :preapproval
"#{@base_page_url}/webscr?cmd=_ap-preapproval&preapprovalkey=#{URI.escape(preapproval_key)}"
when :payment
"#{@base_page_url}/webscr?cmd=_ap-payment&paykey=#{URI.escape(pay_key)}"
end
end
|
#pending? ⇒ Boolean
24
25
26
|
# File 'lib/adaptive_pay/response.rb', line 24
def pending?
payment_exec_status == "PENDING"
end
|
#read_attribute(name) ⇒ Object
42
43
44
|
# File 'lib/adaptive_pay/response.rb', line 42
def read_attribute(name)
@attributes[name]
end
|
#success? ⇒ Boolean
11
12
13
|
# File 'lib/adaptive_pay/response.rb', line 11
def success?
!!@success
end
|