Giter Site home page Giter Site logo

wxpay's Introduction

微信支付小工具使用教程

  1. 下载相关的(预)发行release版本(com.one.wxpay.zip)

  2. 将zip解压到本地maven仓库中

  3. 添加maven坐标如下

    <dependency>
        <groupId>com.one.wxpay</groupId>
        <artifactId>wxpay</artifactId>
        <version>{下载的版本号}</version>
    </dependency>
  4. application.yml配置必要参数

    //示例子
    spring:
      wxpay:
        //微信提供的appId
        app-id: ******
        //微信商户平台ID
        mch-id: ******
        //微信商户平台Key
        mch-key: ******
  5. 注入服务

    @Autowired
    private WxpayService wxpayService;
  6. 调用方法并传入相关参数发起支付

    /* 
    * sendPay方法参数介绍
    * Map必填参数介绍(其他参数参照官方文档):
    * body:商品描述
    * out_trade_no:商户订单号
    * total_fee:价格(单位:分)
    * spbill_create_ip:发起支付的IP地址
    * notify_url trade_type:微信支付回调地址
    * trade_type:交易类型(由于一个后台系统可能提供多端app支付使用,故此参数并没加入配置文件中)
    * openid:当trade_type为JSAPI时为必传
    */
    // 使用示例
    @RestController
    public class Test() {
       @Autowired
       WxpayService wxpayService;
    
       @GetMapping("/pay") 
       public Map<String,String> pay{
          Map<String,String> params = new HashMap<>();
    
    
         params.put("body","测试-商品");
    
         params.put("out_trade_no", UUID.randomUUID().toString().replace("-","").toUpperCase());
    
         params.put("total_fee","100");
    
         params.put("spbill_create_ip",request.getRemoteAddr());
    
         params.put("notify_url","你的回调地址 请输入全域名");
    
         params.put("trade_type","NATIVE");
    
         return wxpayService.sendPay(params);
       }
    }

    注:微信支付详细参数链接

wxpay's People

Contributors

lwl9710 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.