借助小程序云开发实现小程序支付功能(含源码),2024年最新javaee毕业设计

if (!goods.data.length) {

 return new Res({

  code: 1,

  message: '找不到商品'

 });

}



// 在云函数中提取数据,包括名称、价格才更合理安全,

// 因为从端里传过来的商品数据都是不可靠的

let good = goods.data[0];



// 拼凑微信支付统一下单的参数

const curTime = Date.now();

const tradeNo = `${goodId}-${curTime}`;

const body = good.name;

const spbill_create_ip = ip.address() || '127.0.0.1';

// 云函数暂不支付 http 触发器,因此这里回调 notify_url 可以先随便填。

const notify_url = 'http://www.qq.com'; //'127.0.0.1';

const total_fee = good.price;

const time_stamp = '' + Math.ceil(Date.now() / 1000);

const out_trade_no = `${tradeNo}`;

const sign_type = WXPayConstants.SIGN_TYPE_MD5;



let orderParam = {

 body,

 spbill_create_ip,

 notify_url,

 out_trade_no,

 total_fee,

 openid,

 trade_type: 'JSAPI',

 timeStamp: time_stamp,

};



// 调用 wx-js-utils 中的统一下单方法

const {

 return_code,

 ...restData

} = await pay.un
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值