Skip to content
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

微信支付现已支持HMAC-SHA256签名方式 #1351

Merged
merged 1 commit into from
Aug 25, 2018
Merged

微信支付现已支持HMAC-SHA256签名方式 #1351

merged 1 commit into from
Aug 25, 2018

Conversation

554393109
Copy link
Contributor

@554393109 554393109 commented Aug 22, 2018

微信支付现支持HMAC-SHA256签名方式(EncryptHelper.GetHmacSha256方法留待实现)

https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=4_3

添加 Senparc.Weixin.MP.TenPayLibV3.RequestHandler.CreateSha256Sign(string key, string value) 方法

修改 Senparc.Weixin.MP.TenPayLibV3.TenPayV3MicroPayRequestData 构造函数中 Sign签名方式,添加Sha256

其余支付实体对象同理修改

Signed-off-by: 554393109 554393109@qq.com

…gn签名方式,添加Sha256。

添加 Senparc.Weixin.MP.TenPayLibV3.RequestHandler.CreateSha256Sign(string key, string value) 方法。

https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=4_3

微信支付现已支持HMAC-SHA256签名方式(EncryptHelper.GetHmacSha256具体方法留待实现)。

Signed-off-by: 554393109 <554393109@qq.com>

// 现支持HMAC-SHA256签名方式(EncryptHelper.GetHmacSha256方法留待实现)
// https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=4_3
string sign = EncryptHelper.GetHmacSha256(sb.ToString(), "UTF-8").ToUpper();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

当前方法直接从上述CreateMd5Sign中复制修改名称而来

@JeffreySu
Copy link
Owner

意思是SHA256的算法实际上是没有写的?也只实现了这一个地方?

@554393109
Copy link
Contributor Author

@JeffreySu 是的 (TㅅT)

@JeffreySu JeffreySu added the task label Aug 24, 2018
@JeffreySu JeffreySu merged commit 7f33bb4 into JeffreySu:Developer Aug 25, 2018
@JeffreySu
Copy link
Owner

@554393109 我正在合并,看到你新建的方法里面已经用了EncryptHelper.GetHmacSha256()这个方法,这个是有效的,你的意思是还有哪里需要重新写的?

@554393109
Copy link
Contributor Author

554393109 commented Aug 25, 2018

是的,我PR的时候没有调整开发环境,拉源码下来直接改的,看到有EncryptHelper也是推测有sha256的方法。
按照微信文档的改动,应该是刷卡(小额)、公众号、原生扫码、APP、H5、小程序的
RequestData构造函数【设置RequestHandler】签名并赋值的地方都需要添加签名类型选择。
并且,微信官方文档在通过预下单的形式的支付场景,通知回调里面也添加了HMAC-SHA256的签名类型返回,所以CheckSign的方法
也是需要取参指定验签方式。
普通商户模式和服务商模式都是如此。

刚看了下代码,需要改动的类应该都在目录:

Senparc.Weixin.MP.TenPayLibV3.Request

由于我们的项目并没有用到Senparc的dll,所以对Senparc的支付模块并不太熟悉。抱歉
@JeffreySu

@JeffreySu
Copy link
Owner

@554393109 已经优化了,非常感谢!刚才发布了新的 Senparc.Weixin.TenPay 独立的模块,老的方法也都是兼容的,你可以试一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants