1 Star 0 Fork 30

zhiyong777 / live-payjs-sdk

forked from 阿希 / live-payjs-sdk 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
README.md 2.23 KB
一键复制 编辑 原始数据 按行查看 历史
阿希 提交于 2018-04-04 13:31 . no commit message

live-payjs-sdk

项目介绍:

官网: https://payjs.cn

可以体验一下支付流程: http://qiongbi.chenwenxi.cc

本项目是对payjs的api进行的一层封装,用于个人微信支付

Quick Start

API 能力

  • 扫码支付接口
  • 收银台支付接口(JSAPI模式)
  • 异步通知接口
  • 订单查询接口

如何使用

//密钥去官网申请
private WxPayApi api = new WxPayApi(new PayJSConfig("商户号", "密钥"));

/**生成支付的二维码*/
@Action
public JsonData getQr() throws IOException {
    //回调的url
    String url_huidiao = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/" + "pay/psyJs.huidiao.html";
    //封装支付信息
    ClientPayInfo payInfo = new ClientPayInfo();
    String id = "qb" + System.currentTimeMillis();
    payInfo.setTotal_fee(Convert.toLongValue(user.getAmount() * 100)).setBody(user.getEmail()).setNotify_url(url_huidiao).setOut_trade_no(id).setAttach("qb");

    ScanResult scan = api.scan(payInfo);
    user.setCreateTime(new JDateTime().getTimeInMillis());
    return new JsonData(scan);
}

/**验证订单信息(是否用户已经扫描支付完成)*/
@Action
public JsonData checkOrder() throws UnsupportedEncodingException {
    Order order = api.getOrder(orderId);//根据订单id获取订单信息
    if (order.getStatus() == 1) {// 支付成功
        this.look("支付完成");
    }
    return new JsonData(order);
}

/**收银台*/
@Action
public JsonData getWxPay() throws UnsupportedEncodingException{
    String url_huidiao = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/" + "pay/psyJs.huidiao.html";
    String callback_url = "http://qiongbi.chenwenxi.cc";//用户支付成功后,前端跳转地址
    ClientPayInfo payInfo = new ClientPayInfo();
    payInfo.setCallback_url(callback_url);
    String id = "qb" + System.currentTimeMillis();
    payInfo.setTotal_fee(Convert.toLongValue(user.getAmount() * 100)).setBody(user.getEmail()).setNotify_url(url_huidiao).setOut_trade_no(id).setAttach("qb");
    return new JsonData(payInfo);
}
Java
1
https://gitee.com/zhiyong777/live-payjs-sdk.git
git@gitee.com:zhiyong777/live-payjs-sdk.git
zhiyong777
live-payjs-sdk
live-payjs-sdk
master

搜索帮助