SpringBoot + 微信支付(小程序)案例

这篇具有很好参考价值的文章主要介绍了SpringBoot + 微信支付(小程序)案例。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.注册

1.1接入微信支付

https://pay.weixin.qq.com/index.php/apply/applyment_home/guide_normal

1.2微信公众平台(小程序)

https://pay.weixin.qq.com/index.php/apply/applyment_home/guide_normal

2. 小程序微信认证

https://mp.weixin.qq.com/wxamp/basicprofile/index?token=1160814128&lang=zh_CN
进入后找到最下方的:设置-微信认证
需要 300RMB
springboot微信小程序支付,spring boot,微信,小程序

3. 微信支付和小程序进行关联

https://pay.weixin.qq.com/index.php/extend/merchant_appid/mapay_platform/account_manage
打开网页
点击 : 产品中心-AppID账号管理-关联AppID
springboot微信小程序支付,spring boot,微信,小程序文章来源地址https://www.toymoban.com/news/detail-727078.html

//这个是对应项目的文件名称   放在resources下面
wxpay.properties
#appid 小程序id(小程序获取)
v3.appId=XXXXXX
#商户id  (微信支付获取)
v3.merchantId=XXXXXXXXX
#小程序appSecret  (小程序获取)
v3.appSecret=203732ad918e3dbcd515d2f9a7587529
#证书序列号(微信支付获取) 这个在账号中心API 安全里面获取  地址:https://kf.qq.com/faq/161222NneAJf161222U7fARv.html
v3.merchantSerialNumber=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#证书  放在resources下
v3.certKeyPath=/wxPay/apiclient_key.pem 
#apiV3Key   获取地址  https://pay.weixin.qq.com/index.php/core/cert/api_cert#/
v3.apiV3Key=XXXXXXXXXXXXXXXXXXXXXXXXX
//这个回调接口的线上地址   微信要调用的接口  你也用内网穿透
v3.wxnotify=http://XXXXXXXXXXXx
配置实体类 
WxPayConfig
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
@Data
//如果你的参数写在配置文件里面  就打开这个
//@ConfigurationProperties(prefix = "wx.pay")
@PropertySource("wxpay.properties")
//配置前缀
@ConfigurationProperties(prefix = "v3")
public class WxPayConfig {
    //appId
    private String appId;
    //商户id
    private String merchantId;
    //appSecret
    private String appSecret;
    //证书序列号
    private String merchantSerialNumber;
    //私钥路径  
    private String certKeyPath;
    //商户秘钥
    private String apiV3Key;
    //回调通知地址
    private String wxnotify;
}

