当前位置:网站首页>Wechat jsapi payment pit summary
Wechat jsapi payment pit summary
2022-06-12 20:00:00 【What's crunchy? Our favorite】
1. Different payment scenarios
https://pay.weixin.qq.com/wiki/doc/apiv3/index.shtml
What we do is embed the web page in the official account , Call wechat payment . So the choice is JSAPI
2. signType The problem of inconsistency
At the beginning of the query , In the documents issued by the product signType yes md5. But I saw it on the official website signType yes RSA. This is because of the wechat 2 A version :v2 and v3
https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay-1.shtml
v2 Support HMAC-SHA256 and MD5, Below v2 JSAPI Documents
https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&index=6
v3 Support RSA, Below v3 JSAPI Documents
https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_4.shtml
We've done it before app Wechat payment , For interface compatibility , therefore JSAPI Also used v2 edition
3. Angular call WeixinJSBridge
Angular call WeixinJSBridge, Prompt name not found , Compilation fails ?
https://developers.weixin.qq.com/community/develop/doc/000e062d098200b9d549cad3d51c00
4. The payment scenario is illegal
Because all I did at first was app Wechat payment of , So you need to add support JSAPI Transactions type (trade_type)
https://blog.csdn.net/SEA_mihu/article/details/107684206
https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_2
5. Multi micro signal processing
Because in the beginning app When calling wechat payment , A wechat official account for collection
Now it is a new micro signal . The solution is to 2 Get one of every micro signal Wechat payment merchant number above
6. Payment verification signature failed
6.1 Routine solution
Wechat official has a post about failed payment verification signature :https://developers.weixin.qq.com/community/develop/doc/000cc4ffa2c2083e565b4dabe5fc09
Payment verification signature failed , The problem for most people is Inconsistent signatures , Parameter case problem, etc . But we are unified md5, Parameters are copied directly from the document , Writing is definitely not What's the problem? .
There are others. , Reset required key, Because if we reset here , May lead to app There is a problem with your payment , So it is not easy to try this .
6.2 Second signature
Later, I checked a lot of information . I found many people saying Second signature , Because I returned directly from the backstage sign { "package": "Sign=WXPay", "appid": "wx666", "sign": "7E9360EE36", "partnerid": "1116401", "prepayid": "wx66000", "noncestr": "345332", "timestamp": "1625620895" }
, What I did at that time was to take these parameters returned from the background Call wechat payment directly after formatting :
https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&index=6
So I didn't pay much attention to the problem of secondary signature . But it always prompts that the signature fails , Later I found this 3 This article says https://www.cnblogs.com/6324/p/10281798.html
https://developers.weixin.qq.com/community/develop/article/doc/00088264e006f0cc423c1732d5b413
https://developers.weixin.qq.com/community/develop/doc/000ca273cf0ef8348f6c868c55b800?highLine=%25E6%2594%25AF%25E4%25BB%2598%25E9%25AA%258C%25E8%25AF%2581%25E7%25AD%25BE%25E5%2590%258D%25E5%25A4%25B1%25E8%25B4%25A5
Lenovo communicated with the backstage before , Then I realized . This sign yes Need to put appId , timeStamp, nonceStr,package, signType 5 Parameter splicing key in the future Reuse md5 Encrypted . The previous interface returns sign Because it is for app Call the... Used by wechat payment , therefore sign Encryption method and JSAPI Not the same . So the verification fails all the time
6.3 Sand sculpture document
Looking back ,v2 JSAPI Payment documents It does say , Yes 5 Parameters are encrypted , And it is marked with case attention
But in the signature algorithm that jumps from the document to the past , https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_3 Signature algorithm demo There are some other parameters , and appid Also lowercase .
And in the signature verification tool ,https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=20_1 appid Or lower case
From the signature algorithm documentation and verification signature tool here , Basically and JSAPI Adjust the sentence "pay" " Parameters need to be re signed " It doesn't correspond to .
6.4 Debugging tips
① Use the signature verification tool (https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=20_1) Quickly generate sign
② Create a new one index.html hold JSAPI Of demo code copy go in .
At the same time, we need to put ① The parameters and from ① Got sign Replace here .
③ Go online directly index.html Just test it out
边栏推荐
- WordPress station group tutorial automatic collection of pseudo original release tutorial
- system()
- 7:00 tonight | application of PhD debate self supervised learning in Recommendation System
- First build green, then build city
- MySQL Basics
- Reading small programs based on wechat e-book graduation design works (7) Interim inspection report
- Equipment management - borrowing / returning module interface code
- Installation and testing of open source deep learning framework plaidml
- What is an index?
- 今晚7:00 | PhD Debate 自监督学习在推荐系统中的应用
猜你喜欢
WordPress optimization tutorial makes WordPress open faster
Demand and business model innovation - demand 1 - Introduction to demand engineering
Deep feature synthesis and genetic feature generation, comparison of two automatic feature generation strategies
Interpreter Files
Wechat e-book reading applet graduation design completion works (3) background function
[generation confrontation network learning III] reading notes of Bigan paper and its principle understanding
Test prerequisites: recommend a special cross platform app performance test tool!
Pyinstaller packaging tutorial packaging resource files
用户权限和组权限
In 2022, 20 cities with the largest number of college students in China
随机推荐
硬件测试之—纹波测试为什么不要使用接地夹子
Wechat e-book reading applet graduation design completion works (3) background function
How mysterious is "PIP not an internal or external command, nor a runnable program or batch file"
Microsoft Word 教程,如何在 Word 中插入页码、目录?
What is the difference between union and union all
[leetcode] small thinking of optimal division
4 R basic exercises
Kyma application connectivity feature introduction
In 2022, 20 cities with the largest number of college students in China
模块八作业
Theory + practice will help you master the dynamic programming method
Reading small programs based on wechat e-book graduation design works (7) Interim inspection report
Reading small program based on wechat e-book graduation design (4) opening report
基于微信电子书阅读小程序毕业设计毕设作品(8)毕业设计论文模板
Compilation of programs
Process creation fork (), demise wait()
[generation confrontation network learning III] reading notes of Bigan paper and its principle understanding
基于微信电子书阅读小程序毕业设计毕设作品(5)任务书
基于微信电子书阅读小程序毕业设计毕设作品(7)中期检查报告
BigTable (II): how BigTable achieves scalability and high performance