alipay / alipay-sdk-nodejs-all

支付宝开放平台 Alipay SDK for Node.js
https://docs.open.alipay.com/54/103419/
Other
407 stars 64 forks source link

Invalid signature #109

Closed matheusczi closed 4 months ago

matheusczi commented 1 year ago

I'm trying to create a payment URL following the examples but the API call always return the following error:

  code: '40002',
  msg: 'Invalid Arguments',
  subCode: 'isv.invalid-signature',
  subMsg: '验签出错,建议检查签名字符串或签名私钥与应用公钥是否匹配,网关生成的验签字符串为:app_id=9021000123609320&biz_content={"out_trade_no":"商家的交易码,需保持唯一性","total_amount":"0.1","subject":"测试订单"}&charset=utf-8&method=alipay.trade.pay&notify_url=http://www.notify.com/notify&sign_type=RSA2&timestamp=2023-08-03 17:42:46&version=1.0'

The request:

  const result = await alipaySdk.exec('alipay.trade.pay', {
      notify_url: 'http://www.notify.com/notify', 
      bizContent: {
        out_trade_no: '商家的交易码,需保持唯一性',
        total_amount: '0.1',
        subject: '测试订单',
      }
    });

What I'm missing?

troyeagle commented 1 year ago

It seems to be the privateKey / alipayPublicKey configured when alipaySdk initialized is not valid. You could log in the Alipay site, following this guide https://opendocs.alipay.com/common/02kdnf or ask for technical support.