/**
* 订单实体类
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class StuOrderBo extends BaseEntity {

    /**
     * 订单id
     */
    private Long id;

    /**
     * 设备信息
     */
    private String deviceInfo;
    /**
     * 订单号
     */
    private String orderNo;

    /**
     * 三方订单号
     */
    private String thirdOrderNo;

    /**
     * 交易类型
     */
    private String transactionType;

    /**
     * 付款银行
     */
    private String paymentBank;

    /**
     * 订单金额
     */
    private BigDecimal orderAmount;

    /**
     * 支付完成时间
     */
    private Date paymentCompletionTime;

    /**
     * 支付类型  0微信/1支付宝
     */
    private String paymentType;

    /**
     * 0未退款/1已退款
     */
    private String isRefund;

    /**
     * 学生用户id
     */
    private Long stuUserId;
    /**
     * openId
     */
    private String openId;

    /**
     * 微信支付退款单号
     */
    private String refundId;

    /**
     * 退款单号
     */
    private String outRefundNo;

}


    /**
     * 生产订单 10分钟内有效
     *     @RepeatSubmit()这个注解是防止重复提交的 
     *     StuOrderBo 这必须有 单号和总额 这里是自己的订单还需要微信的订单
     */
    //@RepeatSubmit()
    @PostMapping("createOrder")
    public R<StuOrderBo> createOrder(@Validated(AddGroup.class) @RequestBody StuOrderBo bo) {
    	//设置订单号
 		bo.setOrderNo(UUID.randomUUID().toString().replace("-", "")); 
 		//看看业务设置订单的金额   
		bo.getOrderAmount.multiply(new BigDecimal(100)
        //添加金额
        bo.setOrderAmount(totalFee);	
        RedisUtils.setCacheObject( bo.getId(), bo, Duration.ofMinutes(10));
        return R.ok(bo);
    }

    /**
     * 更具stuUserId查询订单号
     */
    @GetMapping("getByStuUserIdOrder")
    public Object getByOpenidOrder(@NotNull(message = "stuUserId不可未空") Long stuUserId) {
        return R.ok(RedisUtils.getCacheObject(stuUserId));
    }

//这个类是预支付信息
import lombok.Data;

@Data
public class WxPayInfo {
    /**
     * appid
     */
    private String appId;
    /**
     * 随机字符串
     */
    private String timeStamp;
    /**
     * 签名
     */
    private String nonceStr;
    /**
     * 预支付id
     */
    private String prepay_id;
    private String packageStr;
    /**
     * 签名类型
     */
    private String signType;
    private String paySign;
}

下面是控制器实体类接口
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.Sign;
import cn.hutool.crypto.asymmetric.SignAlgorithm;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
import com.wechat.pay.contrib.apache.httpclient.auth.Verifier;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator;
import com.wechat.pay.contrib.apache.httpclient.cert.CertificatesManager;
import com.wechat.pay.contrib.apache.httpclient.notification.Notification;
import com.wechat.pay.contrib.apache.httpclient.notification.NotificationHandler;
import com.wechat.pay.contrib.apache.httpclient.notification.NotificationRequest;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.security.PrivateKey;
import java.security.SecureRandom;
import java.time.Duration;
import java.util.*;


/**
 * 微信支付相关接口
 *
 * @author xsk
 */
@RestController
@RequestMapping("/wx/pay")
@Slf4j
public class WxPayController extends BaseController {
    private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    private static final Random RANDOM = new SecureRandom();
  
    //配置微信支付
    @Autowired
    private WxPayConfig wxPayConfig;
    //微信专业httpClient
    private static CloseableHttpClient httpClient;
    //生成签名用
    private static Sign sign;
    //证书管理器
    private static CertificatesManager certificatesManager;

	/*
	*初始化配置
	*/
    @PostConstruct
    public void init() throws Exception {
        //获取商户私钥
        PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(getFileInputStream(wxPayConfig.getCertKeyPath()));
        // 获取证书管理器实例
        certificatesManager = CertificatesManager.getInstance();
        sign = SecureUtil.sign(SignAlgorithm.SHA256withRSA, merchantPrivateKey.getEncoded(), null);
        // 向证书管理器增加需要自动更新平台证书的商户信息
        certificatesManager.putMerchant(wxPayConfig.getMerchantId(), new WechatPay2Credentials(wxPayConfig.getMerchantId(),
            new PrivateKeySigner(wxPayConfig.getMerchantSerialNumber(), merchantPrivateKey)), wxPayConfig.getApiV3Key().getBytes(StandardCharsets.UTF_8));
        // 从证书管理器中获取verifier
        Verifier verifier = certificatesManager.getVerifier(wxPayConfig.getMerchantId());
        //用于构造HttpClient
        WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
            .withMerchant(wxPayConfig.getMerchantId(), wxPayConfig.getMerchantSerialNumber(), merchantPrivateKey)
            .withValidator(new WechatPay2Validator(verifier));
        httpClient = builder.build();
    }

    /**
     * 使用getResourceAsStream直接从resources根路径下获取文件流
     *
     * @param path
     */
    private InputStream getFileInputStream(String path) {
        InputStream in = this.getClass().getResourceAsStream(path);
        return in;
    }


	/**
	* 微信支付下单返回预支付id
	*/
    @PostMapping("/createOrder")
    public R createOrder(@RequestBody StuOrderBo bo) throws Exception {
        JSONObject obj = new JSONObject();
        obj.put("appid", wxPayConfig.getAppId());
        obj.put("mchid", wxPayConfig.getMerchantId());
        //设置订单过期时间 (选填 ) 一定要设置不然一直不过期
        obj.put("time_expire", DateUtils.toExpirationTime(RedisUtils.getTimeToLive(bo.getStuUserId())));
        obj.put("description", "这个地方填写商品的信息");
        obj.put("out_trade_no", bo.getOrderNo());
        //线上地址
        obj.put("notify_url", wxPayConfig.getWxnotify());
        JSONObject amount = new JSONObject();
        //获取订单的金额  微信支付需要的单位是分钱   如果你是元需要*100
        amount.put("total", bo.totalFee.intValue());
        obj.put("amount", amount);
        JSONObject payer = new JSONObject();
        //支付者的openId
        payer.put("openid", bo.getOpenId());
        obj.put("payer", payer);
        log.info("请求参数为:" + JSON.toJSONString(obj));

        //执行请求
        JSONObject jsonResult = sendHttpPost(obj, "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi");
        String prePayId = jsonResult.getString("prepay_id");
        if (prePayId == null) {
            String message = jsonResult.getString("message");
            throw new Exception(message);
        }
        WxPayInfo wxPayInfo = new WxPayInfo();
        wxPayInfo.setAppId(wxPayConfig.getAppId());
        String timeStamp = String.valueOf(System.currentTimeMillis() / 1000);
        wxPayInfo.setTimeStamp(timeStamp);
        String nonceStr = IdUtil.fastSimpleUUID();
        wxPayInfo.setNonceStr(nonceStr);
        wxPayInfo.setPrepay_id(prePayId);
        String packageStr = "prepay_id=" + prePayId;
        wxPayInfo.setPackageStr(packageStr);
        wxPayInfo.setSignType("RSA");
        String signString = wxPayConfig.getAppId() + "\n" + timeStamp + "\n" + nonceStr + "\n" + packageStr + "\n";
        wxPayInfo.setPaySign(Base64.encode(sign.sign(signString.getBytes())).toString());
        //可以进行一些操作
        
        return R.ok(wxPayInfo);

    }


    /**
     * 支付回调通知处理
     *
     * @param
     * @return
     * @throws
     */
    @PostMapping("/notify/order")
    public void parseOrderNotifyResult(HttpServletRequest servletRequest) {
        String timeStamp = servletRequest.getHeader("Wechatpay-Timestamp");
        String nonce = servletRequest.getHeader("Wechatpay-Nonce");
        String signature = servletRequest.getHeader("Wechatpay-Signature");
        String certSn = servletRequest.getHeader("Wechatpay-Serial");
     //   String stuUserId= "";
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(servletRequest.getInputStream()))) {
            StringBuilder stringBuilder = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line);
            }
            String obj = stringBuilder.toString();
            log.info("回调数据:{},{},{},{},{}", obj, timeStamp, nonce, signature, certSn);
            Verifier verifier = certificatesManager.getVerifier(wxPayConfig.getMerchantId());
            String sn = verifier.getValidCertificate().getSerialNumber().toString(16).toUpperCase(Locale.ROOT);
            NotificationRequest request = new NotificationRequest.Builder().withSerialNumber(sn)
                .withNonce(nonce)
                .withTimestamp(timeStamp)
                .withSignature(signature)
                .withBody(obj)
                .build();
            NotificationHandler handler = new NotificationHandler(verifier, wxPayConfig.getApiV3Key().getBytes(StandardCharsets.UTF_8));
            // 验签和解析请求体
            Notification notification = handler.parse(request);
            JSONObject notifyResult = JSON.parseObject(notification.getDecryptData());
            System.out.println("notifyResult:" + notifyResult);
            //做一些操作
           
            log.info(notifyResult.toString());
        } catch (Exception e) {
            log.error("微信支付回调失败", e);
            //关闭订单
        } finally {
            //删除订单
          //  RedisUtils.deleteKeys(stuUserId);
        }
    }

    /**
     * 微信退款
     *
     * @param bo
     * @return
     * @throws Exception
     */
    @PostMapping("/refund")
    public Object refund(@RequestBody StuOrderBo bo) throws Exception {
     
        JSONObject obj = new JSONObject();
        obj.put("transaction_id", bo.getThirdOrderNo());
        String outRefundNo = getOrderNumber();
        obj.put("out_refund_no", outRefundNo); //退款的单号
        JSONObject amount = new JSONObject();
        //查询订单需要退款的金额
        StuOrderVo stuOrderVo = iStuOrderService.getByOrderNo(bo.getOrderNo());
        BigDecimal total = stuOrderVo.getOrderAmount();
        amount.put("refund", total.intValue());
        amount.put("total", total.intValue());
        amount.put("currency", "CNY");
        obj.put("amount", amount);
        HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/refund/domestic/refunds");
        httpPost.addHeader("Accept", "application/json");
        httpPost.addHeader("Content-type", "application/json; charset=utf-8");
        httpPost.setEntity(new StringEntity(obj.toJSONString(), "UTF-8"));
        try {
            //执行请求
            CloseableHttpResponse response = httpClient.execute(httpPost);
            String bodyAsString = EntityUtils.toString(response.getEntity());
            JSONObject refundObject = JSONObject.parseObject(bodyAsString);
            String refund_id = refundObject.getString("refund_id");
            if (refund_id == null) {
                String message = JSONObject.parseObject(bodyAsString).getString("message");
                return message;
            }
           
            return "退款成功";
        } catch (IOException e) {
          //
        }
    }

    /**
     * 查询 微信支付订单
     *
     * @throws Exception
     */
    @SaIgnore
    @GetMapping("queryWxOrder/{openid}")
    public R queryWxOrder(@PathVariable(value = "openid") @NotNull(message = "openid不可为空值") String openid) throws Exception {
        StuOrderVo stuOrderVo = RedisUtils.getCacheObject(CacheConstants.STU_ORDER_KEY + openid);
        if (ObjectUtils.isEmpty(stuOrderVo)) {
            return R.fail("订单不存在");
        }
        //请求URL
        URIBuilder uriBuilder = new URIBuilder("https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/" + stuOrderVo.getOrderNo());
        uriBuilder.setParameter("mchid", wxPayConfig.getMerchantId());
        //完成签名并执行请求
        HttpGet httpGet = new HttpGet(uriBuilder.build());
        httpGet.addHeader("Accept", "application/json");
        CloseableHttpResponse response = httpClient.execute(httpGet);
        try {
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                System.out.println("success,return body = " + EntityUtils.toString(response.getEntity()));
                return R.ok("微信支付订单查询成功", JSONObject.parseObject(EntityUtils.toString(response.getEntity())));
            } else if (statusCode == 204) {
                return R.ok("成功", JSONObject.parseObject(EntityUtils.toString(response.getEntity())));
            }
            return R.ok(statusCode, "请求失败", JSONObject.parseObject(EntityUtils.toString(response.getEntity())));

        } finally {
            response.close();
        }
    }

    /**
     * 查询 微信支付订单
     *
     * @throws Exception
     */
    @SaIgnore
    @GetMapping("queryByOrderNo/{orderNo}")
    public R queryByOrderNo(@PathVariable(value = "orderNo") @NotNull(message = "orderNo") String orderNo) throws Exception {
        //请求URL
        URIBuilder uriBuilder = new URIBuilder("https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/" + orderNo);
        uriBuilder.setParameter("mchid", wxPayConfig.getMerchantId());
        //完成签名并执行请求
        HttpGet httpGet = new HttpGet(uriBuilder.build());
        httpGet.addHeader("Accept", "application/json");
        CloseableHttpResponse response = httpClient.execute(httpGet);
        try {
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                System.out.println("success,return body = " + EntityUtils.toString(response.getEntity()));
                return R.ok("微信支付订单查询成功", JSONObject.parseObject(EntityUtils.toString(response.getEntity())));
            } else if (statusCode == 204) {
                return R.ok("成功", JSONObject.parseObject(EntityUtils.toString(response.getEntity())));
            }
            return R.ok(statusCode, "请求失败", JSONObject.parseObject(EntityUtils.toString(response.getEntity())));

        } finally {
            response.close();
        }
    }
    /**
     * 关闭微信支付订单
     *
     * @throws Exception
     */

    @SaIgnore
    @PostMapping("/closeWxOrder/{openid}")
    public R CloseWxOrder(@PathVariable(value = "openid") @NotNull(message = "openid 不可为空值") String openid) throws Exception {
        StuOrderVo stuOrderVo = iStuOrderService.getByOpenidOrder(openid);
        //请求URL
        HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/" + stuOrderVo.getOrderNo() + "/close");
        //请求body参数
        String reqdata = "{\"mchid\": \"" + wxPayConfig.getMerchantId() + "\"}";
        StringEntity entity = new StringEntity(reqdata, "utf-8");
        entity.setContentType("application/json");
        httpPost.setEntity(entity);
        httpPost.setHeader("Accept", "application/json");
        //完成签名并执行请求
        CloseableHttpResponse response = httpClient.execute(httpPost);
        try {
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                System.out.println("success,return body = " + EntityUtils.toString(response.getEntity()));
                RedisUtils.deleteKeys(CacheConstants.STU_ORDER_KEY + openid);
                return R.ok("关闭成功", EntityUtils.toString(response.getEntity()));
            } else if (statusCode == 204) {
                RedisUtils.deleteKeys(CacheConstants.STU_ORDER_KEY + openid);
                return R.ok("关闭成功", null);
            }
            return R.fail("请求失败", EntityUtils.toString(response.getEntity()));
        } finally {
            RedisUtils.deleteKeys(CacheConstants.STU_ORDER_KEY + openid);
            response.close();
        }
    }

    /**
     * 获取openid
     *
     * @param
     */
    @SaIgnore
    @GetMapping(value = "/getOpenid")
    public R login(String code) {
        // 根据小程序穿过来的code想这个url发送请求
        String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxPayConfig.getAppId() + "&secret=" + wxPayConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
        // 发送请求,返回Json字符串
        String str = WeChatUtil.httpRequest(url, "GET", null);
        // 转成Json对象 获取openid
        JSONObject jsonObject = JSONObject.parseObject(str);
        // 我们需要的openid,在一个小程序中,openid是唯一的
        String openid = jsonObject.get("openid").toString();
        return R.ok("授权成功", openid);
    }

    private JSONObject sendHttpPost(JSONObject obj, String url) throws IOException {
        HttpPost httpPost = new HttpPost(url);
        httpPost.addHeader("Accept", "application/json");
        httpPost.addHeader("Content-type", "application/json; charset=utf-8");
        httpPost.setEntity(new StringEntity(obj.toJSONString(), "UTF-8"));
        try {
            CloseableHttpResponse response = httpClient.execute(httpPost);
            String bodyAsString = EntityUtils.toString(response.getEntity());
            JSONObject jsonResult = JSONObject.parseObject(bodyAsString);
            return jsonResult;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private JSONObject sendHttpGet(JSONObject obj, String url) throws IOException {
        HttpGet httpGet = new HttpGet();
        HttpPost httpPost = new HttpPost(url);
        httpPost.addHeader("Accept", "application/json");
        httpPost.addHeader("Content-type", "application/json; charset=utf-8");
        httpPost.setEntity(new StringEntity(obj.toJSONString(), "UTF-8"));
        try {
            CloseableHttpResponse response = httpClient.execute(httpPost);
            String bodyAsString = EntityUtils.toString(response.getEntity());
            JSONObject jsonResult = JSONObject.parseObject(bodyAsString);
            return jsonResult;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * 获取随机字符串 Nonce Str
     *
     * @return String 随机字符串
     */
    public static String generateNonceStr() {
        char[] nonceChars = new char[32];
        for (int index = 0; index < nonceChars.length; ++index) {
            nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
        }
        return new String(nonceChars);
    }


    /**
     * 生产订单号
     *
     * @return
     */
    private String getOrderNumber() {
        return UUID.randomUUID().toString().replace("-", "");
    }

到了这里,关于SpringBoot + 微信支付(小程序)案例的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • springboot实现微信小程序V3微信支付功能

    appId:小程序appid appSecret:小程序的secret mchId:商户号 keyPath:商户私钥路径(apiclient_key.pem) certPath:证书路径(apiclient_cert.pem) platFormPath:平台证书(cert.pem) 注 : 需要通过写程序生成平台证书(见v3Get()方法) apiKey3:apiv3密钥 serialnumber:商户证书序列号 notifyUrl:回调地

    2024年02月12日
    浏览(39)
  • springboot整合IJPay实现微信支付-V3---微信小程序

    微信支付适用于许多场合,如小程序、网页支付、但微信支付相对于其他支付方式略显麻烦,我们使用IJpay框架进行整合 JPay 让支付触手可及, 封装了微信支付、支付宝支付、银联支付常用的支付方式以及各种常用的接口。不依赖任何第三方 mvc 框架,仅仅作为工具使用简单

    2024年02月02日
    浏览(55)
  • SpringBoot对接微信小程序支付功能开发(一,下单功能)

    1,接入前准备: 接入模式选择直连模式; 申请小程序,得到APPID,并开通微信支付; 申请微信商户号,得到mchid,并绑定APPID; 配置商户API key,下载并配置商户证书,根据微信官方文档操作:https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_8_1.shtml 上面都配置完之后会得到:小

    2024年02月10日
    浏览(48)
  • uniapp+java/springboot实现微信小程序APIV3支付功能

    微信小程序的支付跟H5的支付和APP支付流程不一样,本次只描述下小程序支付流程。 1.微信小程序账号 文档:小程序申请 小程序支付需要先认证,如果你有已认证的公众号,也可以通过公众号免费注册认证小程序。 一般300元,我是认证的政府的免费。 然后登录小程序,设置

    2023年04月19日
    浏览(35)
  • springboot基于spring boot的在线答题微信小程序

    :在线答题微信小程序;JAVA语言;MySQL数据库; Abstract WeChat widget for online question answering is an important part of the exam. Online question answering is the main channel for students to obtain task information. In order to facilitate students to view task information and exams on the website, a simple and portable online W

    2024年02月20日
    浏览(34)
  • 毕业设计springboot基于spring boot的在线答题微信小程序

    :在线答题微信小程序;JAVA语言;MySQL数据库; Abstract WeChat widget for online question answering is an important part of the exam. Online question answering is the main channel for students to obtain task information. In order to facilitate students to view task information and exams on the website, a simple and portable online W

    2024年04月26日
    浏览(32)
  • springboot 小程序微信支付

    看效果   参考文章:SpringBoot + 小程序 整合微信支付和退款 V2版 - 码农教程 本文仅作记录 参考文章: UniApp + SpringBoot 实现微信支付和退款 - 奔跑的砖头 - 博客园 Springboot整合支付宝支付参考: UniApp + SpringBoot 实现支付宝支付和退款 - 奔跑的砖头 - 博客园 微信支付商户号接入微

    2024年02月05日
    浏览(23)
  • SpringBoot对接小程序微信支付

    目录 前言 一、准备工作 2.1、企业微信小程序开通 2.1.1、获取开发者ID 2.1.2、开通支付功能 2.1.3、关联商户号 2.2、企业商户号的开通 2.2.1、获取商户号mch_id 2.2.2、获取商户API密钥mch_key 二、整体流程 三、后端项目搭建 3.1、统一下单 3.2、支付支付回调 3.3、问题排查 3.4、统一下

    2024年02月04日
    浏览(39)
  • 基于SpringBoot+微信小程序的壁纸小程序

    ✌全网粉丝20W+,csdn特邀作者、博客专家、CSDN新星计划导师、java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 🍅 文末获取项目下载方式 🍅 一、项目背景介绍: 为什么要做壁纸表情包头像的小程序?我们有很多

    2023年04月12日
    浏览(33)
  • SpringBoot微信小程序商城源码(前台+后台)

    🍓🍓 文末获取联系 🍓🍓 产品介绍   本产品用java技术开发的小程序前后台源码代码和视频开发教程。   产品主要包含一套Spring Boot小程序商城代码和一套小程序开发全栈实战项目视频课程。 小程序商城源代码介绍:   系统由:Spring Boot后端API,web管理后台 和 微信小

    2024年02月10日
    浏览(79)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包