Class: Tenpay::Response
- Inherits:
-
Object
- Object
- Tenpay::Response
- Defined in:
- lib/tenpay/response.rb
Instance Attribute Summary collapse
-
#attach ⇒ Object
readonly
Returns the value of attribute attach.
-
#order_id ⇒ Object
readonly
Returns the value of attribute order_id.
-
#pay_time ⇒ Object
readonly
Returns the value of attribute pay_time.
-
#total_fee ⇒ Object
readonly
Returns the value of attribute total_fee.
Instance Method Summary collapse
-
#initialize(params) ⇒ Response
constructor
A new instance of Response.
- #successful? ⇒ Boolean
- #valid_sign? ⇒ Boolean
Constructor Details
#initialize(params) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tenpay/response.rb', line 9 def initialize(params) @cmdno = params[:cmdno] || '' @date = params[:date] || '' @fee_type = params[:fee_type] || '' @pay_info = params[:pay_info] || '' @pay_result = params[:pay_result] || '' @pay_time = Time.at((params[:pay_time] || '0').to_i) @sign = params[:sign] || '' @order_id = (params[:sp_billno] || '').to_i @transaction_id = params[:transaction_id] || '' @total_fee = params[:total_fee] || '' @attach = params[:attach] || '' @spid = Tenpay::Config.spid @key = Tenpay::Config.key end |
Instance Attribute Details
#attach ⇒ Object (readonly)
Returns the value of attribute attach.
7 8 9 |
# File 'lib/tenpay/response.rb', line 7 def attach @attach end |
#order_id ⇒ Object (readonly)
Returns the value of attribute order_id.
7 8 9 |
# File 'lib/tenpay/response.rb', line 7 def order_id @order_id end |
#pay_time ⇒ Object (readonly)
Returns the value of attribute pay_time.
7 8 9 |
# File 'lib/tenpay/response.rb', line 7 def pay_time @pay_time end |
#total_fee ⇒ Object (readonly)
Returns the value of attribute total_fee.
7 8 9 |
# File 'lib/tenpay/response.rb', line 7 def total_fee @total_fee end |
Instance Method Details
#successful? ⇒ Boolean
26 27 28 |
# File 'lib/tenpay/response.rb', line 26 def successful? @pay_info == 'OK' && @pay_result == '0' && valid_sign? end |
#valid_sign? ⇒ Boolean
30 31 32 |
# File 'lib/tenpay/response.rb', line 30 def valid_sign? @sign == Digest::MD5.hexdigest(sign_params).upcase end |