代码如下:
// 云函数入口文件
const cloud = require('wx-server-sdk')
const comm = require('common');
cloud.init({ env: '**********' }) // 使用当前云环境
// 云函数入口函数
exports.main = async (event, context) => {
let receiver = {
type: 'PERSONAL_SUB_OPENID',
account: event.openid,
name: event.real_name,
relation_type: 'USER'
};
let data = {
subMchId: '**********',
subAppid: '**********',
nonceStr: comm.generateNonceStr(32),
receiver: JSON.stringify(receiver)
};
let res = await cloud.cloudPay.profitSharingAddReceiver(data);
if (res.returnCode !== 'SUCCESS' || res.resultCode !== 'SUCCESS') {
console.error(res);
return {
result: 50000,
msg: 'add profit sharing receiver failed'
};
}
return {
result: 0,
msg: 'ok'
}
}
返回消息内容如下:
appid: "**********"
errCode: 0
errCodeDes: "无分账权限"
errMsg: "cloudPay.profitSharingAddReceiver:ok"
mchId: "**********"
nonceStr: "1c2c6b351e22d4e7"
receiver: "{"type":"PERSONAL_SUB_OPENID","account":"**********","relation_type":"USER"}"
resultCode: "FAIL"
returnCode: "SUCCESS"
sign: "A6B15BB38A178CF7A743E5BF094D6326934D386CE86D480861D5EC66E4983559"
subAppid: "**********"
subMchId: "**********"
请问需要如何处理
问一下这个云函数是要申请通过了才能用吗,代码是自己写的不,有没有像调用微信支付云函数一样能下载的,感谢