Skip to content

Conversation

MrOzawa
Copy link

@MrOzawa MrOzawa commented Apr 7, 2025

修改内容:
1.添加微信支付公钥证书和微信支付公钥ID的变量、接口,老商户号非必填(从平台证书切换微信支付公钥验签必填),新注册商户没有平台证书验签必填
2.微信支付公钥验签回调,根据Wechatpay-Serial的PUB_KEY_ID_微信支付公钥ID关键词判断使用平台证书或微信公钥证书进行验签。
3.所有发起支付、转账等请求头添加Wechatpay-Serial: 微信支付公钥ID,根据文档要求使用微信支付公钥部分字段加密必须携带,以及平台证书切换微信支付公钥验签过程中凡是使用支付相关接口必须携带(切换完成并废弃平台证书可不携带,但部分字段必须携带)。

已测试微信小程序支付,支付回调通知没问题,因为本人是个体户,而且只有小程序能测试,其它功能没办法测试,请各位大佬测试,若没问题请求合并。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要把buildAuthorization方法改成init方法呢?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个pr怎么用到打包到项目里面

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildAuthorization原本就有得吧,我没改这个哦,我只添加了公钥id和公钥key变量名,在verifySign方法添加公钥验签功能,根据请求头含有PUB_KEY_ID_判断是公钥就使用公钥验签,没有则用平台证书,其它并没有改动。

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildAuthorization原本就有得吧,我没改这个哦,我只添加了公钥id和公钥key变量名,在verifySign方法添加公钥验签功能,根据请求头含有PUB_KEY_ID_判断是公钥就使用公钥验签,没有则用平台证书,其它并没有改动。

你看index.js 372行,

protected buildAuthorization(method: string, url: string, params?: Record<string, any>) {

变成了

  protected init(method: string, url: string, params?: Record<string, any>) {

调用的地方也同步被修改了,如396行

const authorization = this.buildAuthorization('POST', url, _params);

变成了

const authorization = this.init('POST', url, _params);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个pr怎么用到打包到项目里面

#87 这个issue里有说明如何打包到项目里,我按照步骤打包到项目里了

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildAuthorization原本就有得吧,我没改这个哦,我只添加了公钥id和公钥key变量名,在verifySign方法添加公钥验签功能,根据请求头含有PUB_KEY_ID_判断是公钥就使用公钥验签,没有则用平台证书,其它并没有改动。

你看index.js 372行,

protected buildAuthorization(method: string, url: string, params?: Record<string, any>) {

变成了

  protected init(method: string, url: string, params?: Record<string, any>) {

调用的地方也同步被修改了,如396行

const authorization = this.buildAuthorization('POST', url, _params);

变成了

const authorization = this.init('POST', url, _params);

我看了buildAuthorization,init代码重复了,调用那个问题都不大吧,我确实是没动过这两个方法,我改的时候对git不是很熟悉,拉取合并提交出现问题,我是用fork,可能拉取到别人改的也不说。

Copy link

@wengxiaoxiong wengxiaoxiong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants