Class: Kuaiqian::Request
- Inherits:
-
Object
- Object
- Kuaiqian::Request
- Defined in:
- lib/kuaiqian/request.rb
Constant Summary collapse
- GATEWAY_URL =
"https://www.99bill.com/gateway/recvMerchantInfoAction.htm"
- PARAMS =
%w(inputCharset bgUrl version language signType merchantAcctId payerName payerContactType payerContact orderId orderAmount orderTime productName productNum productId productDesc ext1 ext2 payType redoFlag pid)
Instance Method Summary collapse
- #bg_url ⇒ Object
- #ext1 ⇒ Object
- #ext2 ⇒ Object
- #html_params ⇒ Object
-
#initialize(product_name, order_id, order_time, total_fee, return_url, pay_type = '00', attach = nil, payer_name = '用户') ⇒ Request
constructor
A new instance of Request.
- #input_charset ⇒ Object
- #key ⇒ Object
- #language ⇒ Object
- #merchant_acct_id ⇒ Object
- #order_amount ⇒ Object
- #order_id ⇒ Object
- #order_time ⇒ Object
- #page_url ⇒ Object
- #pay_type ⇒ Object
- #payer_contact ⇒ Object
- #payer_contact_type ⇒ Object
- #payer_name ⇒ Object
- #pid ⇒ Object
- #product_desc ⇒ Object
- #product_id ⇒ Object
- #product_name ⇒ Object
- #product_num ⇒ Object
- #redo_flag ⇒ Object
- #sign_msg ⇒ Object
- #sign_params ⇒ Object
- #sign_type ⇒ Object
- #url ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(product_name, order_id, order_time, total_fee, return_url, pay_type = '00', attach = nil, payer_name = '用户') ⇒ Request
Returns a new instance of Request.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kuaiqian/request.rb', line 10 def initialize(product_name, order_id, order_time, total_fee, return_url, pay_type='00', attach=nil, payer_name='用户') @bank_type = 0 @fee_type = 1 @order_id = order_id.to_s @total_fee = total_fee.to_i.to_s @order_time = order_time.strftime("%Y%m%d%H%M%S") @product_name = product_name @pay_type = pay_type @return_url = return_url @ext1 = attach || '' @payer_name = payer_name end |
Instance Method Details
#bg_url ⇒ Object
32 |
# File 'lib/kuaiqian/request.rb', line 32 def bg_url; @return_url; end |
#ext1 ⇒ Object
49 |
# File 'lib/kuaiqian/request.rb', line 49 def ext1; @ext1; end |
#ext2 ⇒ Object
50 |
# File 'lib/kuaiqian/request.rb', line 50 def ext2; ''; end |
#html_params ⇒ Object
66 67 68 69 70 71 |
# File 'lib/kuaiqian/request.rb', line 66 def html_params PARAMS.map do |param| value = send(param.underscore) value == '' ? nil : "#{param}=#{CGI.escape(value)}" end.compact.join('&') end |
#input_charset ⇒ Object
31 |
# File 'lib/kuaiqian/request.rb', line 31 def input_charset; '1'; end |
#language ⇒ Object
35 |
# File 'lib/kuaiqian/request.rb', line 35 def language; '1'; end |
#merchant_acct_id ⇒ Object
37 |
# File 'lib/kuaiqian/request.rb', line 37 def merchant_acct_id; Kuaiqian::Config.spid; end |
#order_amount ⇒ Object
43 |
# File 'lib/kuaiqian/request.rb', line 43 def order_amount; @total_fee; end |
#order_id ⇒ Object
42 |
# File 'lib/kuaiqian/request.rb', line 42 def order_id; @order_id; end |
#order_time ⇒ Object
44 |
# File 'lib/kuaiqian/request.rb', line 44 def order_time; @order_time; end |
#page_url ⇒ Object
33 |
# File 'lib/kuaiqian/request.rb', line 33 def page_url; ''; end |
#pay_type ⇒ Object
51 |
# File 'lib/kuaiqian/request.rb', line 51 def pay_type; @pay_type; end |
#payer_contact ⇒ Object
40 |
# File 'lib/kuaiqian/request.rb', line 40 def payer_contact; ''; end |
#payer_contact_type ⇒ Object
39 |
# File 'lib/kuaiqian/request.rb', line 39 def payer_contact_type; '1'; end |
#payer_name ⇒ Object
38 |
# File 'lib/kuaiqian/request.rb', line 38 def payer_name; @payer_name; end |
#pid ⇒ Object
53 |
# File 'lib/kuaiqian/request.rb', line 53 def pid; ''; end |
#product_desc ⇒ Object
48 |
# File 'lib/kuaiqian/request.rb', line 48 def product_desc; ''; end |
#product_id ⇒ Object
47 |
# File 'lib/kuaiqian/request.rb', line 47 def product_id; ''; end |
#product_name ⇒ Object
45 |
# File 'lib/kuaiqian/request.rb', line 45 def product_name; @product_name; end |
#product_num ⇒ Object
46 |
# File 'lib/kuaiqian/request.rb', line 46 def product_num; '1'; end |
#redo_flag ⇒ Object
52 |
# File 'lib/kuaiqian/request.rb', line 52 def redo_flag; "0"; end |
#sign_msg ⇒ Object
62 63 64 |
# File 'lib/kuaiqian/request.rb', line 62 def sign_msg Digest::MD5.hexdigest(sign_params).upcase end |
#sign_params ⇒ Object
55 56 57 58 59 60 |
# File 'lib/kuaiqian/request.rb', line 55 def sign_params (PARAMS + ['key']).map do |param| value = send(param.underscore) value == '' ? nil : "#{param}=#{value}" end.compact.join('&') end |
#sign_type ⇒ Object
36 |
# File 'lib/kuaiqian/request.rb', line 36 def sign_type; '1'; end |
#url ⇒ Object
27 28 29 |
# File 'lib/kuaiqian/request.rb', line 27 def url "#{GATEWAY_URL}?#{html_params}&signMsg=#{sign_msg}" end |
#version ⇒ Object
34 |
# File 'lib/kuaiqian/request.rb', line 34 def version; 'v2.0'; end |