Class: JwAlipay::Response
- Inherits:
-
Object
- Object
- JwAlipay::Response
- Includes:
- Sign
- Defined in:
- lib/jw_alipay/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
-
#initialize(res, options = {}) ⇒ Response
constructor
A new instance of Response.
- #parse_xml_data(xml, root = nil) ⇒ Object
Methods included from Sign
#_md5_sign, #_query_string, #_sign_string, #_sort_params, #sign, #verify_sign
Constructor Details
#initialize(res, options = {}) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jw_alipay/response.rb', line 7 def initialize(res, = {}) fields = Hash[res.split('&').map{ |f| f.split('=') }].symbolize_keys sign, sort = fields[:sign], [:sort].nil? ? true : [:sort] if sign and verify_sign(fields, sort) data = fields[[:data_name]] @fields = fields @data = data ? parse_xml_data(data, [:data_root]) : nil elsif sign @error = {:msg => :sign_error, :detail => 'sign error'} else err = fields[[:error_name]] @error = err ? parse_xml_data(err, [:error_root]) : nil end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/jw_alipay/response.rb', line 5 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/jw_alipay/response.rb', line 5 def error @error end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
5 6 7 |
# File 'lib/jw_alipay/response.rb', line 5 def fields @fields end |