【苍穹外卖】个人小程序模拟实现微信支付

您所在的位置:网站首页 微信支付页面数字修改 【苍穹外卖】个人小程序模拟实现微信支付

【苍穹外卖】个人小程序模拟实现微信支付

2024-07-01 20:39| 来源: 网络整理| 查看: 265

事先声明: _________本文 并没有 真正调用微信支付这个接口,如果你想调用微信支付这个接口,那么 无法满足 你的需求,非常抱歉。

由于我注册的小程序也是个体户,所以没有权限使用《微信支付接口》。但为了实现苍穹外卖的完整功能,只能死马当活马医,模拟出用户支付成功的结果。 具体方式是:跳过了调用接口的这个步骤,用户点击《确认支付》会直接支付成功,见效果图: 请添加图片描述 我就只贴出需要修改的部分,其他代码都是用的黑马的。

小程序里需要修改的代码:

在小程序page/pay/index.js中的238行左右,将支付详情和订单倒计时这两个注释之间的代码换成下面的。

// 支付详情 handleSave: function handleSave() { var _this = this; if (this.timeout) { (0, _api.cancelOrder)(this.orderId).then(function (res) { }); uni.redirectTo({ url: '/pages/details/index?orderId=' + this.orderId }); } else { //如果支付成功进入成功页 clearTimeout(this.times); var params = { orderNumber: this.orderDataInfo.orderNumber, payMethod: this.activeRadio === 0 ? 1 : 2 }; (0, _api.paymentOrder)(params).then(function (res) { if (res.code === 1) { console.log("hcs,支付了!") wx.showModal({ title: '提示', content: '支付成功', success: function () { uni.redirectTo({ url: '/pages/success/index?orderId=' + _this.orderId }); } }) console.log('支付成功!') } else { console.log("hcs,支付失败了!") wx.showModal({ title: '提示', content: res.msg }) } }); } }, // 订单倒计时 服务器中需要修改的代码:

只需修改OrderServiceImpl.class中的代码:比对着方法名去改即可。

public OrderPaymentVO payment(OrdersPaymentDTO ordersPaymentDTO) { OrderPaymentVO vo = new OrderPaymentVO(); vo.setNonceStr("666"); vo.setPaySign("hhh"); vo.setPackageStr("prepay_id=wx"); vo.setSignType("RSA"); vo.setTimeStamp("1670380960"); return vo; }

另外,除了这个方法,这个类中的订单取消和订单拒绝方法都需要注释掉这部分代码:

String refund = weChatPayUtil.refund( ordersDB.getNumber(), ordersDB.getNumber(), new BigDecimal(0.01), new BigDecimal(0.01));

完成,是不是也没想象中的那么难。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3