完全按uni-pay2文档配置示例程序,点击“打开收银台”或者“直接支付”就会弹出报错提示。
查了云函数uni-pay-co的日志,除了入参,后面都是报错:
[uni-pay-co/ac1cc30-------------隐藏/331ms/ERROR] data: { provider: 'wxpay',
total_fee: 1,
user_id: undefined,
openid: 'om-----------------------------隐藏',
order_no: 'test1718718280579',
out_trade_no: 'test1718718280579-1',
description: '测试订单',
type: 'test',
qr_code: undefined,
custom: { a: 'a', b: 1 },
other: undefined,
clientInfo:
{ scene: 1001,
batteryLevel: 100,
benchmarkLevel: -1,
memorySize: 2048,
safeArea:
{ top: 47,
left: 0,
right: 390,
bottom: 810,
width: 390,
height: 763 },
screenWidth: 390,
screenHeight: 844,
screenTop: 91,
windowWidth: 390,
windowHeight: 753,
statusBarHeight: 47,
enableDebug: false,
fontSizeScaleFactor: 0.96,
mode: 'default',
bluetoothEnabled: true,
locationEnabled: true,
wifiEnabled: true,
locationReducedAccuracy: true,
albumAuthorized: true,
bluetoothAuthorized: true,
cameraAuthorized: true,
locationAuthorized: true,
microphoneAuthorized: true,
notificationAuthorized: true,
notificationAlertAuthorized: true,
notificationBadgeAuthorized: true,
notificationSoundAuthorized: true,
phoneCalendarAuthorized: true,
deviceOrientation: 'portrait',
devicePixelRatio: 3,
deviceId: '17187051061335100024',
safeAreaInsets: { top: 47, left: 0, right: 0, bottom: 34 },
appId: '__UNI__3802FC5',
appName: 'uni-pay示例1',
appVersion: '1.0.0',
appVersionCode: '100',
appLanguage: 'zh-Hans',
uniCompileVersion: '4.15',
uniRuntimeVersion: '4.15',
uniPlatform: 'mp-weixin',
deviceBrand: 'devtools',
deviceModel: 'iPhone 12/13 (Pro)',
deviceType: 'phone',
osName: 'ios',
osVersion: '10.0.1',
hostVersion: '8.0.5',
hostLanguage: 'zh-CN',
hostName: 'WeChat',
hostSDKVersion: '3.4.7',
hostFontSizeSetting: 16,
windowTop: 0,
windowBottom: 0,
locale: 'zh-Hans',
secretType: 'none',
os: 'ios',
clientIP: '1-----------------------------隐藏',
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1 wechatdevtools/1.06.2404301 MicroMessenger/8.0.5 webview/',
platform: 'mp-weixin',
source: 'client',
requestId: 'ac1c-----------------------------隐藏' },
cloudInfo:
{ provider: 'aliyun',
spaceId: 'mp-------------------------------------------------------------隐藏',
useOldSpaceId: false,
functionName: 'uni-pay-co',
functionType: 'cloudobject' },
wxpay_virtual: undefined }
[uni-pay-co/ac1cc30-------------隐藏/332ms/ERROR] getOrderInfoParam: { openid: 'o-------------隐藏',
body: '测试订单',
outTradeNo: 'test1718718280579-1',
totalFee: 1,
notifyUrl: 'https://fc-mp--------------隐藏.next.bspapp.com/uni-pay-co/payNotify/wxpay-mp',
tradeType: 'JSAPI' }
[uni-pay-co/ac1cc30-------------隐藏/332ms/ERROR] err: Error: 签名错误,请检查后再试
at t.default._parse (/tmp/function/@common_modules/uni-pay/index.js:1:44373)
at t.default._requestWxpay (/tmp/function/@common_modules/uni-pay/index.js:1:45950)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
[uni-pay-co/ac1cc30-------------隐藏/333ms/ERROR] errMsg: 签名错误,请检查后再试
请求响应状态: success
systhinker (作者)
就是按这个文档来的,只是没有重新生成密钥,因为还有其他小程序和公众号在用,怕造成影响。
这个文档里面写的是P12,对吗?
另外,这个文档有些老了,现在微信支付商户后台显示的跟截图已经不一样了。
2024-06-19 12:49
systhinker (作者)
重新生成密钥的作用是什么?能够从我发的云函数日志推测出问题所在吗?
2024-06-19 14:27
DCloud_uniCloud_VK
回复 h***@qq.com: 你截图的微信支付v2的报的错误是签名错误,那就是密钥不对或者密钥和mchId不匹配
2024-06-19 14:31
DCloud_uniCloud_VK
建议重新上传下 uni-config-center 公共模块试试
2024-06-19 14:32
systhinker (作者)
回复 DCloud_uniCloud_VK: 重传uni-config-center 试过了,问题还是一样的。密钥和mchId不匹配的问题应该不存在,因为其他小程序也在用这个商户号和密钥,支付正常。而且我也在电脑上导入f12证书,用商户号可以解密,说明两者是匹配的
2024-06-19 15:26
DCloud_uniCloud_VK
回复 h***@qq.com: 私发下你的空间id
2024-06-19 16:00
systhinker (作者)
回复 DCloud_uniCloud_VK: 已发,谢谢大佬!
2024-06-19 17:36
systhinker (作者)
回复 DCloud_uniCloud_VK: 搞定了,原来确实是密钥不对,截图微信识别错了,把0识别成O, 谢谢啦
2024-06-20 00:12