微信支付(小程序)-java配置

一:商户号配置与小程序设置

微信支付(小程序)-商户号配置与小程序配置

二:java引入微信jar包

        <!--  微信支付  -->
        <dependency>
            <groupId>com.github.binarywang</groupId>
            <artifactId>weixin-java-pay</artifactId>
            <version>3.8.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>guava</artifactId>
                    <groupId>com.google.guava</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>commons-io</artifactId>
                    <groupId>commons-io</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>commons-lang3</artifactId>
                    <groupId>org.apache.commons</groupId>
                </exclusion>
            </exclusions>
        </dependency>

三:项目存入商户号证书

注:这是商户号配置中,详细前往操作一中观看
在这里插入图片描述

四:配置参数与实体类

yml文件中配置

#  自定义配置
he:
  wx:
    appid: wx291cac11f428e94e
    secret: 2636dd0ae13ecafffc6b386799f5b2a6
    #微信支付
    pay:
      mchId: 商户号id
      mchKey: APIv2密钥
      keyPath: classpath:cert/apiclient_cert.p12  //证书路径 
      notifyUrl: https://服务器路径/api/pay/%s/%s 支付回调路径

读取微信支付配置的 实体类

package com.io.order.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@Data
@ConfigurationProperties(prefix = "he.wx.pay")
public class WxPayProperties {

    /**
     * 设置微信公众号或者小程序等的appid
     */
    private String appId;

    /**
     * 微信支付商户号
     */
    private String mchId;

    /**
     * 微信支付商户密钥
     */
    private String mchKey;

    /**
     * apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定
     */
    private String keyPath;

    /**
     * 支付回调Url
     */
    private String notifyUrl;
}

idea要有插件才能这样写

如果扳手那行是红色的那就是没有插件,需要你去下载。点击红色的那行查询需要的插件下载就行
在这里插入图片描述

五:支付编写

微信支付(小程序)-java实现与小程序实现

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值