t***@outlook.com
t***@outlook.com
  • 发布:2025-05-26 02:02
  • 更新:2025-05-26 02:02
  • 阅读:437

uniapp+unicloud开发微信小程序商家转账功能,签名报错

分类:uni-app

一、报错内容:
detail: {issue: "sign not match"}
field: "signature"
location: "authorization"
sign_information:
method: "POST"
sign_message_length: 488
truncated_sign_message: "POST↵/v3/fund-app/mch-transfer/transfer-bills↵1748222858↵fZ85ihB3pMmD8S6P3↵{"appid"↵"
url: "/v3/fund-app/mch-transfer/transfer-bills"
proto: Object
proto: Object
message: "错误的签名,验签失败"

二、背景:
使用云函数开发微信小程序中微信支付的商家转账功能:
签名部分代码采用unicloud云函数:
// 构建待签名字符串
const message = ${method}\n${path2}\n${timestamp}\n${nonceStr}\n${body}\n;

// 使用商户私钥进行签名  
const sign = crypto  
    .createSign('sha256')  
    .update(message)  
    .sign(prikey, 'base64');  

疑问1:
使用的地址是否正确:url: "/v3/fund-app/mch-transfer/transfer-bills"

疑问2:是否有官方案例看下如何正确的签名操作?

2025-05-26 02:02 负责人:无 分享
已邀请:

要回复问题请先登录注册