一、工具准备
微信支付官网
官网:https://pay.weixin.qq.com
注册商家地址:https://pay.weixin.qq.com/index.php/apply/applyment_home/guide_normal
微信小程序支付:https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_8_2.shtml
uniapp官网
小程序官网
工具下载
hbuilderx
https://www.dcloud.io/hbuilderx.html
微信小程序开发工具:
https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
vscode工具:
https://code.visualstudio.com/
Linux客户端工具FinalShell下载
http://www.hostbuf.com/t/988.html
二、微信支付-申请流程和步骤
01、微信支付图解
02、申请注册流程和文档
官方网址:https://pay.weixin.qq.com/index.php
官方文档:https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/index.shtml
PC端微信小程序Navtive文档:https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_7_0.shtml
微信小程序支付对接文档:https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_8_1.shtml
三、微信支付-注册商家及获取商家mchid
目标
1、注册商家号
2、获取商家号mcid
01、注册成为商家
注册商家地址:https://pay.weixin.qq.com/index.php/apply/applyment_home/guide_normal
以上安装步骤填写即可。
02、进入微信支付后台获取商家号mchid
四、微信支付-商家-配置商家证书及获取API私钥
目标
1:获取API私钥
https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_8_1.shtml
01、配置商家证书及获取API私钥
02、生成私钥的代码
import java.util.Random;
public class RandomStringGenerator {
/**
* 获取一定长度的随机字符串
*
* @param length 指定字符串长度
* @return 一定长度的字符串
*/
public static String getRandomStringByLength(int length) {
String base = "abcdefghijklmnopqrstuvwxyz0123456789";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
}
五、微信支付-商家-签约产品
目标
1:签约微信小程序支付产品
2:签约Native支付产品
01、产品类型表
文档:https://pay.weixin.qq.com/wiki/doc/apiv3/index.shtml
02、签约产品
六、微信支付-配置回调地址
目标
配偶在支付回调地址
配置如下
七、微信支付-微信小程序注册获取APPID
目标
1、注册微信小程序
2、微信支付绑定微信小程序
01、注册微信小程序
申请官网:https://mp.weixin.qq.com/
注册地址:https://mp.weixin.qq.com/cgi-bin/registermidpage?action=index&lang=zh_CN&token=
01-1、申请注册
01-2、获取APPID
02、微信小程序配置及认证
八、微信支付-小程序和微信支付绑定关系
目标
完成小程序和微信支付的绑定关系
01、小程序与微笑支付绑定
九、实战部分
9.1 导入weixinpay工具包
工具包: https://download.csdn.net/download/qq_41096598/43396028
9.2 引入依赖
<!--微信支付请求 begin-->
<dependency>
<groupId>com.github.wxpay</groupId>
<artifactId>wxpay-sdk</artifactId>
<version>0.0.3</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.10