• 微信支付及支付回调


    1.微信支付

    通过微信平台为商家提供代收款服务

    1.1微信支付的业务–商户注册微信支付业务:

    1.2申请支付订单–商户向支付平台申请支付链接

    支付订单,并不是用户提交的商品订单,而是商品向微信支付平台申请的支付链接

    1.2.1导入微信支付的依赖

    wxpay的maven依赖

    
        com.github.wxpay
        wxpay-sdk
        0.0.3
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

    1.2.2创建微信支付配置类,配置商品信息

    创建一类,实现WXPayConfig接口

    重写三分方法,分别设置商品AppID商户ID商户密钥

    package com.qfedu.config;
    
    import com.github.wxpay.sdk.WXPayConfig;
    
    import java.io.InputStream;
    
    /**
     * @Description:
     * @Author : Jerry
     * @create : 2022-07-02 18:16
     */
    public class MyPayConfig implements WXPayConfig {
        @Override
        public String getAppID() {
            return "wx632c8f211f8122c6";
        }
    
        @Override
        public String getMchID() {
            return "1497984412";
        }
    
        @Override
        public String getKey() {
            return "sbNCm1JnevqI36LrEaxFwcaT0hkGxFnc";
        }
    
        @Override
        public InputStream getCertStream() {
            return null;
        }
    
        @Override
        public int getHttpConnectTimeoutMs() {
            return 0;
        }
    
        @Override
        public int getHttpReadTimeoutMs() {
            return 0;
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42

    1.2.3设置订单的参数

    //设置当前订单信息
    HashMap data = new HashMap<>();
    data.put("fee_type","CNY");         //支付币种
    data.put("total_fee","0.1");        //支付总金额
    data.put("body","咪咪虾条");        // 商品描述
    //使用当前用户订单的编号作为当前支付交易的交易号
    data.put("out_trade_no", orderId);
    data.put("trade_type","NATIVE");    //交易类型
    data.put("notify_url","/pay/success");          //设置支付完成时的回调方法接口
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    修改OrderService的实现类:

    package com.qfedu.fmmall.service.impl;
    
    import com.qfedu.fmmall.dao.OrderItemMapper;
    import com.qfedu.fmmall.dao.OrdersMapper;
    import com.qfedu.fmmall.dao.ProductSkuMapper;
    import com.qfedu.fmmall.dao.ShoppingCartMapper;
    import com.qfedu.fmmall.entity.OrderItem;
    import com.qfedu.fmmall.entity.Orders;
    import com.qfedu.fmmall.entity.ProductSku;
    import com.qfedu.fmmall.entity.ShoppingCartVO;
    import com.qfedu.fmmall.service.OrderService;
    import com.qfedu.fmmall.vo.R;
    import com.qfedu.fmmall.vo.ResStatus;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;
    
    import java.math.BigDecimal;
    import java.util.*;
    
    /**
     * @Description:
     * @Author : Jerry
     * @create : 2022-07-01 17:46
     */
    @Service
    public class OrderSer
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
  • 相关阅读:
    【搭建私人图床】使用LightPicture开源搭建图片管理系统并远程访问
    PLSQL工具 数据库连接名的设置
    论文导读 | 支持事务与图分析的图存储系统
    JVM常见面试题
    【配电网优化】基于粒子群算法结合MATPOWER实现GARVER-6配电网系统优化网架规划及交流潮流计算附matlab代码
    SpringBoot核心注解
    一次性彻底解决 Web 工程中文乱码问题
    创建第一个Springboot 项目
    线性代数对角化
    【ML】第六章 决策树
  • 原文地址:https://blog.csdn.net/m0_67403073/article/details/126774758