-
Notifications
You must be signed in to change notification settings - Fork 126
添加微信支付公钥验签 #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
添加微信支付公钥验签 #91
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么要把buildAuthorization方法改成init方法呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个pr怎么用到打包到项目里面
There was a problem hiding this comment.
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_判断是公钥就使用公钥验签,没有则用平台证书,其它并没有改动。
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个pr怎么用到打包到项目里面
#87 这个issue里有说明如何打包到项目里,我按照步骤打包到项目里了
There was a problem hiding this comment.
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,可能拉取到别人改的也不说。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以
修改内容:
1.添加微信支付公钥证书和微信支付公钥ID的变量、接口,老商户号非必填(从平台证书切换微信支付公钥验签必填),新注册商户没有平台证书验签必填
2.微信支付公钥验签回调,根据Wechatpay-Serial的PUB_KEY_ID_微信支付公钥ID关键词判断使用平台证书或微信公钥证书进行验签。
3.所有发起支付、转账等请求头添加Wechatpay-Serial: 微信支付公钥ID,根据文档要求使用微信支付公钥部分字段加密必须携带,以及平台证书切换微信支付公钥验签过程中凡是使用支付相关接口必须携带(切换完成并废弃平台证书可不携带,但部分字段必须携带)。
已测试微信小程序支付,支付回调通知没问题,因为本人是个体户,而且只有小程序能测试,其它功能没办法测试,请各位大佬测试,若没问题请求合并。