Native payment of wechat payment java version
Recently, I came across some things about wechat payment in my work. I saw that the demo given to me was in PHP version. In addition, I really didn't dare to compliment the wechat payment documents. After walking through many pits, I took time to make a summary.
1、 Preliminary preparation
For wechat development, you must first apply for a public account. After successful application, you will be sent some necessary information in the form of e-mail. There are development documents, necessary information in development and test data query in the public account.
2、 Tools 1 MD5 encryption tool class
2. Commonutil tool class, which is used to install and replace the XML required by wechat. The following return new string (XML. Tostring() getBytes(),"ISO8859-1"); Change the UTF-8 in the tool class to iso8859-1, otherwise the Chinese in the wechat order will be garbled, which can be displayed correctly after modification.
3. Clientcustomssl tool class, which is used to generate sign and create wechat order package com pay. utils. weixin;
4. Call wechat payment interface
Httpclient jar package and JSON jar package: download address.