标签:bsp err exp nod openid open hash iges init
// 云函数入口文件 const cloud = require(‘wx-server-sdk‘) cloud.init() var wechat = require(‘./wechat_config.js‘); var body_data = require(‘./bodyData.js‘); var non_str_random = require(‘./non_str_random.js‘); var non_str = non_str_random(); var out_trade_no = Date.parse(new Date()); var cryptoMO = require(‘crypto‘); var request = require(‘request‘); var fs = require(‘fs‘); var path = require(‘path‘); var key = fs.readFileSync(path.join(__dirname, "./apiclient_key.pem")); var cert = fs.readFileSync(path.join(__dirname, "./apiclient_cert.pem")); // 云函数入口函数 exports.main = async (event, context) => { const wxContext = cloud.getWXContext() var str = `amount=${event.total_fee}&check_name=NO_CHECK&desc=奖金&mch_appid=${wechat.mch_appid}&mchid=${wechat.mchid}&nonce_str=${non_str}&openid=${wxContext.OPENID}&partner_trade_no=${out_trade_no}&spbill_create_ip=${wechat.ip}&key=${wechat.key}`; console.log(str); var sign = cryptoMO.createHash(‘md5‘).update(str).digest(‘hex‘); console.log(sign); var temp_body_data = body_data(wechat, non_str, wxContext.OPENID, out_trade_no, event.total_fee, sign); console.log(temp_body_data); return new Promise((resolve, reject) => request({ url: wechat.url, method: ‘POST‘, body: temp_body_data, key: key, cert: cert }, (err, res, body) => { console.log(body) }) ) }
小程序 云开发 node js 企业付款到零钱 证书路径 引用方法 签名等 关键代码
标签:bsp err exp nod openid open hash iges init
原文地址:https://www.cnblogs.com/shaoing/p/11018480.html