Class: Kuaiqian::Response
- Inherits:
-
Object
- Object
- Kuaiqian::Response
- Defined in:
- lib/kuaiqian/response.rb
Constant Summary collapse
- BANK_NAMES =
{'ICBC' => '中国工商银行', 'CMB' => '招商银行', 'CCB' => '中国建设银行', 'ABC' => '中国农业银行', 'BOC_SH' => '中国银行(上海)', 'BOC_GZ' => '中国银行(广州)', 'SPDB' => '上海浦东发展银行', 'BCOM' => '交通银行', 'CMBC' => '中国民生银行', 'SDB' => '深圳发展银行', 'GDB' => '广东发展银行', 'CITIC' => '中信银行', 'HXB' => '华夏银行', 'CIB' => '兴业银行', 'GZRCC' => '广州市农村信用合作社', 'GZCB' => '广州市商业银行', 'SHRCC' => '上海农村商业银行', 'CPSRB' => '中国邮政储蓄', 'CEB' => '中国光大银行', 'BOB' => '北京银行', 'CBHB' => '渤海银行', 'BJRCB' => '北京农村商业银行', 'CNPY' => '中国银联'}
- SIGN_PARAMS =
%w(merchantAcctId version language signType payType bankId orderId orderTime orderAmount dealId bankDealId dealTime payAmount fee ext1 ext2 payResult errCode key)
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
- #bank_deal_id ⇒ Object
- #bank_id ⇒ Object
- #bank_name ⇒ Object
- #deal_id ⇒ Object
- #deal_time ⇒ Object
- #err_code ⇒ Object
- #ext1 ⇒ Object
- #ext2 ⇒ Object
- #fee ⇒ Object
-
#initialize(params) ⇒ Response
constructor
A new instance of Response.
- #key ⇒ Object
- #language ⇒ Object
- #merchant_acct_id ⇒ Object
- #order_amount ⇒ Object
- #order_time ⇒ Object
- #pay_amount ⇒ Object
- #pay_result ⇒ Object
- #pay_type ⇒ Object
- #sign_msg ⇒ Object
- #sign_params ⇒ Object
- #sign_type ⇒ Object
- #successful? ⇒ Boolean
- #valid_sign? ⇒ Boolean
- #version ⇒ Object
Constructor Details
#initialize(params) ⇒ Response
Returns a new instance of Response.
19 20 21 |
# File 'lib/kuaiqian/response.rb', line 19 def initialize(params) @params = params end |
Instance Attribute Details
#attach ⇒ Object (readonly)
Returns the value of attribute attach.
7 8 9 |
# File 'lib/kuaiqian/response.rb', line 7 def attach @attach end |
#order_id ⇒ Object (readonly)
Returns the value of attribute order_id.
7 8 9 |
# File 'lib/kuaiqian/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/kuaiqian/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/kuaiqian/response.rb', line 7 def total_fee @total_fee end |
Instance Method Details
#bank_deal_id ⇒ Object
47 |
# File 'lib/kuaiqian/response.rb', line 47 def bank_deal_id; @params[:bankDealId]; end |
#bank_id ⇒ Object
58 |
# File 'lib/kuaiqian/response.rb', line 58 def bank_id; @params[:bankId]; end |
#bank_name ⇒ Object
59 |
# File 'lib/kuaiqian/response.rb', line 59 def bank_name; BANK_NAMES[bank_id]; end |
#deal_id ⇒ Object
46 |
# File 'lib/kuaiqian/response.rb', line 46 def deal_id; @params[:dealId]; end |
#deal_time ⇒ Object
48 |
# File 'lib/kuaiqian/response.rb', line 48 def deal_time; @params[:dealTime]; end |
#err_code ⇒ Object
55 |
# File 'lib/kuaiqian/response.rb', line 55 def err_code; @params[:errCode]; end |
#ext1 ⇒ Object
52 |
# File 'lib/kuaiqian/response.rb', line 52 def ext1; @params[:ext1]; end |
#ext2 ⇒ Object
53 |
# File 'lib/kuaiqian/response.rb', line 53 def ext2; @params[:ext2]; end |
#fee ⇒ Object
50 |
# File 'lib/kuaiqian/response.rb', line 50 def fee; @params[:fee]; end |
#language ⇒ Object
39 |
# File 'lib/kuaiqian/response.rb', line 39 def language; @params[:language]; end |
#merchant_acct_id ⇒ Object
41 |
# File 'lib/kuaiqian/response.rb', line 41 def merchant_acct_id; @params[:merchantAcctId]; end |
#order_amount ⇒ Object
44 |
# File 'lib/kuaiqian/response.rb', line 44 def order_amount; @params[:orderAmount]; end |
#order_time ⇒ Object
45 |
# File 'lib/kuaiqian/response.rb', line 45 def order_time; @params[:orderTime]; end |
#pay_amount ⇒ Object
49 |
# File 'lib/kuaiqian/response.rb', line 49 def pay_amount; @params[:payAmount]; end |
#pay_result ⇒ Object
54 |
# File 'lib/kuaiqian/response.rb', line 54 def pay_result; @params[:payResult]; end |
#pay_type ⇒ Object
57 |
# File 'lib/kuaiqian/response.rb', line 57 def pay_type; @params[:payType]; end |
#sign_msg ⇒ Object
56 |
# File 'lib/kuaiqian/response.rb', line 56 def sign_msg; @params[:signMsg]; end |
#sign_params ⇒ Object
31 32 33 34 35 36 |
# File 'lib/kuaiqian/response.rb', line 31 def sign_params SIGN_PARAMS.map do |param| value = send(param.underscore) value == '' ? nil : "#{param}=#{value}" end.compact.join('&') end |
#sign_type ⇒ Object
40 |
# File 'lib/kuaiqian/response.rb', line 40 def sign_type; @params[:signType]; end |
#successful? ⇒ Boolean
23 24 25 |
# File 'lib/kuaiqian/response.rb', line 23 def successful? pay_result == '10' && valid_sign? end |
#valid_sign? ⇒ Boolean
27 28 29 |
# File 'lib/kuaiqian/response.rb', line 27 def valid_sign? sign_msg == Digest::MD5.hexdigest(sign_params).upcase end |
#version ⇒ Object
38 |
# File 'lib/kuaiqian/response.rb', line 38 def version; @params[:version]; end |