Module: Wechatpay::Api::V3::JSAPI

Included in:
Client
Defined in:
lib/wechatpay/api/v3/jsapi.rb

Instance Method Summary collapse

Instance Method Details

#js_prepay(openid, out_trade_no, description, total_amount, **opts) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/wechatpay/api/v3/jsapi.rb', line 6

def js_prepay(openid, out_trade_no, description, total_amount, **opts)
  data = {
    appid: appid, mchid: mch_id, description: description,
    out_trade_no: out_trade_no, amount: { total: total_amount, currency: 'CNY' },
    payer: { openid: openid }
  }.merge(opts)
  res = post '/v3/pay/transactions/jsapi', data
  res[:prepay_id]
end

#js_sign(package, timestamp, nonce) ⇒ Object



16
17
18
19
# File 'lib/wechatpay/api/v3/jsapi.rb', line 16

def js_sign(package, timestamp, nonce)
  str = [appid, timestamp, nonce, package].join("\n") + "\n"
  sign_content(str)
end