收藏
回答

云开发微信支付回调函数报错(user code exception caught)?

错误信息

返回结果

{"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"ReferenceError: enent is not defined\n at Runtime.exports.main [as handler] (/var/user/index.js:16:21)\n at Runtime.handleOnce (/var/runtime/node10/Runtime.engine.js:214:23)\n at Timeout.setTimeout [as _onTimeout] (/var/runtime/node10/Runtime.engine.js:54:12)\n at ontimeout (timers.js:436:11)\n at tryOnTimeout (timers.js:300:5)\n at listOnTimeout (timers.js:263:5)\n at Timer.processTimers (timers.js:223:10)","statusCode":430}

ERROR RequestId:024fa213-5ac4-11eb-8d8d-52540036d55c Result:{"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"ReferenceError: enent is not defined\n at Runtime.exports.main [as handler] (/var/user/index.js:16:21)\n at Runtime.handleOnce (/var/runtime/node10/Runtime.engine.js:214:23)\n at Timeout.setTimeout [as _onTimeout] (/var/runtime/node10/Runtime.engine.js:54:12)\n at ontimeout (timers.js:436:11)\n at tryOnTimeout (timers.js:300:5)\n at listOnTimeout (timers.js:263:5)\n at Timer.processTimers (timers.js:223:10)","statusCode":430}

END RequestId:024fa213-5ac4-11eb-8d8d-52540036d55c

Report RequestId:024fa213-5ac4-11eb-8d8d-52540036d55c Duration:6ms Memory:256MB MemUsage:26.394531MB

回调函数

exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const db = cloud.database()
  console.log('支付回调:', event)
  const orderId = event.outTradeNo
  const subMchId = event.subMchId
  const returnCode = event.returnCode
  const orderType = enent.attach
  if (returnCode == 'SUCCESS') {
    if (orderType == 'Vip') {
      const result = await db.collection('VipOrder')
        .where({
          _id: orderId
        })
        .update({
          data: {
            outTradeNo: orderId,
          }
        })
      const res = {
        errcode: 0,
        errmsg: '',
        result: result,
      }
      return res
    } else {
      const result = await db.collection('SaleOrder')
        .where({
          _id: orderId
        })
        .update({
          data: {
            status: 1,
            subMchId: subMchId,
            outTradeNo: orderId,
          }
        })
      const res = {
        errcode: 0,
        errmsg: '',
        result: result,
      }
      return res
    }
  }
}


回答关注问题邀请回答
收藏

2 个回答

  • Mr.Zhao
    Mr.Zhao
    2021-01-20

    2021-01-20
    有用 2
    回复 1
    • Qiu (吉²)
      Qiu (吉²)
      2021-01-20
      非常感谢🙏。
      2021-01-20
      1
      回复
  • 老张
    老张
    2021-01-20

    enent is not defined

    这样的错误信息都不会排查的话,你要考虑是否继续吃开发这碗饭了。

    2021-01-20
    有用 1
    回复 1
    • Qiu (吉²)
      Qiu (吉²)
      2021-01-20
      嗯嗯,谢谢批评指正🙏
      2021-01-20
      回复
登录 后发表内容
问题标签