Class: Tenpay::Query
- Inherits:
-
Object
- Object
- Tenpay::Query
- Defined in:
- lib/tenpay/query.rb
Constant Summary collapse
- GATEWAY_URL =
"http://mch.tenpay.com/cgi-bin/cfbi_query_order_v3.cgi"
Instance Method Summary collapse
-
#initialize(order_id, date, attach = nil, charset = 'UTF-8') ⇒ Query
constructor
A new instance of Query.
- #response ⇒ Object
- #sign ⇒ Object
- #sign_params ⇒ Object
- #transaction_id ⇒ Object
Constructor Details
#initialize(order_id, date, attach = nil, charset = 'UTF-8') ⇒ Query
Returns a new instance of Query.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tenpay/query.rb', line 12 def initialize(order_id, date, attach=nil, charset='UTF-8') @cmdno = 1 @date = date.strftime("%Y%m%d") @spid = Tenpay::Config.spid @key = Tenpay::Config.key @order_id = order_id.to_i @attach = attach || 'nil' @charset = charset end |
Instance Method Details
#response ⇒ Object
23 24 25 |
# File 'lib/tenpay/query.rb', line 23 def response @response ||= QueryResponse.new(Net::HTTP.get(URI.parse("#{GATEWAY_URL}?#{params}"))) end |
#sign ⇒ Object
31 32 33 |
# File 'lib/tenpay/query.rb', line 31 def sign @sign ||= Digest::MD5.hexdigest(sign_params).upcase end |
#sign_params ⇒ Object
35 36 37 |
# File 'lib/tenpay/query.rb', line 35 def sign_params @sign_params ||= generate_sign_params end |
#transaction_id ⇒ Object
27 28 29 |
# File 'lib/tenpay/query.rb', line 27 def transaction_id @transaction_id ||= "%s%s%010d" % [@spid, @date, @order_id] end |