Git Product home page Git Product logo

wepay's Introduction

WepayBuild Status

轻量的微信支付组件(A Lightweight Wechat Pay Component)

  • 包引入:

     <dependency>
         <groupId>me.hao0</groupId>
         <artifactId>wepay-core</artifactId>
         <version>1.2.4</version>
     </dependency>
  • 依赖包,注意引入项目时是否需要exclude:

     <dependency>
         <groupId>me.hao0</groupId>
         <artifactId>common</artifactId>
         <version>1.1.2</version>
     </dependency>
     
  • 基本用法:

     Wepay wepay = WepayBuilder
                     .newBuilder(appId, appKey, mchId)
                     .config1(...)	// 其他可选配置
                     ...
                     .build();
     
     wepay.module().api();
  • 已实现的组件:

    • 支付pay();
    • 退款refund();
    • 订单order();
    • 通知notify();
    • 账单bill()
  • API文档这里

  • 关于测试:

    • 测试用例中是一些基本测试,需作一些配置:

       // 在test/reources目录中配置dev.properties
       // 包括appId(APP ID), appKey(支付密钥), mchId(商户号)
       Properties props = new Properties();
       InputStream in = Object.class.getResourceAsStream("/dev.properties");
       props.load(in);
       in.close();
        
        // 配置证书,退款需要证书,不配置可测试除退款的接口 
       Path path = Paths.get("/path/to/your_cert.p12");
       byte[] data = Files.readAllBytes(path);
      
       wepay = WepayBuilder.newBuilder(
               props.getProperty("appId"),
               props.getProperty("appKey"),
               props.getProperty("mchId"))
               .certPasswd(props.getProperty("mchId"))
               .certs(data)
               .build();
    • wepay-demo项目是一个可运行web项目,方便测试,可按如下步骤进行测试,复制wepay-demo中的app-example.propertiesapp.properties,并作相应配置:

       # 微信app id
       appId=
       # 微信支付key
       appKey=
       # 商户号
       mchId=
       # 支付通知url
       payNotifyUrl=${your_domain}/notifies/paid
    • 注意:**payNotifyUrl **应该配置为微信服务器可以外网调用的地址,本地测试建议使用ngrok工具来作本地外网映射。

    • wepay-demo根目录运行以下命令即可:

       mvn clean jetty:run -Dmaven.test.skip -Djetty.port={自定义端口号}
    • 动态二维码支付可访问(请求正常后,会出现由联图生成的二维码图片,用微信扫描支付成功后,后台会得到对应通知Notifies):

       http://localhost:{port}/pays/qrpay?orderNumber={自定义订单号}
    • 退款可访问(提交成功后,微信会有消息通知):

       http://localhost:{port}/refunds/apply?orderNumber={商户订单号}		```
       
  • 相关文档:

  • 历史版本:

    • 1.0.0:

      • 基本功能实现。
    • 1.1.0:

      • 增加账单查询。
    • 1.1.1:

      • 修复prepayId。
    • 1.1.2:

      • 修复JS/APP支付签名问题。
    • 1.2.2:

      • 增加退款查询字段: 退款状态, 退款金额, 退款入账方。
    • 1.2.3:

      • fix isNullOrEmpty。
    • 1.2.4:

      • 升级common至1.1.2, 可配置解析微信XML的编码类型, 默认为UTF-8, 防止与本地默认编码不一致。
  • 相关组件:

  • 你是好人:

    • 倘若你钱多人傻花不完,小弟乐意效劳😊,掏出你的微信神器做回好人吧:

    • 倘若你还不够尽兴,继续掏出你的支付宝神器,疯狂扫吧:

wepay's People

Contributors

ihaolin avatar yanfch avatar

Watchers

James Cloos 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.