Search in sources :

Example 1 with WxPayMicropayRequest

use of com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest in project leopard by tanhaichao.

the class WeixinPayClientImpl method micropay.

// String outTradeNo, String scene, String authCode, String subject, double totalAmount, String notifyUrl
@Override
public WxPayMicropayResult micropay(String outTradeNo, String scene, String authCode, String subject, double amount, String spbillCreateIp) throws WeixinPayException {
    // String paymentId = StringUtil.uuid();
    // weixinPayDao.add(paymentId, outTradeNo);
    // TODO
    int totalFee = (int) DecimalUtil.multiply(amount, 100);
    // 接口文档地址: https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1
    // .appid(appId).mchId(mchId);
    WxPayMicropayRequest.Builder builder = WxPayMicropayRequest.newBuilder();
    // builder .nonceStr(nonceStr);
    // builder .sign(sign)
    builder.outTradeNo(outTradeNo);
    builder.totalFee(totalFee);
    builder.body(subject);
    builder.spbillCreateIp(spbillCreateIp);
    builder.authCode(authCode);
    WxPayMicropayRequest request = builder.build();
    try {
        return wxPayService.micropay(request);
    } catch (WxPayException e) {
        throw new WeixinPayException("访问刷卡支付接口出现异常.", e);
    }
}
Also used : WxPayException(com.github.binarywang.wxpay.exception.WxPayException) WxPayMicropayRequest(com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest)

Aggregations

WxPayMicropayRequest (com.github.binarywang.wxpay.bean.request.WxPayMicropayRequest)1 WxPayException (com.github.binarywang.wxpay.exception.WxPayException)1