Java企业支付实战 - 微信小程序登录及支付——亲测有效(超级详细)

这篇博客详细介绍了如何使用Java进行微信小程序支付的实战,包括注册商家、获取mchid、配置证书、签约产品、设置回调地址、注册小程序、绑定支付、引入weixinpay工具包以及实际操作中的注意事项,提供了相关网址和配置步骤。
摘要由CSDN通过智能技术生成

一、工具准备

微信支付官网

官网: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官网

https://uniapp.dcloud.io/

小程序官网

https://mp.weixin.qq.com/

工具下载

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、微信支付图解

img

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

img

img

img

以上安装步骤填写即可。

02、进入微信支付后台获取商家号mchid

img
img

四、微信支付-商家-配置商家证书及获取API私钥

目标

1:获取API私钥

https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_8_1.shtml

01、配置商家证书及获取API私钥

img

img

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
img

02、签约产品

img

六、微信支付-配置回调地址

目标

配偶在支付回调地址

配置如下

img

七、微信支付-微信小程序注册获取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、申请注册

img
img

01-2、获取APPID

img

02、微信小程序配置及认证

img

八、微信支付-小程序和微信支付绑定关系

目标

完成小程序和微信支付的绑定关系

01、小程序与微笑支付绑定

img

img

九、实战部分

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值