var cloud = require('wx-server-sdk')
crypto = require('crypto')
request = require('request')
NodeRSA = require('node-rsa')
Form = require('./Form.class')
cloud.init({
env: 'xxxxxx'
})
const db = cloud.database()
exports.main = async (event, context) => {
const rq = options =>
new Promise((resolve, reject) => {...})
var facilitator = event.facilitator=='undefined'?false:event.facilitator
console.log(`${facilitator?'服务商':'直连'}模式`)
var mchid = facilitator?'160xxxxx92':'16xxxxx84'
var appId = 'wx41xxxxxxfd6'
var APIv3Key = facilitator?'xxxxxxxxx':'xxxxxxxxxx'
var cert_Doc = facilitator?'certificates':'direct_certificates'
var timeStamp = parseInt(Date.now()/1000)
var nonce_str = Math.random().toString(36).substr(2, 13)
var url = 'https://api.mch.weixin.qq.com'+event.url
var certificates = (await db.collection('a-data').doc(cert_Doc).get()).data
var {serial_no} = certificates
var {wx_serial_no} = certificates
var RSAoaep = (e)=>{...}
const getHeaders = (method,meta)=>{...}
if(event.url.indexOf('/transactions/jsapi')>-1){
var {data} = event
if(facilitator){
data.sp_mchid = mchid
data.sp_appid = appId
}else{
data.mchid = mchid
data.appid = appId
}
.....
return {
payment,
errMsg:'下单成功',
errCode:0
}
}
if(event.url=='/v3/refund/domestic/refunds'){
....
}
if(event.url=='/v3/applyment4sub/applyment/'){
....
}
if(event.url=='/v3/merchant/media/upload'){
.....
}
if(event.url.indexOf('/v3/applyment4sub/applyment/business_code')>-1||event.url.indexOf('/v3/applyment4sub/applyment/applyment_id')>-1){
......
}
if(event.url=='/v3/certificates'){
......
}
}
感兴趣请私信交流
强呀。
看到全家桶,饿了。