Module: WechatPay::PrepayId::App
- Defined in:
- lib/wechat_pay/prepay_id.rb
Class Method Summary collapse
-
.generate(access_token, params) ⇒ Object
required params: traceid, noncestr, package, timestamp.
Class Method Details
.generate(access_token, params) ⇒ Object
required params:
traceid, noncestr, package,
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/wechat_pay/prepay_id.rb', line 10 def self.generate(access_token, params) url = "https://api.weixin.qq.com/pay/genprepay?access_token=#{access_token}" app_signature = generate_app_signature(params) prepay_params = { appid: WechatPay.app_id, app_signature: app_signature, traceid: params[:traceid], noncestr: params[:noncestr], package: params[:package], timestamp: params[:timestamp], sign_method: 'sha1' } RestClient.post(url, JSON.generate(prepay_params)) do |response| JSON.parse(response.body)['prepayid'] end end |