Class: Tenpay::QueryResponse
- Inherits:
-
Object
- Object
- Tenpay::QueryResponse
- Defined in:
- lib/tenpay/query_response.rb
Instance Method Summary collapse
- #attach ⇒ Object
- #cmdno ⇒ Object
- #date ⇒ Object
- #doc ⇒ Object
- #fee_type ⇒ Object
-
#initialize(response) ⇒ QueryResponse
constructor
A new instance of QueryResponse.
- #order_id ⇒ Object
- #pay_info ⇒ Object
- #pay_result ⇒ Object
- #sign ⇒ Object
- #successful? ⇒ Boolean
- #total_fee ⇒ Object
- #transaction_id ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ QueryResponse
Returns a new instance of QueryResponse.
3 4 5 |
# File 'lib/tenpay/query_response.rb', line 3 def initialize(response) @body = response end |
Instance Method Details
#attach ⇒ Object
19 20 21 |
# File 'lib/tenpay/query_response.rb', line 19 def attach @attach ||= (doc / 'attach').inner_text end |
#cmdno ⇒ Object
23 24 25 |
# File 'lib/tenpay/query_response.rb', line 23 def cmdno @cmdno ||= (doc / 'cmdno').inner_text end |
#date ⇒ Object
27 28 29 |
# File 'lib/tenpay/query_response.rb', line 27 def date @date ||= (doc / 'date').inner_text end |
#doc ⇒ Object
15 16 17 |
# File 'lib/tenpay/query_response.rb', line 15 def doc @doc ||= Hpricot(@body) end |
#fee_type ⇒ Object
31 32 33 |
# File 'lib/tenpay/query_response.rb', line 31 def fee_type @fee_type ||= (doc / 'fee_type').inner_text end |
#order_id ⇒ Object
43 44 45 |
# File 'lib/tenpay/query_response.rb', line 43 def order_id @order_id ||= (doc / 'sp_billno').inner_text end |
#pay_info ⇒ Object
35 36 37 |
# File 'lib/tenpay/query_response.rb', line 35 def pay_info @pay_info ||= (doc / 'pay_info').inner_text end |
#pay_result ⇒ Object
39 40 41 |
# File 'lib/tenpay/query_response.rb', line 39 def pay_result @pay_result ||= (doc / 'pay_result').inner_text end |
#sign ⇒ Object
55 56 57 |
# File 'lib/tenpay/query_response.rb', line 55 def sign @sign ||= (doc / 'sign').inner_text end |
#successful? ⇒ Boolean
11 12 13 |
# File 'lib/tenpay/query_response.rb', line 11 def successful? valid? && pay_result == '0' end |
#total_fee ⇒ Object
47 48 49 |
# File 'lib/tenpay/query_response.rb', line 47 def total_fee @total_fee ||= (doc / 'total_fee').inner_text end |
#transaction_id ⇒ Object
51 52 53 |
# File 'lib/tenpay/query_response.rb', line 51 def transaction_id @transaction_id ||= (doc / 'transaction_id').inner_text end |
#valid? ⇒ Boolean
7 8 9 |
# File 'lib/tenpay/query_response.rb', line 7 def valid? sign == Digest::MD5.hexdigest(sign_params).upcase end |