WxApp/cloud/pay/index.js

22 lines
909 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
// 云函数入口函数
exports.main = async (event, context) => {
console.log("有进来")
const res = await cloud.cloudPay.unifiedOrder({
"functionName": "pay_success", // 支付结果通知回调云函数名
"envId": "zdt2024-9g7pr48u64f887f0", // 结果通知回调云函数环境
"subMchId": "1684540409", // 商户号
"nonceStr": event.nonceStr,//随机字符串,主要保证签名不可预测
"body": "解锁悄悄话", // 商品描述
"outTradeNo": event.outTradeNo, // 商户订单号
"totalFee": event.totalFee, // 总金额
"spbillCreateIp": "127.0.0.1", // 终端 IP,社区说可以随便填不知道为什么可能会出bug
"tradeType": "JSAPI",//交易类型
})
console.log("这里" + res)
return res
}