Search in sources :

Example 1 with ErrorRequestException

use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.

the class YxMiniPayService method wxPay.

/**
 * 小程序支付
 *
 * @param orderId
 * @param openId   小程序openid
 * @param body
 * @param totalFee
 * @return
 * @throws WxPayException
 */
public WxPayMpOrderResult wxPay(String orderId, String openId, String body, Integer totalFee, String attach) throws WxPayException {
    String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
    if (StrUtil.isBlank(apiUrl)) {
        throw new ErrorRequestException("请配置api地址");
    }
    WxPayService wxPayService = WxPayConfiguration.getWxAppPayService();
    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
    orderRequest.setTradeType("JSAPI");
    orderRequest.setOpenid(openId);
    orderRequest.setBody(body);
    orderRequest.setOutTradeNo(orderId);
    orderRequest.setTotalFee(totalFee);
    orderRequest.setSpbillCreateIp("127.0.0.1");
    orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
    orderRequest.setAttach(attach);
    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
    return orderResult;
}
Also used : WxPayService(com.github.binarywang.wxpay.service.WxPayService) WxPayMpOrderResult(com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult) ErrorRequestException(co.yixiang.exception.ErrorRequestException) WxPayUnifiedOrderRequest(com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest)

Example 2 with ErrorRequestException

use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.

the class YxPayService method wxPay.

/**
 * 微信公众号支付
 *
 * @param orderId
 * @param openId   公众号openid
 * @param body
 * @param totalFee
 * @return
 * @throws WxPayException
 */
public WxPayMpOrderResult wxPay(String orderId, String openId, String body, Integer totalFee, String attach) throws WxPayException {
    String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
    if (StrUtil.isBlank(apiUrl)) {
        throw new ErrorRequestException("请配置api地址");
    }
    WxPayService wxPayService = WxPayConfiguration.getPayService();
    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
    orderRequest.setTradeType("JSAPI");
    orderRequest.setOpenid(openId);
    orderRequest.setBody(body);
    orderRequest.setOutTradeNo(orderId);
    orderRequest.setTotalFee(totalFee);
    orderRequest.setSpbillCreateIp("127.0.0.1");
    orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
    orderRequest.setAttach(attach);
    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
    return orderResult;
}
Also used : WxPayService(com.github.binarywang.wxpay.service.WxPayService) WxPayMpOrderResult(com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult) ErrorRequestException(co.yixiang.exception.ErrorRequestException) WxPayUnifiedOrderRequest(com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest)

Example 3 with ErrorRequestException

use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.

the class YxPayService method refundOrder.

/**
 * 退款
 * @param orderId
 * @param totalFee
 * @throws WxPayException
 */
public void refundOrder(String orderId, Integer totalFee) throws WxPayException {
    String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
    if (StrUtil.isBlank(apiUrl)) {
        throw new ErrorRequestException("请配置api地址");
    }
    WxPayService wxPayService = WxPayConfiguration.getPayService();
    WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
    // 订单总金额
    wxPayRefundRequest.setTotalFee(totalFee);
    wxPayRefundRequest.setOutTradeNo(orderId);
    wxPayRefundRequest.setOutRefundNo(orderId);
    // 退款金额
    wxPayRefundRequest.setRefundFee(totalFee);
    wxPayRefundRequest.setNotifyUrl(apiUrl + "/api/notify/refund");
    wxPayService.refund(wxPayRefundRequest);
}
Also used : WxPayService(com.github.binarywang.wxpay.service.WxPayService) WxPayRefundRequest(com.github.binarywang.wxpay.bean.request.WxPayRefundRequest) ErrorRequestException(co.yixiang.exception.ErrorRequestException)

Example 4 with ErrorRequestException

use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.

the class YxPayService method routinePay.

/**
 * 微信小程序支付
 *
 * @param orderId
 * @param body
 * @param totalFee
 * @return
 * @throws WxPayException
 */
public WxPayMpOrderResult routinePay(String orderId, String body, String openId, Integer totalFee, String attach) throws WxPayException {
    String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
    if (StrUtil.isBlank(apiUrl)) {
        throw new ErrorRequestException("请配置api地址");
    }
    WxPayService wxPayService = WxPayConfiguration.getWxAppPayService();
    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
    orderRequest.setOpenid(openId);
    orderRequest.setTradeType("JSAPI");
    orderRequest.setBody(body);
    orderRequest.setOutTradeNo(orderId);
    orderRequest.setTotalFee(totalFee);
    orderRequest.setSpbillCreateIp("127.0.0.1");
    orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
    orderRequest.setAttach(attach);
    WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
    return orderResult;
}
Also used : WxPayService(com.github.binarywang.wxpay.service.WxPayService) WxPayMpOrderResult(com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult) ErrorRequestException(co.yixiang.exception.ErrorRequestException) WxPayUnifiedOrderRequest(com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest)

Example 5 with ErrorRequestException

use of co.yixiang.exception.ErrorRequestException in project yshopmall by guchengwuyue.

the class YxPayService method wxH5Pay.

/**
 * 微信H5支付
 *
 * @param orderId
 * @param body
 * @param totalFee
 * @return
 * @throws WxPayException
 */
public WxPayMwebOrderResult wxH5Pay(String orderId, String body, Integer totalFee, String attach) throws WxPayException {
    String apiUrl = redisHandler.getVal(ShopKeyUtils.getApiUrl());
    if (StrUtil.isBlank(apiUrl)) {
        throw new ErrorRequestException("请配置api地址");
    }
    WxPayService wxPayService = WxPayConfiguration.getPayService();
    WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
    orderRequest.setTradeType("MWEB");
    orderRequest.setBody(body);
    orderRequest.setOutTradeNo(orderId);
    orderRequest.setTotalFee(totalFee);
    orderRequest.setSpbillCreateIp("127.0.0.1");
    orderRequest.setNotifyUrl(apiUrl + "/api/wechat/notify");
    orderRequest.setAttach(attach);
    WxPayMwebOrderResult orderResult = wxPayService.createOrder(orderRequest);
    return orderResult;
}
Also used : WxPayService(com.github.binarywang.wxpay.service.WxPayService) ErrorRequestException(co.yixiang.exception.ErrorRequestException) WxPayUnifiedOrderRequest(com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest) WxPayMwebOrderResult(com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult)

Aggregations

ErrorRequestException (co.yixiang.exception.ErrorRequestException)8 WxPayService (com.github.binarywang.wxpay.service.WxPayService)7 WxPayUnifiedOrderRequest (com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest)5 WxPayMpOrderResult (com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult)3 WxPayRefundRequest (com.github.binarywang.wxpay.bean.request.WxPayRefundRequest)2 WxPayAppOrderResult (com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult)1 WxPayMwebOrderResult (com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult)1 WxMpService (me.chanjar.weixin.mp.api.WxMpService)1 WxMpMassTagMessage (me.chanjar.weixin.mp.bean.WxMpMassTagMessage)1 WxMpMassSendResult (me.chanjar.weixin.mp.bean.result.WxMpMassSendResult)1