云函数中进行支付,total_fee不允许获取数字*100?
发布于 6 年前 作者 guiyingmo 8927 次浏览 来自 官方Issues
exports.main = async(event, context) => {
  const wxContext = cloud.getWXContext()
  let {
    orderid,
    body,
    money
  } = event
 
  await db.collection('quote')
    .doc(orderid)
    .field({
      sum: true,
    })
    .get()
    .then(res => {
      money = res.data.sum * 100
    })
 
  const api = tenpay.init(config)
  let result = await api.getPayParams({
    out_trade_no: orderid,
    body: body,
    total_fee: money, //订单金额(分)
    openid: wxContext.OPENID //付款用户的openid
  })
 
  return result

不乘100就可以,但金额就不对了。总不能前端输入金额时+两个0吧。这问题很奇怪。网上的支付都是*100的。

3 回复

money = await db.collection(‘quote’)

.doc(orderid).field({

    sum: true,

}).get().then(res => {

    return res.data.sum * 100

})

现在外面*100 然后转成整型,再放在支付里面呢?

回到顶部