return new Promise((resolve, reject) => {
// #ifdef MP-WEIXIN
const params = {
timeStamp: opt.timeStamp,
// 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
nonceStr: opt.nonceStr,
// 支付签名随机串,不长于 32 位
package: opt.package,
// 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
signType: opt.signType,
// 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
paySign: opt.paySign,
}
// #endif
// #ifdef APP-PLUS
const params = {
orderInfo: opt
}
// #endif
console.log(params)
uni.requestPayment({
provider: 'wxpay',
...params,
success: res => {
console.log("success:",res);
resolve('success');
},
cancel: res => {
console.log("cancel:",res);
resolve('fail');
},
fail: res => {
console.log("fail:",res);
resolve('fail');
}
});
});

- 发布:2023-08-25 18:47
- 更新:2023-08-26 00:31
- 阅读:365
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: WIn10
HBuilderX类型: 正式
HBuilderX版本号: 3.8.12
手机系统: Android
手机系统版本号: Android 12
手机厂商: 摩托罗拉
手机机型: 刀锋2022
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
后端接口正常返回唤起支付数据
后端接口正常返回唤起支付数据
预期结果:
正常支付
正常支付
实际结果:
uni.requestPayment直接进fail
所有配置均正常
uni.requestPayment直接进fail
所有配置均正常
bug描述:
打包后App无法唤起支付:报错requestPayment:fail service not found

喜欢技术的前端 - QQ---445849201
App 微信支付
1、检查包名和签名是否正确
2、打包或使用自定义基座测试
3、orderInfo参数名全为小写
你这个的检查一下是不是小写
"appid": 'xxx', // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
"noncestr": 'xxx', // 随机字符串
"package": 'xxx', // 固定值
"partnerid": 'xxx', // 微信支付商户号
"prepayid": 'xxx', // 统一下单订单号
"timestamp": 'xxx', // 时间戳(单位:秒)
"sign": 'xxx', // 签名,这里用的 MD5/RSA 签名
7***@qq.com (作者)
已经解决了 谢谢 开了个开放平台就可以了
2023-11-10 14:21
喜欢技术的前端
回复 7***@qq.com: 不客气
2023-11-10 16:04