Class: Chinapay::Request::Alipay
- Inherits:
-
Object
- Object
- Chinapay::Request::Alipay
- Defined in:
- lib/chinapay/request/alipay.rb
Constant Summary collapse
- GATEWAY_URL =
"https://mapi.alipay.com/gateway.do?"
Instance Method Summary collapse
-
#initialize(title, total_fee, notify_url, attach, bank_type) ⇒ Alipay
constructor
A new instance of Alipay.
- #url ⇒ Object
Constructor Details
#initialize(title, total_fee, notify_url, attach, bank_type) ⇒ Alipay
Returns a new instance of Alipay.
7 8 9 10 11 12 |
# File 'lib/chinapay/request/alipay.rb', line 7 def initialize(title, total_fee, notify_url, attach, bank_type) @title = title @total_fee = total_fee @notify_url = notify_url @attach = attach end |
Instance Method Details
#url ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/chinapay/request/alipay.rb', line 15 def url sign_parameters = { :service => "create_direct_pay_by_user", :partner => Chinapay.config["alipay"]["parter"], :_input_charset => "utf-8", :return_url => @notify_url, :notify_url => @notify_url, :out_trade_no => Time.now.to_i + Time.now.tv_usec * 1000 + $$, :subject => @title, :payment_type => 1, :seller_email => Chinapay.config["alipay"]["seller"], :total_fee => @total_fee, :extra_common_param => @attach } url_parameters = sign_parameters.merge(:sign_type => "MD5", :sign => md5_sort(sign_parameters)).map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') "https://mapi.alipay.com/gateway.do?" + url_parameters end |