alipay-sdk-nodejs-all icon indicating copy to clipboard operation
alipay-sdk-nodejs-all copied to clipboard

demo报错

Open DragonGuo666 opened this issue 1 year ago • 2 comments

jietu1

node:internal/crypto/sig:222 signature = getArrayBufferOrView(signature, 'signature', sigEncoding); ^

TypeError [ERR_INVALID_ARG_TYPE]: The "signature" argument must be of type string or an instance of ArrayBuffer, Buffer, TypedArray, or DataView. Received undefined at Verify.verify (node:internal/crypto/sig:222:15) at verifySignatureV3 (file:///root/node_modules/alipay-sdk/dist/esm/util.js:123:10) at #curl (file:///root/node_modules/alipay-sdk/dist/esm/alipay.js:401:18) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async AlipaySdk.curl (file:///root/node_modules/alipay-sdk/dist/esm/alipay.js:141:16) at async main (file:///root/alipaysdk_node/quanming.mjs:19:20) { code: 'ERR_INVALID_ARG_TYPE' }

Node.js v20.17.0

DragonGuo666 avatar Sep 27 '24 06:09 DragonGuo666

请添加一下 debug 环境变量重新运行一下,看看日志,里面打印了 alipay-signature headers 的值,目前怀疑这个值是空的。

NODE_DEBUG=alipay-sdk*

fengmk2 avatar Sep 30 '24 06:09 fengmk2

还有你的 endpoint 不应该手动设置,走 v3 接口就是默认值 endpoint: 'https://openapi.alipay.com', 而不是 endpoint: 'https://openapi.alipay.com/gateway.do'

fengmk2 avatar Sep 30 '24 06:09 fengmk2