开发环境是 HBuildX 的 3.8.4.20230531,测试手机是 华为畅享10,使用官网上提供的 uni.requestPayment,我直接把官网上写的例子替换了 orderInfo 的值
// orderInfo 的值是从官网上复制过来的
const orderInfo =
'app_id=2015052600090779&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22seller_id%22%3A%22%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22total_amount%22%3A%220.02%22%2C%22subject%22%3A%221%22%2C%22body%22%3A%22%E6%88%91%E6%98%AF%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%22%2C%22out_trade_no%22%3A%22314VYGIAGG7ZOYY%22%7D&charset=utf-8&method=alipay.trade.app.pay&sign_type=RSA2×tamp=2016-08-15%2012%3A12%3A15&version=1.0&sign=MsbylYkCzlfYLy9PeRwUUIg9nZPeN9SfXPNavUCroGKR5Kqvx0nEnd3eRmKxJuthNUx4ERCXe552EV9PfwexqW%2B1wbKOdYtDIb4%2B7PL3Pc94RZL0zKaWcaY3tSL89%2FuAVUsQuFqEJdhIukuKygrXucvejOUgTCfoUdwTi7z%2BZzQ%3D';
uni.getProvider({
service: 'payment',
success: res => {
if (JSON.stringify(res.provider).indexOf('alipay')) {
console.log('调用支付宝');
uni.requestPayment({
provider: 'alipay', //固定值为"alipay"
orderInfo: orderInfo,
success: res => {
console.log('支付成功');
const rawdata = JSON.parse(res.rawdata);
console.log(rawdata);
},
fail: err => {
console.log('支付失败:' + JSON.stringify(err));
}
});
}
},
fail: err => {
console.log('调用支付宝失败');
console.log(err);
}
});
结果手机屏幕上显示商家参数异常,uni.requestPayment 的 fail 函数中打印显示是用户取消了支付(是显示报错后才点击了取消)。
晨扬 (作者)
格式是没错的吧,我把后端的数据按照这个格式拼接出来换上去,结果还是显示商家参数异常
2023-07-11 18:51